Allow finding kicad_3dsg when running from build dir

This might also come in handy later when we use more dynamic libs
This commit is contained in:
Jon Evans 2021-03-21 09:16:47 -04:00
parent 9a13835f5d
commit cdb352bb24
5 changed files with 39 additions and 0 deletions

View File

@ -32,6 +32,7 @@
#include <config.h>
#include <core/arraydim.h>
#include <id.h>
#include <kiplatform/app.h>
#include <settings/settings_manager.h>
#include <logging.h>
@ -199,6 +200,19 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
{
wxString dname = dso_search_path( aFaceId );
// Insert DLL search path for kicad_3dsg from build dir
if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
{
wxFileName myPath = wxStandardPaths::Get().GetExecutablePath();
if( !myPath.GetPath().EndsWith( wxT( "pcbnew" ) ) )
{
myPath.RemoveLastDir();
myPath.AppendDir( wxT( "pcbnew" ) );
KIPLATFORM::APP::AddDynamicLibrarySearchPath( myPath.GetPath() );
}
}
wxDynamicLibrary dso;
void* addr = NULL;

View File

@ -102,3 +102,8 @@ void KIPLATFORM::APP::SetShutdownBlockReason( wxWindow* aWindow, const wxString&
void KIPLATFORM::APP::ForceTimerMessagesToBeCreatedIfNecessary()
{
}
void KIPLATFORM::APP::AddDynamicLibrarySearchPath( const wxString& aPath )
{
}

View File

@ -82,6 +82,15 @@ namespace KIPLATFORM
* Call as needed in an application to ensure timers are dispatched
*/
void ForceTimerMessagesToBeCreatedIfNecessary();
/**
* Inserts a search path for loading dynamic libraries. The exact place this new path ends
* up in the dynamic library search order is platform-dependent, but generally this can be
* used to make sure dynamic libraries are found in non-standard runtime situations.
*
* @param aPath is the full path to insert
*/
void AddDynamicLibrarySearchPath( const wxString& aPath );
}
}

View File

@ -111,3 +111,9 @@ void KIPLATFORM::APP::ForceTimerMessagesToBeCreatedIfNecessary()
MSG msg;
PeekMessage( &msg, nullptr, WM_TIMER, WM_TIMER, PM_NOREMOVE );
}
void KIPLATFORM::APP::AddDynamicLibrarySearchPath( const wxString& aPath )
{
SetDllDirectoryA( aPath.c_str() );
}

View File

@ -63,3 +63,8 @@ void KIPLATFORM::APP::SetShutdownBlockReason( wxWindow* aWindow, const wxString&
void KIPLATFORM::APP::ForceTimerMessagesToBeCreatedIfNecessary()
{
}
void KIPLATFORM::APP::AddDynamicLibrarySearchPath( const wxString& aPath )
{
}