* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <search_stack.h>
|
|
|
|
#include <pgm_base.h>
|
|
|
|
|
|
|
|
|
|
|
|
// put your best guesses in here, send the computer on a wild goose chase, its
|
|
|
|
// got nothing else to do.
|
|
|
|
|
|
|
|
void SystemDirsAppend( SEARCH_STACK* aSearchStack )
|
|
|
|
{
|
|
|
|
// No clearing is done here, the most general approach is NOT to assume that
|
|
|
|
// our appends will be the only thing in the stack. This function has no
|
|
|
|
// knowledge of caller's intentions.
|
|
|
|
|
|
|
|
// wxPathList::AddEnvList() is broken, use SEARCH_STACK::AddPaths().
|
|
|
|
// SEARCH_STACK::AddPaths() will verify readability and existence of
|
|
|
|
// each directory before adding.
|
|
|
|
SEARCH_STACK maybe;
|
|
|
|
|
|
|
|
// User environment variable path is the first search path. Chances are
|
|
|
|
// if the user is savvy enough to set an environment variable they know
|
|
|
|
// what they are doing. It should take precedence over anything else.
|
|
|
|
// Otherwise don't set it.
|
|
|
|
maybe.AddPaths( wxGetenv( wxT( "KICAD" ) ) );
|
|
|
|
|
|
|
|
// This is from CMAKE_INSTALL_PREFIX.
|
|
|
|
// Useful when KiCad is installed by `make install`.
|
|
|
|
// Use as second ranked place.
|
|
|
|
maybe.AddPaths( wxT( DEFAULT_INSTALL_PATH ) );
|
|
|
|
|
|
|
|
// Add the directory for the user-dependent, program specific, data files:
|
|
|
|
// Unix: ~/.appname
|
|
|
|
// Windows: C:\Documents and Settings\username\Application Data\appname
|
|
|
|
// Mac: ~/Library/Application Support/appname
|
|
|
|
maybe.AddPaths( wxStandardPaths::Get().GetUserDataDir() );
|
|
|
|
|
|
|
|
{
|
|
|
|
// Should be full path to this program executable.
|
|
|
|
wxString bin_dir = Pgm().GetExecutablePath();
|
|
|
|
|
|
|
|
#if defined(__MINGW32__)
|
|
|
|
// bin_dir uses unix path separator. So to parse with wxFileName
|
|
|
|
// use windows separator, especially important for server inclusion:
|
|
|
|
// like: \\myserver\local_path .
|
2014-03-20 18:07:19 +00:00
|
|
|
bin_dir.Replace( wxFileName::GetPathSeparator( wxPATH_UNIX ),
|
|
|
|
wxFileName::GetPathSeparator( wxPATH_WIN ) );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
wxFileName bin_fn( bin_dir, wxEmptyString );
|
|
|
|
|
|
|
|
// Dir of the global (not user-specific), application specific, data files.
|
|
|
|
// From wx docs:
|
|
|
|
// Unix: prefix/share/appname
|
|
|
|
// Windows: the directory where the executable file is located
|
|
|
|
// Mac: appname.app/Contents/SharedSupport bundle subdirectory
|
|
|
|
wxString data_dir = wxStandardPaths::Get().GetDataDir();
|
|
|
|
|
|
|
|
if( bin_fn.GetPath() != data_dir )
|
|
|
|
{
|
|
|
|
// add data_dir if it is different from the bin_dir
|
|
|
|
maybe.AddPaths( data_dir );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Up one level relative to binary path with "share" appended below.
|
|
|
|
bin_fn.RemoveLastDir();
|
|
|
|
maybe.AddPaths( bin_fn.GetPath() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The normal OS program file install paths allow for a binary to be
|
|
|
|
* installed in a different path from the library files. This is
|
|
|
|
* useful for development purposes so the library and documentation
|
|
|
|
* files do not need to be installed separately. If someone can
|
|
|
|
* figure out a way to implement this without #ifdef, please do.
|
|
|
|
*/
|
|
|
|
#if defined(__MINGW32__)
|
|
|
|
maybe.AddPaths( wxGetenv( wxT( "PROGRAMFILES" ) ) );
|
|
|
|
#elif __WXMAC__
|
|
|
|
maybe.AddPaths( wxString( wxGetenv( wxT( "HOME" ) ) ) + wxT( "/Library/Application Support" ) );
|
|
|
|
maybe.AddPaths( wxT( "/Library/Application Support" ) );
|
|
|
|
#else
|
|
|
|
maybe.AddPaths( wxGetenv( wxT( "PATH" ) ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(DEBUG) && 0
|
|
|
|
maybe.Show( "maybe wish list" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Append 1) kicad, 2) kicad/share, 3) share, and 4) share/kicad to each
|
|
|
|
// possible base path in 'maybe'. Since SEARCH_STACK::AddPaths() will verify
|
|
|
|
// readability and existence of each directory, not all of these will be
|
|
|
|
// actually appended.
|
|
|
|
for( unsigned i = 0; i < maybe.GetCount(); ++i )
|
|
|
|
{
|
|
|
|
wxFileName fn( maybe[i], wxEmptyString );
|
|
|
|
|
|
|
|
if( fn.GetPath().AfterLast( fn.GetPathSeparator() ) == wxT( "bin" ) )
|
|
|
|
{
|
|
|
|
fn.RemoveLastDir();
|
|
|
|
|
|
|
|
if( !fn.GetDirCount() )
|
|
|
|
continue; // at least on linux
|
|
|
|
}
|
|
|
|
|
|
|
|
aSearchStack->AddPaths( fn.GetPath() );
|
|
|
|
|
|
|
|
fn.AppendDir( wxT( "kicad" ) );
|
|
|
|
aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/kicad
|
|
|
|
|
|
|
|
fn.AppendDir( wxT( "share" ) );
|
|
|
|
aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/kicad/share
|
|
|
|
|
|
|
|
fn.RemoveLastDir(); // ../ clear share
|
|
|
|
fn.RemoveLastDir(); // ../ clear kicad
|
|
|
|
|
|
|
|
fn.AppendDir( wxT( "share" ) );
|
|
|
|
aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/share
|
|
|
|
|
|
|
|
fn.AppendDir( wxT( "kicad" ) );
|
|
|
|
aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/share/kicad
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(DEBUG) && 0
|
|
|
|
// final results:
|
|
|
|
aSearchStack->Show( __func__ );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|