Nasal startup: allow more control over loading
Allow excluding scripts entirely based on the startup load properties.
This commit is contained in:
parent
0e079a7ebe
commit
4e6f9e6239
2 changed files with 15 additions and 4 deletions
|
@ -1152,7 +1152,12 @@ void FGNasalSys::init()
|
||||||
|
|
||||||
// Now load the various source files in the Nasal directory
|
// Now load the various source files in the Nasal directory
|
||||||
simgear::Dir nasalDir(SGPath(globals->get_fg_root(), "Nasal"));
|
simgear::Dir nasalDir(SGPath(globals->get_fg_root(), "Nasal"));
|
||||||
loadScriptDirectory(nasalDir, globals->get_props()->getNode("/sim/nasal-load-priority"));
|
|
||||||
|
// load core Nasal scripts. In GUI startup mode, we restrict to a limited
|
||||||
|
// set of modules deliberately
|
||||||
|
loadScriptDirectory(nasalDir,
|
||||||
|
globals->get_props()->getNode("/sim/nasal-load-priority"),
|
||||||
|
fgGetBool("/sim/gui/startup"));
|
||||||
|
|
||||||
// Add modules in Nasal subdirectories to property tree
|
// Add modules in Nasal subdirectories to property tree
|
||||||
simgear::PathList directories = nasalDir.children(simgear::Dir::TYPE_DIR+
|
simgear::PathList directories = nasalDir.children(simgear::Dir::TYPE_DIR+
|
||||||
|
@ -1298,7 +1303,8 @@ bool pathSortPredicate(const SGPath& p1, const SGPath& p2)
|
||||||
|
|
||||||
// Loads all scripts in given directory, with an optional partial ordering of
|
// Loads all scripts in given directory, with an optional partial ordering of
|
||||||
// files defined in loadorder.
|
// files defined in loadorder.
|
||||||
void FGNasalSys::loadScriptDirectory(simgear::Dir nasalDir, SGPropertyNode* loadorder)
|
void FGNasalSys::loadScriptDirectory(simgear::Dir nasalDir, SGPropertyNode* loadorder,
|
||||||
|
bool excludeUnspecifiedInLoadOrder)
|
||||||
{
|
{
|
||||||
simgear::PathList scripts = nasalDir.children(simgear::Dir::TYPE_FILE, ".nas");
|
simgear::PathList scripts = nasalDir.children(simgear::Dir::TYPE_FILE, ".nas");
|
||||||
|
|
||||||
|
@ -1319,6 +1325,10 @@ void FGNasalSys::loadScriptDirectory(simgear::Dir nasalDir, SGPropertyNode* load
|
||||||
std::for_each(files.begin(), files.end(), loadAndErase);
|
std::for_each(files.begin(), files.end(), loadAndErase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (excludeUnspecifiedInLoadOrder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Load any remaining scripts.
|
// Load any remaining scripts.
|
||||||
// Note: simgear::Dir already reports file entries in a deterministic order,
|
// Note: simgear::Dir already reports file entries in a deterministic order,
|
||||||
// so a fixed loading sequence is guaranteed (same for every user)
|
// so a fixed loading sequence is guaranteed (same for every user)
|
||||||
|
@ -1538,7 +1548,7 @@ bool FGNasalSys::createModule(const char* moduleName, const char* fileName,
|
||||||
|
|
||||||
void FGNasalSys::deleteModule(const char* moduleName)
|
void FGNasalSys::deleteModule(const char* moduleName)
|
||||||
{
|
{
|
||||||
if (!_inited) {
|
if (!_inited || naIsNil(_globals)) {
|
||||||
// can occur on shutdown due to us being shutdown first, but other
|
// can occur on shutdown due to us being shutdown first, but other
|
||||||
// subsystems having Nasal objects.
|
// subsystems having Nasal objects.
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -168,7 +168,8 @@ private:
|
||||||
|
|
||||||
void loadPropertyScripts();
|
void loadPropertyScripts();
|
||||||
void loadPropertyScripts(SGPropertyNode* n);
|
void loadPropertyScripts(SGPropertyNode* n);
|
||||||
void loadScriptDirectory(simgear::Dir nasalDir, SGPropertyNode* loadorder);
|
void loadScriptDirectory(simgear::Dir nasalDir, SGPropertyNode* loadorder,
|
||||||
|
bool excludeUnspecifiedInLoadOrder);
|
||||||
void addModule(std::string moduleName, simgear::PathList scripts);
|
void addModule(std::string moduleName, simgear::PathList scripts);
|
||||||
static void logError(naContext);
|
static void logError(naContext);
|
||||||
naRef parse(naContext ctx, const char* filename, const char* buf, int len,
|
naRef parse(naContext ctx, const char* filename, const char* buf, int len,
|
||||||
|
|
Loading…
Reference in a new issue