Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
bd199b89
Commit
bd199b89
authored
Feb 03, 2015
by
Wayne Stambaugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set default footprint library table and 3D model library environment variables.
parent
4265fa60
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
10 deletions
+116
-10
config.h.cmake
CMakeModules/config.h.cmake
+9
-0
pgm_base.cpp
common/pgm_base.cpp
+81
-5
pgm_base.h
include/pgm_base.h
+26
-5
No files found.
CMakeModules/config.h.cmake
View file @
bd199b89
...
@@ -61,6 +61,15 @@
...
@@ -61,6 +61,15 @@
/// The install prefix defined in CMAKE_INSTALL_PREFIX.
/// The install prefix defined in CMAKE_INSTALL_PREFIX.
#define DEFAULT_INSTALL_PATH "@CMAKE_INSTALL_PREFIX@"
#define DEFAULT_INSTALL_PATH "@CMAKE_INSTALL_PREFIX@"
/// The install prefix used for KiCad's libraries.
/// These paths are only intended to be reasonable default values that work if
/// the user installs KiCad in the default path for a given platform.
#if defined( APPLE )
#define KICAD_DATA_PATH "/Library/Application Support/kicad"
#else
#define KICAD_DATA_PATH "@CMAKE_INSTALL_PREFIX@/@KICAD_DATA@"
#endif
/// When defined, build the GITHUB_PLUGIN for pcbnew.
/// When defined, build the GITHUB_PLUGIN for pcbnew.
#cmakedefine BUILD_GITHUB_PLUGIN
#cmakedefine BUILD_GITHUB_PLUGIN
...
...
common/pgm_base.cpp
View file @
bd199b89
...
@@ -59,6 +59,8 @@ const wxChar PGM_BASE::workingDirKey[] = wxT( "WorkingDir" ); // public
...
@@ -59,6 +59,8 @@ const wxChar PGM_BASE::workingDirKey[] = wxT( "WorkingDir" ); // public
static
const
wxChar
languageCfgKey
[]
=
wxT
(
"LanguageID"
);
static
const
wxChar
languageCfgKey
[]
=
wxT
(
"LanguageID"
);
static
const
wxChar
kicadFpLibPath
[]
=
wxT
(
"KicadFootprintLibraryPath"
);
static
const
wxChar
kicadFpLibPath
[]
=
wxT
(
"KicadFootprintLibraryPath"
);
static
const
wxChar
pathEnvVariables
[]
=
wxT
(
"EnvironmentVariables"
);
static
const
wxChar
traceEnvVars
[]
=
wxT
(
"KIENVVARS"
);
/**
/**
...
@@ -353,7 +355,8 @@ bool PGM_BASE::initPgm()
...
@@ -353,7 +355,8 @@ bool PGM_BASE::initPgm()
wxInitAllImageHandlers
();
wxInitAllImageHandlers
();
m_pgm_checker
=
new
wxSingleInstanceChecker
(
pgm_name
.
GetName
().
Lower
()
+
wxT
(
"-"
)
+
wxGetUserId
(),
GetKicadLockFilePath
()
);
m_pgm_checker
=
new
wxSingleInstanceChecker
(
pgm_name
.
GetName
().
Lower
()
+
wxT
(
"-"
)
+
wxGetUserId
(),
GetKicadLockFilePath
()
);
if
(
m_pgm_checker
->
IsAnotherRunning
()
)
if
(
m_pgm_checker
->
IsAnotherRunning
()
)
{
{
...
@@ -361,6 +364,7 @@ bool PGM_BASE::initPgm()
...
@@ -361,6 +364,7 @@ bool PGM_BASE::initPgm()
_
(
"%s is already running, Continue?"
),
_
(
"%s is already running, Continue?"
),
GetChars
(
pgm_name
.
GetName
()
)
GetChars
(
pgm_name
.
GetName
()
)
);
);
if
(
!
IsOK
(
NULL
,
quiz
)
)
if
(
!
IsOK
(
NULL
,
quiz
)
)
return
false
;
return
false
;
}
}
...
@@ -399,6 +403,17 @@ bool PGM_BASE::initPgm()
...
@@ -399,6 +403,17 @@ bool PGM_BASE::initPgm()
SetLanguagePath
();
SetLanguagePath
();
// Useful local environment variable settings.
m_local_env_vars
[
wxString
(
wxT
(
"KIGITHUB"
)
)
]
=
wxString
(
wxT
(
"https://github.com/KiCad"
)
);
wxFileName
tmpFileName
;
tmpFileName
.
AssignDir
(
wxString
(
wxT
(
KICAD_DATA_PATH
)
)
);
tmpFileName
.
AppendDir
(
wxT
(
"modules"
)
);
m_local_env_vars
[
wxString
(
wxT
(
"KISYSMOD"
)
)
]
=
tmpFileName
.
GetPath
();
tmpFileName
.
AppendDir
(
wxT
(
"packages3d"
)
);
m_local_env_vars
[
wxString
(
wxT
(
"KISYS3DMOD"
)
)
]
=
tmpFileName
.
GetPath
();
// OS specific instantiation of wxConfigBase derivative:
// OS specific instantiation of wxConfigBase derivative:
m_common_settings
=
GetNewConfig
(
KICAD_COMMON
);
m_common_settings
=
GetNewConfig
(
KICAD_COMMON
);
...
@@ -425,6 +440,7 @@ bool PGM_BASE::setExecutablePath()
...
@@ -425,6 +440,7 @@ bool PGM_BASE::setExecutablePath()
// bundle directory, e.g., /Applications/kicad.app/
// bundle directory, e.g., /Applications/kicad.app/
wxFileName
fn
(
m_bin_dir
);
wxFileName
fn
(
m_bin_dir
);
if
(
fn
.
GetName
()
==
wxT
(
"kicad"
)
)
if
(
fn
.
GetName
()
==
wxT
(
"kicad"
)
)
{
{
// kicad launcher, so just remove the Contents/MacOS part
// kicad launcher, so just remove the Contents/MacOS part
...
@@ -440,6 +456,7 @@ bool PGM_BASE::setExecutablePath()
...
@@ -440,6 +456,7 @@ bool PGM_BASE::setExecutablePath()
fn
.
RemoveLastDir
();
fn
.
RemoveLastDir
();
fn
.
RemoveLastDir
();
fn
.
RemoveLastDir
();
}
}
m_bin_dir
=
fn
.
GetPath
()
+
wxT
(
"/"
);
m_bin_dir
=
fn
.
GetPath
()
+
wxT
(
"/"
);
#else
#else
// Use unix notation for paths. I am not sure this is a good idea,
// Use unix notation for paths. I am not sure this is a good idea,
...
@@ -479,6 +496,33 @@ void PGM_BASE::loadCommonSettings()
...
@@ -479,6 +496,33 @@ void PGM_BASE::loadCommonSettings()
}
}
m_editor_name
=
m_common_settings
->
Read
(
wxT
(
"Editor"
)
);
m_editor_name
=
m_common_settings
->
Read
(
wxT
(
"Editor"
)
);
wxString
entry
,
oldPath
;
wxArrayString
entries
;
long
index
=
0L
;
oldPath
=
m_common_settings
->
GetPath
();
m_common_settings
->
SetPath
(
pathEnvVariables
);
while
(
m_common_settings
->
GetNextEntry
(
entry
,
index
)
)
{
wxLogTrace
(
traceEnvVars
,
wxT
(
"Enumerating over entry %s, %ld."
),
GetChars
(
entry
),
index
);
entries
.
Add
(
entry
);
}
for
(
unsigned
i
=
0
;
i
<
entries
.
GetCount
();
i
++
)
{
wxString
val
=
m_common_settings
->
Read
(
entries
[
i
],
wxEmptyString
);
m_local_env_vars
[
entries
[
i
]
]
=
val
;
}
for
(
std
::
map
<
wxString
,
wxString
>::
iterator
it
=
m_local_env_vars
.
begin
();
it
!=
m_local_env_vars
.
end
();
++
it
)
SetLocalEnvVariable
(
it
->
first
,
it
->
second
);
m_common_settings
->
SetPath
(
oldPath
);
}
}
...
@@ -491,6 +535,20 @@ void PGM_BASE::saveCommonSettings()
...
@@ -491,6 +535,20 @@ void PGM_BASE::saveCommonSettings()
wxString
cur_dir
=
wxGetCwd
();
wxString
cur_dir
=
wxGetCwd
();
m_common_settings
->
Write
(
workingDirKey
,
cur_dir
);
m_common_settings
->
Write
(
workingDirKey
,
cur_dir
);
// Save the local environment variables.
m_common_settings
->
SetPath
(
pathEnvVariables
);
for
(
std
::
map
<
wxString
,
wxString
>::
iterator
it
=
m_local_env_vars
.
begin
();
it
!=
m_local_env_vars
.
end
();
++
it
)
{
wxLogTrace
(
traceEnvVars
,
wxT
(
"Saving environment varaiable config entry %s as %s"
),
GetChars
(
it
->
first
),
GetChars
(
it
->
second
)
);
m_common_settings
->
Write
(
it
->
first
,
it
->
second
);
}
m_common_settings
->
SetPath
(
wxT
(
".."
)
);
}
}
}
}
...
@@ -665,3 +723,21 @@ void PGM_BASE::AddMenuLanguageList( wxMenu* MasterMenu )
...
@@ -665,3 +723,21 @@ void PGM_BASE::AddMenuLanguageList( wxMenu* MasterMenu )
}
}
}
}
bool
PGM_BASE
::
SetLocalEnvVariable
(
const
wxString
&
aName
,
const
wxString
&
aValue
)
{
wxString
env
;
// Check to see if the environment variable is already set.
if
(
wxGetEnv
(
aName
,
&
env
)
)
{
wxLogTrace
(
traceEnvVars
,
wxT
(
"Environment variable %s already set to %s."
),
GetChars
(
aName
),
GetChars
(
env
)
);
return
env
==
aValue
;
}
wxLogTrace
(
traceEnvVars
,
wxT
(
"Setting local environment variable %s to %s."
),
GetChars
(
aName
),
GetChars
(
aValue
)
);
return
wxSetEnv
(
aName
,
aValue
);
}
include/pgm_base.h
View file @
bd199b89
/*
/*
* This program source code file is part of KiCad, a free EDA CAD application.
* This program source code file is part of KiCad, a free EDA CAD application.
*
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004
-2015
Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-201
1
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2008-201
5
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-201
1
KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-201
5
KiCad Developers, see AUTHORS.txt for contributors.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* modify it under the terms of the GNU General Public License
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#ifndef PGM_BASE_H_
#ifndef PGM_BASE_H_
#define PGM_BASE_H_
#define PGM_BASE_H_
#include <map>
#include <wx/filename.h>
#include <wx/filename.h>
#include <search_stack.h>
#include <search_stack.h>
#include <wx/gdicmn.h>
#include <wx/gdicmn.h>
...
@@ -109,7 +110,7 @@ public:
...
@@ -109,7 +110,7 @@ public:
/**
/**
* Function UseSystemPdfBrowser
* Function UseSystemPdfBrowser
* returns true if the PDF browser is the default (system) PDF browser
* returns true if the PDF browser is the default (system) PDF browser
* and false if the PDF browser is the prefered (selected) browser, else
* and false if the PDF browser is the prefer
r
ed (selected) browser, else
* returns false if there is no selected browser
* returns false if there is no selected browser
*/
*/
VTBL_ENTRY
bool
UseSystemPdfBrowser
()
const
VTBL_ENTRY
bool
UseSystemPdfBrowser
()
const
...
@@ -119,7 +120,7 @@ public:
...
@@ -119,7 +120,7 @@ public:
/**
/**
* Function ForceSystemPdfBrowser
* Function ForceSystemPdfBrowser
* forces the use of system PDF browser, even if a prefer
en
d PDF browser is set.
* forces the use of system PDF browser, even if a prefer
re
d PDF browser is set.
*/
*/
VTBL_ENTRY
void
ForceSystemPdfBrowser
(
bool
aFlg
)
{
m_use_system_pdf_browser
=
aFlg
;
}
VTBL_ENTRY
void
ForceSystemPdfBrowser
(
bool
aFlg
)
{
m_use_system_pdf_browser
=
aFlg
;
}
...
@@ -168,6 +169,22 @@ public:
...
@@ -168,6 +169,22 @@ public:
*/
*/
VTBL_ENTRY
void
WritePdfBrowserInfos
();
VTBL_ENTRY
void
WritePdfBrowserInfos
();
/**
* Function SetLocalEnvVariable
*
* Sets the environment variable \a aName to \a aValue.
*
* This function first checks to see if the environment variable \a aName is already
* defined. If it is not defined, then the environment variable \a aName is set to
* a value. Otherwise, the environment variable is left unchanged. This allows the user
* to override environment variables for testing purposes.
*
* @param aName is a wxString containing the environment variable name.
* @param aValue is a wxString containing the environment variable value.
* @return true if the environment variable \a Name was set to \a aValue.
*/
VTBL_ENTRY
bool
SetLocalEnvVariable
(
const
wxString
&
aName
,
const
wxString
&
aValue
);
/**
/**
* Function App
* Function App
* returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.
* returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.
...
@@ -247,6 +264,10 @@ protected:
...
@@ -247,6 +264,10 @@ protected:
wxString
m_editor_name
;
wxString
m_editor_name
;
wxSize
m_help_size
;
wxSize
m_help_size
;
/// Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
/// library table.
std
::
map
<
wxString
,
wxString
>
m_local_env_vars
;
wxApp
*
m_wx_app
;
wxApp
*
m_wx_app
;
// The PGM_* classes can have difficulties at termination if they
// The PGM_* classes can have difficulties at termination if they
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment