From dffd1179c5207284b58e86901693c28a8311ba92 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 20 Apr 2019 15:08:34 -0400 Subject: [PATCH] Add a mechanism to load kifaces when run from the build directory This is useful when working on code paths that rely on KiWay communications, since you can run and debug the kicad application without needing to run an install task first. --- common/kiway.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/common/kiway.cpp b/common/kiway.cpp index 4923afca1f..ef94296ab1 100644 --- a/common/kiway.cpp +++ b/common/kiway.cpp @@ -34,6 +34,7 @@ #include #include +#include KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT]; @@ -131,6 +132,19 @@ const wxString KIWAY::dso_search_path( FACE_T aFaceId ) fn.SetName( name ); +#ifdef DEBUG + // To speed up development, it's sometimes nice to run kicad from inside + // the build path. In that case, each program will be in a subdirectory. + // To find the DSOs, we need to go up one directory and then enter a subdirectory + // with the same name as the DSO (without the prefix). + + if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) + { + fn.RemoveLastDir(); + fn.AppendDir( name + 1 ); + } +#endif + // Here a "suffix" == an extension with a preceding '.', // so skip the preceding '.' to get an extension fn.SetExt( KIFACE_SUFFIX + 1 ); // + 1 => &KIFACE_SUFFIX[1]