Fix compilation and install for OSX plus general code cleanup
This commit is contained in:
parent
4d20f32fd0
commit
5b0a250609
|
@ -96,44 +96,6 @@ static const wxString sha1ToWXString( const unsigned char* aSHA1Sum )
|
|||
}
|
||||
|
||||
|
||||
static bool sha1Matches( const unsigned char* sha1a, const unsigned char* sha1b )
|
||||
{
|
||||
for( int i = 0; i < 20; ++i )
|
||||
{
|
||||
if( sha1a[i] != sha1b[i] )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool isSHA1null( const unsigned char* aSHA1Sum )
|
||||
{
|
||||
if( NULL == aSHA1Sum )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aSHA1Sum";
|
||||
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
for( int i = 0; i < 20; ++i )
|
||||
{
|
||||
if( 0 != aSHA1Sum[i] )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
class S3D_CACHE_ENTRY
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -843,7 +843,7 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString&
|
|||
{
|
||||
aResult.clear();
|
||||
|
||||
if( aIndex < 0 || aIndex >= aString.size() )
|
||||
if( aIndex >= aString.size() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#include <wx/stdpaths.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "pgm_base.h"
|
||||
#include "3d_plugin_manager.h"
|
||||
#include "plugins/3d/3d_plugin.h"
|
||||
#include "3d_cache/sg/scenegraph.h"
|
||||
|
@ -118,6 +120,8 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
|
|||
std::list< wxString > pluginlist;
|
||||
wxFileName fn;
|
||||
|
||||
#ifndef __WXMAC__
|
||||
|
||||
#ifdef DEBUG
|
||||
// set up to work from the build directory
|
||||
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
|
||||
|
@ -144,18 +148,6 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
|
|||
checkPluginPath( wxT( "/usr/local/lib/kicad/plugins/3d" ), searchpaths );
|
||||
checkPluginPath( wxT( "/opt/kicad/lib/kicad/plugins/3d" ), searchpaths );
|
||||
|
||||
#ifdef __APPLE__
|
||||
// XXX - we want to use GetOSX... so add support for that somehow in order to avoid hard coding
|
||||
// "/Library/Application Support/kicad/plugins/3d"
|
||||
checkPluginPath( wxT( "/Library/Application Support/kicad/plugins/3d" ), searchpaths );
|
||||
|
||||
// /Library/Application Support/kicad/plugins
|
||||
//fn.Assign( GetOSXKicadMachineDataDir() );
|
||||
//fn.AppendDir( wxT( "plugins" ) );
|
||||
//fn.AppendDir( wxT( "3d" ) );
|
||||
//checkPluginPath( fn.GetPathWithSep(), searchpaths );
|
||||
#endif
|
||||
|
||||
// note: GetUserDataDir() gives '.pcbnew' rather than '.kicad' since it uses the exe name;
|
||||
fn.Assign( wxStandardPaths::Get().GetUserDataDir() );
|
||||
fn.AppendDir( wxT( ".kicad" ) );
|
||||
|
@ -163,6 +155,22 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
|
|||
fn.AppendDir( wxT( "3d" ) );
|
||||
checkPluginPath( fn.GetPathWithSep(), searchpaths );
|
||||
|
||||
#else
|
||||
|
||||
// Search path on OS X is
|
||||
// (1) User ~/Library/Application Support/kicad/PlugIns/3d
|
||||
checkPluginPath( GetOSXKicadUserDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
|
||||
// (2) Machine /Library/Application Support/kicad/PlugIns/3d
|
||||
checkPluginPath( GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
|
||||
// (3) Bundle kicad.app/Contents/PlugIns/3d
|
||||
fn.Assign( Pgm().GetExecutablePath() );
|
||||
fn.AppendDir( wxT( "Contents" ) );
|
||||
fn.AppendDir( wxT( "PlugIns" ) );
|
||||
fn.AppendDir( wxT( "3d" ) );
|
||||
checkPluginPath( fn.GetPathWithSep(), searchpaths );
|
||||
|
||||
#endif
|
||||
|
||||
std::list< wxString >::iterator sPL = searchpaths.begin();
|
||||
std::list< wxString >::iterator ePL = searchpaths.end();
|
||||
|
||||
|
@ -269,7 +277,18 @@ void S3D_PLUGIN_MANAGER::listPlugins( const wxString& aPath,
|
|||
return;
|
||||
|
||||
nameFilter = wxT( "*" );
|
||||
|
||||
#ifndef __WXMAC__
|
||||
nameFilter.Append( wxDynamicLibrary::GetDllExt( wxDL_MODULE ) );
|
||||
#else
|
||||
// wxDynamicLibrary::GetDllExt( wxDL_MODULE ) will return ".bundle" on OS X.
|
||||
// This might be correct, but cmake builds a ".so" for a library MODULE.
|
||||
// Per definition a loadable "xxx.bundle" is similar to an "xxx.app" app
|
||||
// bundle being a folder with some special content in it. We obviously don't
|
||||
// want to have that here for our loadable module, so just use ".so".
|
||||
nameFilter.Append( wxT( ".so" ) );
|
||||
#endif
|
||||
|
||||
wxString lp = wd.GetNameWithSep();
|
||||
|
||||
if( wd.GetFirst( &lName, nameFilter, wxDIR_FILES ) )
|
||||
|
|
|
@ -29,14 +29,22 @@ add_library( kicad_3dsg SHARED
|
|||
ifsg_api.cpp
|
||||
)
|
||||
|
||||
if( APPLE )
|
||||
# puts library into the main kicad.app bundle in build tree
|
||||
set_target_properties( kicad_3dsg PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_LIB_DIR}"
|
||||
INSTALL_NAME_DIR "${OSX_BUNDLE_BUILD_LIB_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
find_file( S3DSG_VERSION_FILE sg_version.h
|
||||
PATHS ${CMAKE_SOURCE_DIR}/include/plugins/3dapi NO_DEFAULT_PATH )
|
||||
|
||||
if( NOT ${S3DSG_VERSION_FILE} STREQUAL "S3DSG_VERSION_FILE-NOTFOUND" )
|
||||
|
||||
# extract the "#define SG_VERSION_*" lines
|
||||
# extract the "#define KICADSG_VERSION_*" lines
|
||||
file( STRINGS ${S3DSG_VERSION_FILE} _version
|
||||
REGEX "^[' ','\t']*#define[' ','\t']*SG_VERSION_.*" )
|
||||
REGEX "^[' ','\t']*#define[' ','\t']*KICADSG_VERSION_.*" )
|
||||
|
||||
foreach( SVAR ${_version} )
|
||||
string( REGEX MATCH KICADSG_VERSION_[M,A,J,O,R,I,N,P,T,C,H,E,V]* _VARNAME ${SVAR} )
|
||||
|
|
|
@ -48,16 +48,11 @@ void C3D_RENDER_OGL_LEGACY::reload()
|
|||
|
||||
COBJECT2D_STATS::Instance().ResetStats();
|
||||
|
||||
printf("InitSettings...\n");
|
||||
unsigned stats_startReloadTime = GetRunningMicroSecs();
|
||||
m_settings.InitSettings();
|
||||
unsigned stats_endReloadTime = GetRunningMicroSecs();
|
||||
|
||||
SFVEC3F camera_pos = m_settings.GetBoardCenter3DU();
|
||||
m_settings.CameraGet().SetBoardLookAtPos( camera_pos );
|
||||
|
||||
unsigned stats_start_OpenGL_Load_Time = GetRunningMicroSecs();
|
||||
|
||||
// Create Board
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
printf("Create board...\n");
|
||||
|
@ -297,7 +292,6 @@ void C3D_RENDER_OGL_LEGACY::reload()
|
|||
float radius = filledCircle->GetRadius() * 2.0f; // Double because the render triangle
|
||||
float radiusSquared = radius * radius;
|
||||
|
||||
const float texture_factor = (0.9f/(float)SIZE_OF_CIRCLE_TEXTURE) + 1.0f;
|
||||
const float f = (sqrtf(2.0f) / 2.0f) * radius * 0.9;// * texture_factor;
|
||||
|
||||
layerTriangles->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, layer_z_top ),
|
||||
|
@ -793,14 +787,6 @@ void C3D_RENDER_OGL_LEGACY::reload()
|
|||
layerColor );
|
||||
}// for each layer on map
|
||||
|
||||
unsigned stats_end_OpenGL_Load_Time = GetRunningMicroSecs();
|
||||
|
||||
#ifdef RAYTRACING_PRINT_STATISTICS
|
||||
printf( "C3D_RENDER_OGL_LEGACY::reload times:\n" );
|
||||
printf( " Reload board: %.3f ms\n", (float)( stats_endReloadTime - stats_startReloadTime ) / 1000.0f );
|
||||
printf( " Loading to openGL: %.3f ms\n", (float)( stats_end_OpenGL_Load_Time - stats_start_OpenGL_Load_Time ) / 1000.0f );
|
||||
COBJECT2D_STATS::Instance().PrintStats();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -328,11 +328,6 @@ else()
|
|||
set( KICAD_BIN ${CMAKE_INSTALL_PREFIX}
|
||||
CACHE PATH "Location of KiCad binaries." FORCE )
|
||||
|
||||
set( KICAD_LIB /Applications/kicad.app/Contents/Macos
|
||||
CACHE PATH "Location of KiCad shared objects" FORCE )
|
||||
|
||||
set( KICAD_USER_PLUGIN /Applications/kicad.app/SharedSupport/plugins
|
||||
CACHE PATH "Location of KiCad user-loaded plugins" FORCE )
|
||||
|
||||
# some paths to single app bundle
|
||||
set( OSX_BUNDLE_MAIN "kicad.app" )
|
||||
|
@ -345,16 +340,22 @@ else()
|
|||
set( OSX_BUNDLE_BUILD_BIN_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_BIN_DIR}" )
|
||||
set( OSX_BUNDLE_BUILD_LIB_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_LIB_DIR}" )
|
||||
set( OSX_BUNDLE_BUILD_KIFACE_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
|
||||
set( OSX_BUNDLE_BUILD_PLUGIN_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
|
||||
set( OSX_BUNDLE_INSTALL_DIR "${KICAD_BIN}/${OSX_BUNDLE_MAIN}" )
|
||||
set( OSX_BUNDLE_INSTALL_BIN_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_BIN_DIR}" )
|
||||
set( OSX_BUNDLE_INSTALL_LIB_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_LIB_DIR}" )
|
||||
set( OSX_BUNDLE_INSTALL_KIFACE_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
|
||||
set( OSX_BUNDLE_INSTALL_PLUGIN_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
|
||||
|
||||
# everything provided with the application bundle goes into
|
||||
# kicad.app/Contents/SharedSupport => accessible via GetDataDir()
|
||||
# everything else to the .dmg image
|
||||
set( KICAD_DATA ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_SUP_DIR}
|
||||
CACHE PATH "Location of KiCad data files." FORCE )
|
||||
set( KICAD_LIB ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_LIB_DIR}
|
||||
CACHE PATH "Location of KiCad shared objects" FORCE )
|
||||
set( KICAD_USER_PLUGIN ${OSX_BUNDLE_INSTALL_PLUGIN_DIR}
|
||||
CACHE PATH "Location of KiCad user-loaded plugins" FORCE )
|
||||
set( KICAD_TEMPLATE ${KICAD_DATA}/template
|
||||
CACHE PATH "Location of KiCad template files." FORCE )
|
||||
set( KICAD_PLUGINS ${KICAD_DATA}/plugins
|
||||
|
@ -364,6 +365,9 @@ else()
|
|||
set( KICAD_DEMOS demos
|
||||
CACHE PATH "Location of KiCad demo files." FORCE )
|
||||
|
||||
# RPATH setttings for building shared libraries
|
||||
set( CMAKE_MACOSX_RPATH FALSE )
|
||||
|
||||
# Override default paths for fixup_bundle
|
||||
set( OSX_BUNDLE_OVERRIDE_PATHS "
|
||||
function( gp_item_default_embedded_path_override item default_embedded_path_var )
|
||||
|
@ -652,6 +656,7 @@ add_subdirectory( pagelayout_editor )
|
|||
add_subdirectory( potrace )
|
||||
add_subdirectory( bitmap2component )
|
||||
add_subdirectory( pcb_calculator )
|
||||
add_subdirectory( plugins ) # 3D plugins must be built before kicad
|
||||
add_subdirectory( kicad ) # should follow pcbnew, eeschema
|
||||
add_subdirectory( tools )
|
||||
add_subdirectory( utils )
|
||||
|
@ -777,6 +782,3 @@ if( UNIX AND NOT APPLE )
|
|||
include( CPack )
|
||||
|
||||
endif()
|
||||
|
||||
# 3D plugins
|
||||
add_subdirectory( plugins )
|
||||
|
|
|
@ -94,7 +94,9 @@ if( APPLE )
|
|||
# make main bundle relocatable
|
||||
install( CODE "
|
||||
# find all libs and modules
|
||||
file( GLOB BUNDLE_FIX_LIBS ${OSX_BUNDLE_INSTALL_KIFACE_DIR}/*.kiface )
|
||||
file( GLOB PLUGINS_KIFACE ${OSX_BUNDLE_INSTALL_KIFACE_DIR}/*.kiface )
|
||||
file( GLOB_RECURSE PLUGINS_SO ${OSX_BUNDLE_INSTALL_PLUGIN_DIR}/*.so )
|
||||
set( BUNDLE_FIX_LIBS \${PLUGINS_KIFACE} \${PLUGINS_SO} )
|
||||
if( ${SCRIPTING_HELPER} )
|
||||
file( GLOB WXPYTHON_DIR RELATIVE ${OSX_BUNDLE_INSTALL_LIB_DIR}/${PYTHON_LIB_DIR} ${OSX_BUNDLE_INSTALL_LIB_DIR}/${PYTHON_LIB_DIR}/wx-?.?-osx_cocoa )
|
||||
file( GLOB PYTHON_SCRIPTING_SO ${OSX_BUNDLE_INSTALL_LIB_DIR}/${PYTHON_LIB_DIR}/*.so )
|
||||
|
|
|
@ -8,11 +8,15 @@ add_library( s3d_plugin_idf MODULE
|
|||
${CMAKE_SOURCE_DIR}/utils/idftools/vrml_layer.cpp
|
||||
)
|
||||
|
||||
set_target_properties( s3d_plugin_idf PROPERTIES
|
||||
LINK_FLAGS -L${CMAKE_BINARY_DIR}/utils/idftools )
|
||||
|
||||
target_link_libraries( s3d_plugin_idf kicad_3dsg idf3 ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} )
|
||||
|
||||
if( APPLE )
|
||||
# puts library into the main kicad.app bundle in build tree
|
||||
set_target_properties( s3d_plugin_idf PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d"
|
||||
)
|
||||
endif()
|
||||
|
||||
install( TARGETS
|
||||
s3d_plugin_idf
|
||||
DESTINATION ${KICAD_USER_PLUGIN}/3d
|
||||
|
|
|
@ -783,7 +783,7 @@ static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent )
|
|||
|
||||
while( so != eo )
|
||||
{
|
||||
if( abs( (*so)->GetOutline()->GetThickness() ) < 0.001 )
|
||||
if( std::abs( (*so)->GetOutline()->GetThickness() ) < 0.001 )
|
||||
{
|
||||
++so;
|
||||
continue;
|
||||
|
@ -889,7 +889,7 @@ static bool makeOtherOutlines( IDF3_BOARD& brd, SGNODE* aParent )
|
|||
{
|
||||
pout = sc->second;
|
||||
|
||||
if( abs( pout->GetThickness() ) < 0.001 )
|
||||
if( std::abs( pout->GetThickness() ) < 0.001 )
|
||||
{
|
||||
++sc;
|
||||
continue;
|
||||
|
|
|
@ -51,6 +51,13 @@ add_library( s3d_plugin_vrml MODULE
|
|||
|
||||
target_link_libraries( s3d_plugin_vrml kicad_3dsg ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} )
|
||||
|
||||
if( APPLE )
|
||||
# puts library into the main kicad.app bundle in build tree
|
||||
set_target_properties( s3d_plugin_vrml PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d"
|
||||
)
|
||||
endif()
|
||||
|
||||
install( TARGETS
|
||||
s3d_plugin_vrml
|
||||
DESTINATION ${KICAD_USER_PLUGIN}/3d
|
||||
|
|
|
@ -58,7 +58,7 @@ WRL1BASE::~WRL1BASE()
|
|||
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool WRL1BASE::SetParent( WRL1NODE* aParent )
|
||||
bool WRL1BASE::SetParent( WRL1NODE* aParent, bool /* doUnlink */ )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode );
|
||||
bool SetParent( WRL1NODE* aParent );
|
||||
bool SetParent( WRL1NODE* aParent, bool doUnlink = true );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp );
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
class WRL1BASE;
|
||||
class SGNODE;
|
||||
struct SGCOLOR;
|
||||
class SGCOLOR;
|
||||
|
||||
/**
|
||||
* Class WRL1MATERIAL
|
||||
|
|
|
@ -78,7 +78,7 @@ WRL2BASE::~WRL2BASE()
|
|||
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool WRL2BASE::SetParent( WRL2NODE* aParent )
|
||||
bool WRL2BASE::SetParent( WRL2NODE* aParent, bool /* doUnlink */ )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool SetParent( WRL2NODE* aParent );
|
||||
bool SetParent( WRL2NODE* aParent, bool doUnlink = true );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue