30#include <wx/filename.h>
34 JOB(
"special_execute", false ),
47 return wxString(
"Execute command" );
54 const wxChar* names[] = { wxS(
"python.exe" ) };
57 const wxChar* names[] = { wxS(
"python3" ), wxS(
"python" ) };
60 for(
const wxString& dir : aToolDirs )
62 for(
const wxChar*
name : names )
64 wxFileName candidate( dir,
name );
66 if( candidate.FileExists() )
67 return candidate.GetFullPath();
79 wxDir::GetAllFiles( aDir, &files, wxS(
"*." ) + aExt, wxDIR_FILES );
81 return files.size() == 1 ? files[0] : wxString();
91 if( !board.FileExists() )
99 return board.GetFullPath();
110 wxFileName
top( sheet.filename );
111 top.MakeAbsolute( dir );
113 if(
top.FileExists() )
114 return top.GetFullPath();
119 if( !schematic.FileExists() )
123 if( !only.IsEmpty() )
127 return schematic.GetFullPath();
133 std::map<wxString, wxString> vars;
137 if( python.IsEmpty() )
140 python = wxS(
"python" );
142 python = wxS(
"python3" );
176 wxString existing =
name;
181 for(
const wxString& form : { wxS(
"${" ) +
name + wxS(
"}" ), wxS(
"$(" ) +
name + wxS(
")" ) } )
185 while( ( pos = command.find( form, pos ) ) != wxString::npos )
187 if( pos > 0 && command[pos - 1] == wxS(
'\\' ) )
189 pos += form.length();
193 command.replace( pos, form.length(), value );
194 pos += value.length();
wxString GetDefaultDescription() const override
std::vector< JOB_PARAM_BASE * > m_params
JOB(const std::string &aType, bool aOutputIsDirectory)
static std::vector< wxString > GetToolDirectories(const wxString &aExecutableDir)
Return the directories holding tools shipped alongside KiCad, most specific first.
static wxString GetExecutableDir()
Return the directory holding the running executable itself.
std::vector< TOP_LEVEL_SHEET_INFO > & GetTopLevelSheets()
Container for project specific data.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
virtual bool TextVarResolver(wxString *aToken) const
virtual PROJECT_FILE & GetProjectFile() const
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject, bool aAllowEscapes)
Replace any environment variable & text variable references with their values.
static const std::string KiCadSchematicFileExtension
static const std::string KiCadPcbFileExtension
Some functions to handle hotkeys in KiCad.
#define REGISTER_JOB(job_name, title, face, T)
std::map< wxString, wxString > GetExecuteBuiltinVariableHelp()
Describe each variable returned by GetExecuteBuiltinVariables() for the user.
static wxString projectSchematic(const PROJECT &aProject)
wxString ExpandExecuteCommand(const wxString &aCommand, const PROJECT *aProject)
Expand an Execute Command string, including the built-in variables.
wxString FindBundledPython(const std::vector< wxString > &aToolDirs)
Find the interpreter shipped with KiCad in the given tool directories.
static wxString projectBoard(const PROJECT &aProject)
std::map< wxString, wxString > GetExecuteBuiltinVariables(const PROJECT *aProject)
Return the variables an Execute Command job can use beyond the environment and project variables.
static wxString onlyFileWithExt(const wxString &aDir, const wxString &aExt)
#define EXEC_PROJECT_PCB_VAR_NAME
#define EXEC_PROJECT_SCH_VAR_NAME
#define EXEC_PYTHON_VAR_NAME
Information about a top-level schematic sheet.
KIBIS top(path, &reporter)
Definition of file extensions used in Kicad.