aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/cc')
-rw-r--r--libbuild2/cc/guess.cxx39
1 files changed, 21 insertions, 18 deletions
diff --git a/libbuild2/cc/guess.cxx b/libbuild2/cc/guess.cxx
index 9f91eae..bba3a35 100644
--- a/libbuild2/cc/guess.cxx
+++ b/libbuild2/cc/guess.cxx
@@ -424,6 +424,7 @@ namespace build2
struct msvc_info
{
dir_path msvc_dir; // VC directory (...\Tools\MSVC\<ver>\).
+ string msvc_cpu; // Target CPU (x86, x64) or empty if unknown.
string psdk_ver; // Platfor SDK directory (...\Windows Kits\<ver>\).
dir_path psdk_dir; // Platfor SDK version (under Include/, Lib/, etc).
};
@@ -467,9 +468,9 @@ namespace build2
{0x87, 0xBF, 0xD5, 0x77, 0x83, 0x8F, 0x1D, 0x5C}};
// If cl is not empty, then find an installation that contains this cl.exe
- // path.
+ // path and also derive msvc_cpu from it.
//
- // @@ TODO: if (cl.sub (r.msvc_dir)) ...
+ // @@ TODO: if (cl.sub (r.msvc_dir)), msvc_cpu derivation.
//
static optional<msvc_info>
find_msvc (const path& /*cl*/ = path ())
@@ -857,8 +858,11 @@ namespace build2
// there is nothing like -m32/-m64 or /MACHINE). Targeting
// 64-bit seems like as good of a default as any.
//
+ if (mi->msvc_cpu.empty ())
+ mi->msvc_cpu = "x64";
+
fb = ((dir_path (mi->msvc_dir) /= "bin") /= "Hostx64") /=
- "x64";
+ mi->msvc_cpu;
search_info = info_ptr (
new msvc_info (move (*mi)), msvc_info_deleter);
@@ -1333,11 +1337,11 @@ namespace build2
// Studio command prompt puts into LIB).
//
static dir_paths
- msvc_lib (const msvc_info& mi, const char* cpu)
+ msvc_lib (const msvc_info& mi)
{
dir_paths r;
- r.push_back ((dir_path (mi.msvc_dir) /= "lib") /= cpu);
+ r.push_back ((dir_path (mi.msvc_dir) /= "lib") /= mi.msvc_cpu);
// This path structure only appeared in Platform SDK 10 (if anyone wants
// to use anything older, they will just have to use the MSVC command
@@ -1347,8 +1351,8 @@ namespace build2
{
dir_path d ((dir_path (mi.psdk_dir) /= "Lib") /= mi.psdk_ver);
- r.push_back ((dir_path (d) /= "ucrt") /= cpu);
- r.push_back ((dir_path (d) /= "um" ) /= cpu);
+ r.push_back ((dir_path (d) /= "ucrt") /= mi.msvc_cpu);
+ r.push_back ((dir_path (d) /= "um" ) /= mi.msvc_cpu);
}
return r;
@@ -1358,7 +1362,7 @@ namespace build2
// command prompt puts into PATH).
//
static string
- msvc_bin (const msvc_info& mi, const char* cpu)
+ msvc_bin (const msvc_info& mi)
{
string r;
@@ -1366,13 +1370,13 @@ namespace build2
// MSVC tools (link.exe, etc). In case of the Platform SDK, it's unclear
// what the CPU signifies (host, target, both).
//
- r = (((dir_path (mi.msvc_dir) /= "bin") /= "Hostx64") /= cpu).
- representation ();
+ r = (((dir_path (mi.msvc_dir) /= "bin") /= "Hostx64") /=
+ mi.msvc_cpu).representation ();
r += path::traits_type::path_separator;
- r += (((dir_path (mi.psdk_dir) /= "bin") /= mi.psdk_ver) /= cpu).
- representation ();
+ r += (((dir_path (mi.psdk_dir) /= "bin") /= mi.psdk_ver) /=
+ mi.msvc_cpu).representation ();
return r;
}
@@ -1553,9 +1557,9 @@ namespace build2
if (const msvc_info* mi = static_cast<msvc_info*> (gr.info.get ()))
{
- lib_dirs = msvc_lib (*mi, "x64");
+ lib_dirs = msvc_lib (*mi);
inc_dirs = msvc_include (*mi);
- bpat = msvc_bin (*mi, "x64");
+ bpat = msvc_bin (*mi);
}
// Derive the toolchain pattern.
@@ -2226,6 +2230,7 @@ namespace build2
// directory and Platform SDK).
//
clang_msvc_info mi (guess_clang_msvc (xl, xp, c_co, x_co, cl));
+ mi.msvc_cpu = msvc_cpu (tt.cpu);
// Keep the CPU and replace the rest.
//
@@ -2247,13 +2252,11 @@ namespace build2
gr.signature += " MSVC version ";
gr.signature += mi.msvc_ver;
- const char* cpu (msvc_cpu (tt.cpu));
-
// Come up with the system library search paths. Ideally we would want
// to extract this from Clang and -print-search-paths would have been
// the natural way for Clang to report it. But no luck.
//
- lib_dirs = msvc_lib (mi, cpu);
+ lib_dirs = msvc_lib (mi);
// Binutils search paths.
//
@@ -2262,7 +2265,7 @@ namespace build2
// lines. However, reliably detecting this and making sure the result
// matches Clang's is complex. So let's keep it simple for now.
//
- bpat = msvc_bin (mi, cpu);
+ bpat = msvc_bin (mi);
// If this is clang-cl, then use the MSVC compatibility version as its
// primary version.