diff options
-rw-r--r-- | build2/cc/compile.cxx | 37 | ||||
-rw-r--r-- | build2/cc/link.cxx | 13 | ||||
-rw-r--r-- | build2/cc/module.cxx | 32 | ||||
-rw-r--r-- | build2/utility.hxx | 17 | ||||
-rw-r--r-- | build2/utility.txx | 27 |
5 files changed, 89 insertions, 37 deletions
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index f3aaba5..1317fcb 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -761,9 +761,10 @@ namespace build2 // Extra system header dirs (last). // assert (sys_inc_dirs_extra <= sys_inc_dirs.size ()); - for (auto i (sys_inc_dirs.begin () + sys_inc_dirs_extra); - i != sys_inc_dirs.end (); ++i) - cs.append (i->string ()); + hash_option_values ( + cs, "-I", + sys_inc_dirs.begin () + sys_inc_dirs_extra, sys_inc_dirs.end (), + [] (const dir_path& d) {return d.string ();}); } hash_options (cs, t, c_coptions); @@ -1760,12 +1761,10 @@ namespace build2 // Extra system header dirs (last). // assert (sys_inc_dirs_extra <= sys_inc_dirs.size ()); - for (auto i (sys_inc_dirs.begin () + sys_inc_dirs_extra); - i != sys_inc_dirs.end (); ++i) - { - args.push_back ("-I"); - args.push_back (i->string ().c_str ()); - } + append_option_values ( + args, "-I", + sys_inc_dirs.begin () + sys_inc_dirs_extra, sys_inc_dirs.end (), + [] (const dir_path& d) {return d.string ().c_str ();}); if (md.symexport) append_symexport_options (args, t); @@ -2751,12 +2750,10 @@ namespace build2 append_options (args, t, x_poptions); assert (sys_inc_dirs_extra <= sys_inc_dirs.size ()); - for (auto i (sys_inc_dirs.begin () + sys_inc_dirs_extra); - i != sys_inc_dirs.end (); ++i) - { - args.push_back ("-I"); - args.push_back (i->string ().c_str ()); - } + append_option_values ( + args, "-I", + sys_inc_dirs.begin () + sys_inc_dirs_extra, sys_inc_dirs.end (), + [] (const dir_path& d) {return d.string ().c_str ();}); if (md.symexport) append_symexport_options (args, t); @@ -4042,12 +4039,10 @@ namespace build2 // Extra system header dirs (last). // assert (sys_inc_dirs_extra <= sys_inc_dirs.size ()); - for (auto i (sys_inc_dirs.begin () + sys_inc_dirs_extra); - i != sys_inc_dirs.end (); ++i) - { - args.push_back ("-I"); - args.push_back (i->string ().c_str ()); - } + append_option_values ( + args, "-I", + sys_inc_dirs.begin () + sys_inc_dirs_extra, sys_inc_dirs.end (), + [] (const dir_path& d) {return d.string ().c_str ();}); if (md.symexport) append_symexport_options (args, t); diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx index 4f1eea5..2b70fe9 100644 --- a/build2/cc/link.cxx +++ b/build2/cc/link.cxx @@ -1421,6 +1421,17 @@ namespace build2 append_options (args, t, c_loptions); append_options (args, t, x_loptions); + // Extra system library dirs (last). + // + // @@ /LIBPATH:<path>, not /LIBPATH <path> + // + assert (sys_lib_dirs_extra <= sys_lib_dirs.size ()); + append_option_values ( + args, + cid == compiler_id::msvc ? "/LIBPATH:" : "-L", + sys_lib_dirs.begin () + sys_lib_dirs_extra, sys_lib_dirs.end (), + [] (const dir_path& d) {return d.string ().c_str ();}); + // Handle soname/rpath. // if (tclass == "windows") @@ -1562,7 +1573,7 @@ namespace build2 if (!manifest.empty ()) cs.append (manifest.string ()); - // Treat them as inputs, not options. + // Treat .libs as inputs, not options. // if (!lt.static_library ()) { diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index 9971b56..badd0ef 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -231,42 +231,44 @@ namespace build2 const string& ct (tt.string ()); // Canonical target. dr << " signature " << ci.signature << '\n' + << " checksum " << ci.checksum << '\n' << " target " << ct; if (ct != ci.target) dr << " (" << ci.target << ")"; - - dr << '\n'; } if (!tstd.empty ()) { - dr << " std "; // One less space. + dr << "\n std "; // One less space. for (const string& o: tstd) dr << ' ' << o; - dr << '\n'; } if (!ci.cc_pattern.empty ()) // bin_pattern printed by bin { - dr << " pattern " << ci.cc_pattern << '\n'; + dr << "\n pattern " << ci.cc_pattern; } if (verb >= 3 && !inc_dirs.empty ()) { - dr << " inc dirs\n"; - for (const dir_path& d: inc_dirs) - dr << " " << d << '\n'; + dr << "\n inc dirs"; + for (size_t i (0); i != inc_dirs.size (); ++i) + { + if (i == sys_inc_dirs_extra) + dr << "\n --"; + dr << "\n " << inc_dirs[i]; + } } if (verb >= 3 && !lib_dirs.empty ()) { - dr << " lib dirs\n"; - for (const dir_path& d: lib_dirs) - dr << " " << d << '\n'; - } - - { - dr << " checksum " << ci.checksum; + dr << "\n lib dirs"; + for (size_t i (0); i != lib_dirs.size (); ++i) + { + if (i == sys_lib_dirs_extra) + dr << "\n --"; + dr << "\n " << lib_dirs[i]; + } } } diff --git a/build2/utility.hxx b/build2/utility.hxx index 2fa7e6e..af26acd 100644 --- a/build2/utility.hxx +++ b/build2/utility.hxx @@ -355,6 +355,23 @@ namespace build2 void hash_options (sha256&, const strings&, size_t); + // As above but append/hash option values for the specified option (e.g., + // -I, -L). + // + template <typename I, typename F> + void + append_option_values (cstrings&, + const char* opt, + I begin, I end, + F&& get = [] (const string& s) {return s.c_str ();}); + + template <typename I, typename F> + void + hash_option_values (sha256&, + const char* opt, + I begin, I end, + F&& get = [] (const string& s) {return s;}); + // Check if a specified option is present in the variable or value. T is // either target or scope. // diff --git a/build2/utility.txx b/build2/utility.txx index 28c7d6e..19a9819 100644 --- a/build2/utility.txx +++ b/build2/utility.txx @@ -4,6 +4,33 @@ namespace build2 { + template <typename I, typename F> + void + append_option_values (cstrings& args, const char* o, I b, I e, F&& get) + { + if (b != e) + { + args.reserve (args.size () + (e - b)); + + for (; b != e; ++b) + { + args.push_back (o); + args.push_back (get (*b)); + } + } + } + + template <typename I, typename F> + void + hash_option_values (sha256& cs, const char* o, I b, I e, F&& get) + { + for (; b != e; ++b) + { + cs.append (o); + cs.append (get (*b)); + } + } + template <typename K> basic_path<char, K> relative (const basic_path<char, K>& p) |