diff options
Diffstat (limited to 'src/driver')
-rw-r--r-- | src/driver/main.c | 11 | ||||
-rw-r--r-- | src/driver/utils.c | 26 | ||||
-rw-r--r-- | src/driver/utils.h | 3 |
3 files changed, 35 insertions, 5 deletions
diff --git a/src/driver/main.c b/src/driver/main.c index 3dd06ebe..1436d42c 100644 --- a/src/driver/main.c +++ b/src/driver/main.c @@ -79,13 +79,16 @@ namespace OpenAxiom { } static void - upgrade_environment(const char* sysdir) { + upgrade_environment(const Command* command) { + const char* sysdir = command->root_dir; augment_variable("TEXINPUTS", oa_concatenate_string(sysdir, OPENAXIOM_TEXINPUTS_PATH)); augment_variable("BIBINPUTS", oa_concatenate_string(sysdir, OPENAXIOM_BIBINPUTS_PATH)); - augment_variable("LD_LIBRARY_PATH", - oa_concatenate_string(sysdir, "/lib")); + const char* ldd_path = option_value(command, "--syslib"); + if (ldd_path == 0) + ldd_path = oa_concatenate_string(sysdir, "/lib"); + augment_variable("LD_LIBRARY_PATH", ldd_path); publish_systemdir(sysdir); } @@ -115,7 +118,7 @@ main(int argc, char* argv[]) using namespace OpenAxiom; Command command; Driver driver = preprocess_arguments(&command, argc, argv); - upgrade_environment(command.root_dir); + upgrade_environment(&command); switch (driver) { case null_driver: diff --git a/src/driver/utils.c b/src/driver/utils.c index 42b0183d..89e1ad4c 100644 --- a/src/driver/utils.c +++ b/src/driver/utils.c @@ -86,6 +86,14 @@ namespace OpenAxiom { exec_path() { } + static const char* + get_suffix(const char* first, const char* last, const char* seq) { + for (; first < last; ++first, ++seq) + if (*first != *seq) + return 0; + return seq; + } + // -- Return non-null if `lhs' is a prefix of `rhs'. When non-null // -- the pointer points to the '=' character that starts of the // -- value supplied to the argument. @@ -97,6 +105,21 @@ namespace OpenAxiom { return rhs + N - 1; } + const char* + option_value(const Command* command, const char* opt) { + const int n = strlen(opt); + for (int i = 1; i < command->core.argc; ++i) { + const char* arg = command->core.argv[i]; + if (strlen(arg) < n) + continue; + if(const char* val = get_suffix(opt, opt + n, arg)) { + if (*val++ == '=') + return val; + break; + } + } + return 0; + } /* Return a path to the running system, either as specified on command line through --system=, or as specified at configuration time. */ @@ -311,7 +334,8 @@ preprocess_arguments(Command* command, int argc, char** argv) if (strcmp(argv[i], "--script") == 0) driver = script_driver; else if(strcmp(argv[i], "--compile") == 0 - or strcmp(argv[i], "--translate") == 0) + or strcmp(argv[i], "--translate") == 0 + or strcmp(argv[i], "--build-databases") == 0) driver = compiler_driver; else if (strcmp(argv[i], "--make") == 0) driver = linker_driver; diff --git a/src/driver/utils.h b/src/driver/utils.h index 10f47f79..6c55f1c0 100644 --- a/src/driver/utils.h +++ b/src/driver/utils.h @@ -93,6 +93,9 @@ namespace OpenAxiom { const char* get_systemdir(int argc, char*[]); const char* make_path_for(const char*, Driver); + // Return a pointer the string value associated with an option. + const char* option_value(const Command*, const char*); + int execute_core(const Command*, Driver); void build_rts_options(Command*, Driver); |