mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
support Configrc*
This commit is contained in:
parent
1bced6e324
commit
a42d5f1389
@ -1,2 +1,8 @@
|
|||||||
#define INSTALL_CONFIG \
|
#define INSTALL_CONFIG \
|
||||||
direct.init Configrc
|
Configrc.direct
|
||||||
|
|
||||||
|
#if $[CTPROJS]
|
||||||
|
// These files only matter to ctattach users.
|
||||||
|
#define INSTALL_CONFIG $[INSTALL_CONFIG] direct.init
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -105,12 +105,13 @@
|
|||||||
|
|
||||||
|
|
||||||
// The Configrc file is used by Panda for runtime configuration.
|
// The Configrc file is used by Panda for runtime configuration.
|
||||||
// Panda will look for it in the directory specified by the
|
// Panda will load up all files named Configrc* (with any and every
|
||||||
// CONFIGRC_DIR environment variable, or in the directory named here
|
// extension) in the directory specified by the CONFIGRC_DIR
|
||||||
// if that environment variable is undefined. By default, we specify
|
// environment variable, or in the directory named here if that
|
||||||
// a dot, to indicate the current directory; you may redefine this if
|
// environment variable is undefined. By default, we specify the
|
||||||
// you have someplace in particular you'd rather put it.
|
// install/etc dir, which is where the system-provided Configrc files
|
||||||
#define DEFAULT_CONFIGRC_DIR .
|
// get copied to.
|
||||||
|
#defer DEFAULT_CONFIGRC_DIR $[INSTALL_DIR]/etc
|
||||||
|
|
||||||
|
|
||||||
// What level of compiler optimization/debug symbols should we build?
|
// What level of compiler optimization/debug symbols should we build?
|
||||||
|
@ -24,6 +24,10 @@ INLINE void ConfigTable::ConfigDbgDefault() {
|
|||||||
dconfig_cat->set_severity(NS_info);
|
dconfig_cat->set_severity(NS_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE void ConfigTable::ConfigExeDefault() {
|
||||||
|
configexe = false;
|
||||||
|
}
|
||||||
|
|
||||||
INLINE void ConfigTable::ReadArgsDefault() {
|
INLINE void ConfigTable::ReadArgsDefault() {
|
||||||
readargs = true;
|
readargs = true;
|
||||||
}
|
}
|
||||||
@ -45,7 +49,7 @@ INLINE void ConfigTable::ConfigNameDefault() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
INLINE void ConfigTable::ConfigSuffixDefault() {
|
INLINE void ConfigTable::ConfigSuffixDefault() {
|
||||||
configsuffix = "";
|
configsuffix = "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void ConfigTable::ConfigArgsDefault() {
|
INLINE void ConfigTable::ConfigArgsDefault() {
|
||||||
@ -53,7 +57,7 @@ INLINE void ConfigTable::ConfigArgsDefault() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
INLINE void ConfigTable::ConfigPathDefault() {
|
INLINE void ConfigTable::ConfigPathDefault() {
|
||||||
configpath = "CFG_PATH";
|
configpath = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void ConfigTable::ConfigCmtDefault() {
|
INLINE void ConfigTable::ConfigCmtDefault() {
|
||||||
|
@ -137,6 +137,17 @@ void ConfigTable::ReadConfigFile() {
|
|||||||
// intuitive definition.
|
// intuitive definition.
|
||||||
|
|
||||||
DSearchPath config_search;
|
DSearchPath config_search;
|
||||||
|
|
||||||
|
// The configdir variable gets priority--it names a directory that
|
||||||
|
// ends up first on the search path.
|
||||||
|
if (!configdir.empty()) {
|
||||||
|
config_search.append_directory(Filename::from_os_specific(configdir));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then all of the directories named (indirectly) by configpath.
|
||||||
|
// This variable actually names a space-delimited list of
|
||||||
|
// environment variable names, each of which contains a space- or
|
||||||
|
// colon-delimited search path.
|
||||||
while (!configpath.empty()) {
|
while (!configpath.empty()) {
|
||||||
int i = configpath.find_first_of(" ");
|
int i = configpath.find_first_of(" ");
|
||||||
ConfigString stmp = configpath.substr(0, i);
|
ConfigString stmp = configpath.substr(0, i);
|
||||||
@ -160,50 +171,58 @@ void ConfigTable::ReadConfigFile() {
|
|||||||
CropString(configpath);
|
CropString(configpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the configpath is empty, use the configdir string instead. If
|
|
||||||
// the configdir string is empty, it gets its value from the
|
|
||||||
// CONFIGRC_DIR environment variable, or from the compiled-in
|
|
||||||
// default.
|
|
||||||
if (config_search.is_empty()) {
|
|
||||||
if (configdir.empty()) {
|
|
||||||
configdir = ExecutionEnvironment::get_environment_variable("CONFIGRC_DIR");
|
|
||||||
if (configdir.empty()) {
|
|
||||||
configdir = DEFAULT_CONFIGRC_DIR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config_search.append_directory(Filename::from_os_specific(configdir));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (microconfig_cat->is_spam()) {
|
if (microconfig_cat->is_spam()) {
|
||||||
microconfig_cat->spam()
|
microconfig_cat->spam()
|
||||||
<< "search path from configpath is: "
|
<< "search path from configdir and configpath is: "
|
||||||
<< config_search << endl;
|
<< config_search << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
DSearchPath::Results config_files;
|
DSearchPath::Results config_files;
|
||||||
|
|
||||||
if (!configsuffix.empty()) {
|
if (!configsuffix.empty()) {
|
||||||
if (microconfig_cat->is_spam())
|
if (configsuffix == "*") {
|
||||||
microconfig_cat->spam() << "agregate config name is: "
|
// A configsuffix of "*" is a special case: this means to find
|
||||||
<< (configname + configsuffix) << endl;
|
// all files that begin with configname. We don't do full
|
||||||
config_search.find_all_files(configname + configsuffix, config_files);
|
// globbing, though. We also make a special case for files
|
||||||
if (microconfig_cat->is_spam())
|
// ending in ~, which we always ignore (these are usually just
|
||||||
microconfig_cat->spam() << "found " << config_files.get_num_files()
|
// backup files).
|
||||||
<< " files" << endl;
|
if (microconfig_cat->is_spam())
|
||||||
|
microconfig_cat->spam() << "searching for files matching: "
|
||||||
|
<< (configname + configsuffix) << endl;
|
||||||
|
for (int di = 0; di < config_search.get_num_directories(); di++) {
|
||||||
|
const Filename &directory = config_search.get_directory(di);
|
||||||
|
vector_string files;
|
||||||
|
directory.scan_directory(files);
|
||||||
|
// Scan the files in reverse order to match Configrc overwrite
|
||||||
|
// rules, so that the alphabetically earliest file has
|
||||||
|
// precedence.
|
||||||
|
for (vector_string::reverse_iterator fi = files.rbegin();
|
||||||
|
fi != files.rend();
|
||||||
|
++fi) {
|
||||||
|
if ((*fi).substr(0, configname.length()) == configname &&
|
||||||
|
(*fi).substr((*fi).length() - 1) != string("~")) {
|
||||||
|
Filename file(directory, (*fi));
|
||||||
|
config_files.add_file(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (microconfig_cat->is_spam())
|
||||||
|
microconfig_cat->spam() << "aggregate config name is: "
|
||||||
|
<< (configname + configsuffix) << endl;
|
||||||
|
config_search.find_all_files(configname + configsuffix, config_files);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (microconfig_cat->is_spam())
|
if (microconfig_cat->is_spam())
|
||||||
microconfig_cat->spam() << "searching for '" << configname << "'"
|
microconfig_cat->spam() << "searching for '" << configname << "'"
|
||||||
<< endl;
|
<< endl;
|
||||||
config_search.find_all_files(configname, config_files);
|
config_search.find_all_files(configname, config_files);
|
||||||
if (microconfig_cat->is_spam())
|
|
||||||
microconfig_cat->spam() << "found " << config_files.get_num_files()
|
|
||||||
<< " files" << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (microconfig_cat->is_spam())
|
if (microconfig_cat->is_spam())
|
||||||
microconfig_cat->spam() << "configpath parsed and searched"
|
microconfig_cat->spam() << "found " << config_files.get_num_files()
|
||||||
<< endl;
|
<< " files" << endl;
|
||||||
|
|
||||||
int num_config_files = config_files.get_num_files();
|
int num_config_files = config_files.get_num_files();
|
||||||
for (int i = num_config_files - 1; i >= 0; i--) {
|
for (int i = num_config_files - 1; i >= 0; i--) {
|
||||||
@ -219,7 +238,7 @@ void ConfigTable::ReadConfigFile() {
|
|||||||
<< "file is not a regular file, ignoring.\n";
|
<< "file is not a regular file, ignoring.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (config_file.is_executable()) {
|
} else if (configexe && config_file.is_executable()) {
|
||||||
ConfigString line = config_file.to_os_specific() + " " + configargs;
|
ConfigString line = config_file.to_os_specific() + " " + configargs;
|
||||||
if (microconfig_cat->is_spam())
|
if (microconfig_cat->is_spam())
|
||||||
microconfig_cat->spam() << "file is executable, running '"
|
microconfig_cat->spam() << "file is executable, running '"
|
||||||
@ -353,6 +372,15 @@ void ConfigTable::ParseArgs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigTable::ConfigDirDefault() {
|
||||||
|
// The configdir default comes from $CONFIGRC_DIR, or from the
|
||||||
|
// compiled in DEFAULT_CONFIGRC_DIR if that's unspecified.
|
||||||
|
configdir = ExecutionEnvironment::get_environment_variable("CONFIGRC_DIR");
|
||||||
|
if (configdir.empty()) {
|
||||||
|
configdir = DEFAULT_CONFIGRC_DIR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigTable::MicroConfig() {
|
void ConfigTable::MicroConfig() {
|
||||||
/*
|
/*
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -376,6 +404,7 @@ void ConfigTable::MicroConfig() {
|
|||||||
microconfig_cat->spam() << "CONFIG_CONFIG = '" << cc << "'" << endl;
|
microconfig_cat->spam() << "CONFIG_CONFIG = '" << cc << "'" << endl;
|
||||||
}
|
}
|
||||||
bool cdbg = false;
|
bool cdbg = false;
|
||||||
|
bool cexe = false;
|
||||||
bool psep = false;
|
bool psep = false;
|
||||||
bool fsep = false;
|
bool fsep = false;
|
||||||
bool cname = false;
|
bool cname = false;
|
||||||
@ -537,6 +566,21 @@ void ConfigTable::MicroConfig() {
|
|||||||
<< "got a microconfig configdbg directive, "
|
<< "got a microconfig configdbg directive, "
|
||||||
<< "setting the config spam state to " << configdbg
|
<< "setting the config spam state to " << configdbg
|
||||||
<< endl;
|
<< endl;
|
||||||
|
} else if (tok == "configexe") {
|
||||||
|
configexe = TrueOrFalse(rest);
|
||||||
|
cexe = true;
|
||||||
|
if (configexe) {
|
||||||
|
microconfig_cat->set_severity(NS_spam);
|
||||||
|
dconfig_cat->set_severity(NS_spam);
|
||||||
|
} else {
|
||||||
|
microconfig_cat->set_severity(NS_info);
|
||||||
|
dconfig_cat->set_severity(NS_info);
|
||||||
|
}
|
||||||
|
if (microconfig_cat->is_spam())
|
||||||
|
microconfig_cat->spam()
|
||||||
|
<< "got a microconfig configexe directive, "
|
||||||
|
<< "setting the config spam state to " << configexe
|
||||||
|
<< endl;
|
||||||
} else if (tok == "readargs") {
|
} else if (tok == "readargs") {
|
||||||
readargs = TrueOrFalse(rest);
|
readargs = TrueOrFalse(rest);
|
||||||
rdarg = true;
|
rdarg = true;
|
||||||
@ -565,6 +609,8 @@ void ConfigTable::MicroConfig() {
|
|||||||
microconfig_cat->spam() << "CONFIG_CONFIG is empty" << endl;
|
microconfig_cat->spam() << "CONFIG_CONFIG is empty" << endl;
|
||||||
if (!cdbg)
|
if (!cdbg)
|
||||||
ConfigDbgDefault();
|
ConfigDbgDefault();
|
||||||
|
if (!cexe)
|
||||||
|
ConfigExeDefault();
|
||||||
if (!psep) {
|
if (!psep) {
|
||||||
PathSepDefault();
|
PathSepDefault();
|
||||||
if (microconfig_cat->is_spam())
|
if (microconfig_cat->is_spam())
|
||||||
@ -608,9 +654,10 @@ void ConfigTable::MicroConfig() {
|
|||||||
<< "'" << endl;
|
<< "'" << endl;
|
||||||
}
|
}
|
||||||
if (!cdir) {
|
if (!cdir) {
|
||||||
|
ConfigDirDefault();
|
||||||
if (microconfig_cat->is_spam())
|
if (microconfig_cat->is_spam())
|
||||||
microconfig_cat->spam() << "no microconfig for configdir, "
|
microconfig_cat->spam() << "no microconfig for configdir, "
|
||||||
<< "leaving empty: '" << configdir
|
<< "setting to default '" << configdir
|
||||||
<< "'" << endl;
|
<< "'" << endl;
|
||||||
}
|
}
|
||||||
if (!ccmt) {
|
if (!ccmt) {
|
||||||
|
@ -44,6 +44,7 @@ private:
|
|||||||
SymbolTable unqualified;
|
SymbolTable unqualified;
|
||||||
TableMap qualified;
|
TableMap qualified;
|
||||||
bool _initializing;
|
bool _initializing;
|
||||||
|
bool configexe;
|
||||||
bool configdbg;
|
bool configdbg;
|
||||||
bool readargs;
|
bool readargs;
|
||||||
bool readenvs;
|
bool readenvs;
|
||||||
@ -69,6 +70,7 @@ private:
|
|||||||
void ParseCommandEnv(ConfigString&, const ConfigString&);
|
void ParseCommandEnv(ConfigString&, const ConfigString&);
|
||||||
void ParseArgs();
|
void ParseArgs();
|
||||||
INLINE void ConfigDbgDefault();
|
INLINE void ConfigDbgDefault();
|
||||||
|
INLINE void ConfigExeDefault();
|
||||||
INLINE void ReadArgsDefault();
|
INLINE void ReadArgsDefault();
|
||||||
INLINE void ReadEnvsDefault();
|
INLINE void ReadEnvsDefault();
|
||||||
INLINE void PathSepDefault();
|
INLINE void PathSepDefault();
|
||||||
@ -77,6 +79,7 @@ private:
|
|||||||
INLINE void ConfigSuffixDefault();
|
INLINE void ConfigSuffixDefault();
|
||||||
INLINE void ConfigArgsDefault();
|
INLINE void ConfigArgsDefault();
|
||||||
INLINE void ConfigPathDefault();
|
INLINE void ConfigPathDefault();
|
||||||
|
void ConfigDirDefault();
|
||||||
INLINE void ConfigCmtDefault();
|
INLINE void ConfigCmtDefault();
|
||||||
INLINE void ArgSuffixDefault();
|
INLINE void ArgSuffixDefault();
|
||||||
INLINE void CommandStubDefault();
|
INLINE void CommandStubDefault();
|
||||||
|
@ -1,2 +1,10 @@
|
|||||||
|
|
||||||
#define INSTALL_CONFIG \
|
#define INSTALL_CONFIG \
|
||||||
panda.emacs panda.emacs.Xdefaults panda.init Configrc
|
panda.emacs panda.emacs.Xdefaults Configrc.panda
|
||||||
|
|
||||||
|
|
||||||
|
#if $[CTPROJS]
|
||||||
|
// These files only matter to ctattach users.
|
||||||
|
#define INSTALL_CONFIG $[INSTALL_CONFIG] panda.init
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
lib
|
|
Loading…
x
Reference in New Issue
Block a user