aboutsummaryrefslogtreecommitdiff
path: root/odb/odb.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-02-18 15:54:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-02-18 15:54:04 +0200
commit3cc7d6569990cfb4fae913e1ea0e56c1e80c2246 (patch)
tree8497cdc478a6585ce8997adda141188f7a71e1b9 /odb/odb.cxx
parenta9a87afc39f815024b1908473a3ed33a82ddd25e (diff)
Add support for default options file
Now, if configured, the ODB compiler will load the default options file (../etc/odb/default.options by default). This file can be used for installation-wide customization, such as adding extra include search paths.
Diffstat (limited to 'odb/odb.cxx')
-rw-r--r--odb/odb.cxx53
1 files changed, 53 insertions, 0 deletions
diff --git a/odb/odb.cxx b/odb/odb.cxx
index 196329b..707173e 100644
--- a/odb/odb.cxx
+++ b/odb/odb.cxx
@@ -213,6 +213,54 @@ main (int argc, char* argv[])
args.push_back ("g++");
#endif // GXX_NAME
+ // Parse the default options file if we have one.
+ //
+ strings def_inc_dirs;
+#ifdef DEFAULT_OPTIONS_FILE
+ {
+ path file (DEFAULT_OPTIONS_FILE);
+
+ // If the path is relative, then use the driver's path as a base.
+ //
+ if (file.relative ())
+ {
+ path dp (driver_path (path (argv[0])));
+ file = dp.directory () / file;
+ }
+
+ int ac (3);
+ const char* av[4] = {argv[0], "--file", file.string ().c_str (), 0};
+ cli::argv_file_scanner s (ac, const_cast<char**> (av), "--file");
+
+ while (s.more ())
+ {
+ string a (s.next ());
+ size_t n (a.size ());
+
+ // -I
+ //
+ if (n > 1 && a[0] == '-' && a[1] == 'I')
+ {
+ def_inc_dirs.push_back (a);
+
+ if (n == 2) // -I /path
+ {
+ if (!s.more () || (a = s.next ()).empty ())
+ {
+ e << file << ": error: expected argument for the -I option"
+ << endl;
+ return 1;
+ }
+
+ def_inc_dirs.push_back (a);
+ }
+ }
+ else
+ plugin_args.push_back (a);
+ }
+ }
+#endif
+
// Default options.
//
args.push_back ("-x");
@@ -326,6 +374,11 @@ main (int argc, char* argv[])
plugin_args.push_back (a);
}
+ // Add the default include directories (-I) after the user-supplied
+ // ones.
+ //
+ args.insert (args.end (), def_inc_dirs.begin (), def_inc_dirs.end ());
+
// Obtain profile (-I) search paths.
//
paths prof_paths (profile_paths (args, argv[0]));