From c9b6be2243c18d5fe2668a50b71ce98ab1b75ac2 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 5 Apr 2024 17:28:58 -0400 Subject: [PATCH] Load 3D plugins when running from build dir on macOS --- 3d-viewer/3d_cache/3d_plugin_manager.cpp | 46 ++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/3d-viewer/3d_cache/3d_plugin_manager.cpp b/3d-viewer/3d_cache/3d_plugin_manager.cpp index 3317e84983..c3dc1b6713 100644 --- a/3d-viewer/3d_cache/3d_plugin_manager.cpp +++ b/3d-viewer/3d_cache/3d_plugin_manager.cpp @@ -155,13 +155,47 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void ) fn.AssignDir( PATHS::GetStockPlugins3DPath() ); checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths ); #else - // Search path on OS X is - // (1) Machine /Library/Application Support/kicad/PlugIns/3d - checkPluginPath( PATHS::GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths ); + if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) + { + // Exe will be at /pcbnew/pcbnew.app/Contents/MacOS/pcbnew for standalone + // Plugin will be at /kicad/KiCad.app/Contents/PlugIns/3d + fn.Assign( wxStandardPaths::Get().GetExecutablePath() ); - // (2) Bundle kicad.app/Contents/PlugIns/3d - fn.AssignDir( PATHS::GetStockPlugins3DPath() ); - checkPluginPath( fn.GetPathWithSep(), searchpaths ); + if( fn.GetName() == wxT( "kicad" ) ) + { + fn.AppendDir( wxT( ".." ) ); // Contents + } + else + { + fn.AppendDir( wxT( ".." ) ); // Contents + fn.AppendDir( wxT( ".." ) ); // pcbnew.app + fn.AppendDir( wxT( ".." ) ); // pcbnew + fn.AppendDir( wxT( ".." ) ); // Build root + fn.AppendDir( wxT( "kicad" ) ); + fn.AppendDir( wxT( "KiCad.app" ) ); + fn.AppendDir( wxT( "Contents" ) ); + } + + fn.AppendDir( wxT( "PlugIns" ) ); + fn.AppendDir( wxT( "3d" ) ); + fn.MakeAbsolute(); + + std::string testpath = std::string( fn.GetPathWithSep().ToUTF8() ); + checkPluginPath( testpath, searchpaths ); + + // Also check when running KiCad manager from build dir + + } + else + { + // Search path on OS X is + // (1) Machine /Library/Application Support/kicad/PlugIns/3d + checkPluginPath( PATHS::GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths ); + + // (2) Bundle kicad.app/Contents/PlugIns/3d + fn.AssignDir( PATHS::GetStockPlugins3DPath() ); + checkPluginPath( fn.GetPathWithSep(), searchpaths ); + } #endif std::list< wxString >::iterator sPL = searchpaths.begin();