diff options
-rw-r--r-- | libbuild2/c/init.cxx | 1 | ||||
-rw-r--r-- | libbuild2/cc/common.hxx | 8 | ||||
-rw-r--r-- | libbuild2/cc/compile-rule.cxx | 23 | ||||
-rw-r--r-- | libbuild2/cc/guess.cxx | 28 | ||||
-rw-r--r-- | libbuild2/cc/guess.hxx | 4 | ||||
-rw-r--r-- | libbuild2/cc/module.cxx | 12 | ||||
-rw-r--r-- | libbuild2/cxx/init.cxx | 1 |
7 files changed, 64 insertions, 13 deletions
diff --git a/libbuild2/c/init.cxx b/libbuild2/c/init.cxx index 7129f37..423e6af 100644 --- a/libbuild2/c/init.cxx +++ b/libbuild2/c/init.cxx @@ -354,6 +354,7 @@ namespace build2 cast<dir_paths> (rs[cm.x_sys_lib_dirs]), cast<dir_paths> (rs[cm.x_sys_inc_dirs]), + cm.x_info->sys_mod_dirs, cm.sys_lib_dirs_extra, cm.sys_inc_dirs_extra, diff --git a/libbuild2/cc/common.hxx b/libbuild2/cc/common.hxx index 0548d6f..84d287c 100644 --- a/libbuild2/cc/common.hxx +++ b/libbuild2/cc/common.hxx @@ -162,8 +162,9 @@ namespace build2 const strings* xlate_hdr; // x.translatable_headers (NULL if // unused/empty). - const dir_paths& sys_lib_dirs; // x.sys_lib_dirs - const dir_paths& sys_inc_dirs; // x.sys_inc_dirs + const dir_paths& sys_lib_dirs; // x.sys_lib_dirs + const dir_paths& sys_inc_dirs; // x.sys_inc_dirs + const optional<dir_paths>& sys_mod_dirs; // compiler_info::sys_mod_dirs size_t sys_lib_dirs_extra; // First extra path (size if none). size_t sys_inc_dirs_extra; // First extra path (size if none). @@ -213,6 +214,7 @@ namespace build2 bool fs, const dir_paths& sld, const dir_paths& sid, + const optional<dir_paths>& smd, size_t sle, size_t sie, const target_type& src, @@ -232,7 +234,7 @@ namespace build2 modules (fm), symexport (fs), xlate_hdr (nullptr), - sys_lib_dirs (sld), sys_inc_dirs (sid), + sys_lib_dirs (sld), sys_inc_dirs (sid), sys_mod_dirs (smd), sys_lib_dirs_extra (sle), sys_inc_dirs_extra (sie), x_src (src), x_mod (mod), x_hdr (hdr), x_inc (inc) {} }; diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index c0f876c..98b78e1 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -5576,11 +5576,24 @@ namespace build2 for (const string& a: stor) args.push_back (a.c_str ()); - // VC's IFCPATH takes precedence over /module:stdIfcDir so unset it - // if we are using our own std modules. - // - if (!stdifc.empty ()) - env.push_back ("IFCPATH"); + if (getenv ("IFCPATH")) + { + // VC's IFCPATH takes precedence over /module:stdIfcDir so unset it if + // we are using our own std modules. + // + if (!stdifc.empty ()) + env.push_back ("IFCPATH"); + } + else if (stdifc.empty ()) + { + // Add the VC's default directory (should be only one). + // + if (sys_mod_dirs && !sys_mod_dirs->empty ()) + { + args.push_back ("/module:stdIfcDir"); + args.push_back (sys_mod_dirs->front ().string ().c_str ()); + } + } } target_state compile_rule:: diff --git a/libbuild2/cc/guess.cxx b/libbuild2/cc/guess.cxx index c37b6b6..053a4cb 100644 --- a/libbuild2/cc/guess.cxx +++ b/libbuild2/cc/guess.cxx @@ -1360,7 +1360,7 @@ namespace build2 // do that probably first checking if they exist/empty). // static dir_paths - msvc_include (const msvc_info& mi) + msvc_inc (const msvc_info& mi) { dir_paths r; @@ -1382,6 +1382,19 @@ namespace build2 return r; } + // Return the MSVC system module search paths (i.e., what the Visual + // Studio command prompt puts into IFCPATH). + // + static dir_paths + msvc_mod (const msvc_info& mi, const char* cpu) + { + dir_paths r; + + r.push_back ((dir_path (mi.msvc_dir) /= "ifc") /= cpu); + + return r; + } + // Return the MSVC system library search paths (i.e., what the Visual // Studio command prompt puts into LIB). // @@ -1601,10 +1614,11 @@ namespace build2 // If we have the MSVC installation information, then this means we are // running out of the Visual Studio command prompt and will have to - // supply PATH/INCLUDE/LIB equivalents ourselves. + // supply PATH/INCLUDE/LIB/IFCPATH equivalents ourselves. // optional<dir_paths> lib_dirs; optional<dir_paths> inc_dirs; + optional<dir_paths> mod_dirs; string bpat; if (const msvc_info* mi = static_cast<msvc_info*> (gr.info.get ())) @@ -1612,7 +1626,9 @@ namespace build2 const char* cpu (msvc_cpu (target_triplet (t).cpu)); lib_dirs = msvc_lib (*mi, cpu); - inc_dirs = msvc_include (*mi); + inc_dirs = msvc_inc (*mi); + mod_dirs = msvc_mod (*mi, cpu); + bpat = msvc_bin (*mi, cpu); } @@ -1654,7 +1670,8 @@ namespace build2 move (csl), move (xsl), move (lib_dirs), - move (inc_dirs)}; + move (inc_dirs), + move (mod_dirs)}; } static compiler_info @@ -1852,6 +1869,7 @@ namespace build2 move (csl), move (xsl), nullopt, + nullopt, nullopt}; } @@ -2438,6 +2456,7 @@ namespace build2 move (csl), move (xsl), move (lib_dirs), + nullopt, nullopt}; } @@ -2743,6 +2762,7 @@ namespace build2 move (csl), move (xsl), nullopt, + nullopt, nullopt}; } diff --git a/libbuild2/cc/guess.hxx b/libbuild2/cc/guess.hxx index d93aaf9..b32aaa9 100644 --- a/libbuild2/cc/guess.hxx +++ b/libbuild2/cc/guess.hxx @@ -227,10 +227,12 @@ namespace build2 string c_stdlib; string x_stdlib; - // System library/header search paths, if extracted at the guess stage. + // System library/header/module search paths, if extracted at the guess + // stage. // optional<dir_paths> sys_lib_dirs; optional<dir_paths> sys_inc_dirs; + optional<dir_paths> sys_mod_dirs; }; // In a sense this is analagous to the language standard which we handle diff --git a/libbuild2/cc/module.cxx b/libbuild2/cc/module.cxx index 5f8652e..881583f 100644 --- a/libbuild2/cc/module.cxx +++ b/libbuild2/cc/module.cxx @@ -403,8 +403,11 @@ namespace build2 // Extract system header/library search paths from the compiler and // determine if we need any additional search paths. // + // Note that for now module search paths only come from compiler_info. + // dir_paths lib_dirs; dir_paths inc_dirs; + const optional<dir_paths>& mod_dirs (xi.sys_mod_dirs); if (xi.sys_lib_dirs) lib_dirs = *xi.sys_lib_dirs; @@ -599,6 +602,15 @@ namespace build2 dr << "\n pattern " << xi.pattern; } + if (verb >= 3 && mod_dirs && !mod_dirs->empty ()) + { + dr << "\n mod dirs"; + for (const dir_path& d: *mod_dirs) + { + dr << "\n " << d; + } + } + if (verb >= 3 && !inc_dirs.empty ()) { dr << "\n inc dirs"; diff --git a/libbuild2/cxx/init.cxx b/libbuild2/cxx/init.cxx index 851ea0c..8e641b5 100644 --- a/libbuild2/cxx/init.cxx +++ b/libbuild2/cxx/init.cxx @@ -626,6 +626,7 @@ namespace build2 cast<dir_paths> (rs[cm.x_sys_lib_dirs]), cast<dir_paths> (rs[cm.x_sys_inc_dirs]), + cm.x_info->sys_mod_dirs, cm.sys_lib_dirs_extra, cm.sys_inc_dirs_extra, |