use CONFIGRC_DIR and DEFAULT_CONFIGRC_DIR

This commit is contained in:
David Rose 2004-06-04 06:44:04 +00:00
parent 988a2e060c
commit a11c7a4828
4 changed files with 55 additions and 5 deletions

View File

@ -98,6 +98,15 @@
// #define INSTALL_LIB_DIR /usr/lib/python2.2/site-packages
// The Configrc file is used by Panda for runtime configuration.
// Panda will look for it in the directory specified by the
// CONFIGRC_DIR environment variable, or in the directory named here
// if that environment variable is undefined. By default, we specify
// a dot, to indicate the current directory; you may redefine this if
// you have someplace in particular you'd rather put it.
#define DEFAULT_CONFIGRC_DIR .
// What level of compiler optimization/debug symbols should we build?
// The various optimize levels are defined as follows:
//

View File

@ -183,6 +183,14 @@ $[cdefine LINK_IN_GL]
/* Define if we are linking PANDAPHYSICS in with PANDA. */
$[cdefine LINK_IN_PHYSICS]
/* The compiled-in default directory to look for the Configrc file, in
the absence of the CONFIGRC_DIR environment variable set, and in
the absence of anything specified via the configpath directive. */
# define DEFAULT_CONFIGRC_DIR "$[DEFAULT_CONFIGRC_DIR]"
/* Define if your processor stores words with the most significant
byte first (like Motorola and SPARC, unlike Intel and VAX). */
$[cdefine WORDS_BIGENDIAN]

View File

@ -141,17 +141,33 @@ void ConfigTable::ReadConfigFile() {
int i = configpath.find_first_of(" ");
ConfigString stmp = configpath.substr(0, i);
if (ExecutionEnvironment::has_environment_variable(stmp)) {
Filename next_path = Filename::from_os_specific(ExecutionEnvironment::get_environment_variable(stmp));
config_search.append_path(next_path);
string next_path = ExecutionEnvironment::get_environment_variable(stmp);
while (!next_path.empty()) {
int j = next_path.find_first_of(" ");
Filename dir = Filename::from_os_specific(next_path.substr(0, j));
config_search.append_directory(dir);
next_path.erase(0, j);
CropString(next_path);
}
}
configpath.erase(0, i);
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 we still have no directories on the search path, then at
// least search the current directory.
config_search.append_directory(".");
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()) {
@ -361,6 +377,7 @@ void ConfigTable::MicroConfig() {
bool csuff = false;
bool cargs = false;
bool cpath = false;
bool cdir = false;
bool ccmt = false;
bool asuff = false;
bool cstub = false;
@ -467,6 +484,14 @@ void ConfigTable::MicroConfig() {
<< endl;
}
cpath = true;
} else if (tok == "configdir") {
configdir = rest;
if (microconfig_cat->is_spam())
microconfig_cat->spam()
<< "got a microconfig configdir directive, "
<< "setting the configdir to '" << configdir << "'"
<< endl;
cdir = true;
} else if (tok == "configcmt") {
configcmt = rest;
ccmt = true;
@ -576,6 +601,13 @@ void ConfigTable::MicroConfig() {
<< "setting to default '" << configpath
<< "'" << endl;
}
if (!cdir) {
ConfigPathDefault();
if (microconfig_cat->is_spam())
microconfig_cat->spam() << "no microconfig for configdir, "
<< "setting to default '" << configdir
<< "'" << endl;
}
if (!ccmt) {
ConfigCmtDefault();
if (microconfig_cat->is_spam())

View File

@ -53,6 +53,7 @@ private:
ConfigString configsuffix;
ConfigString configargs;
ConfigString configpath;
ConfigString configdir;
ConfigString configcmt;
ConfigString argsuffix;
ConfigString commandstub;