diff options
-rw-r--r-- | build2/cc/module.cxx | 2 | ||||
-rw-r--r-- | build2/install/rule.cxx | 34 | ||||
-rw-r--r-- | build2/parser.cxx | 36 | ||||
-rw-r--r-- | build2/test/script/parser.cxx | 4 |
4 files changed, 40 insertions, 36 deletions
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index f619e5f..1c4e84c 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -137,6 +137,7 @@ namespace build2 { lib_dirs = gcc_library_search_paths (ci.path, rs); +#ifndef _WIN32 // Many platforms don't search in /usr/local/lib by default (but do // for headers in /usr/local/include). So add it as the last option. // @@ -150,6 +151,7 @@ namespace build2 // if (tt.system == "freebsd") inc_dirs.push_back (dir_path ("/usr/local/include")); +#endif } // If this is a new value (e.g., we are configuring), then print the diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx index c97dbb0..c208efa 100644 --- a/build2/install/rule.cxx +++ b/build2/install/rule.cxx @@ -389,16 +389,25 @@ namespace build2 // So this function translates an absolute Windows path to its MSYS // representation. // - static dir_path + // Note that we return the result as a string, not dir_path since path + // starting with / are illegal on Windows. Also note that the result + // doesn't have the trailing slash. + // + static string msys_path (const dir_path& d) { assert (d.absolute ()); - string s (d.representation ()); - s[1] = lcase (s[0]); // Replace ':' with the drive letter. + + // First replace ':' with the drive letter (so the path is no longer + // absolute) but postpone setting the first character to / until we are + // a string. + // + s[1] = lcase (s[0]); + s = dir_path (move (s)).posix_string (); s[0] = '/'; - return dir_path (dir_path (move (s)).posix_representation ()); + return s; } // install -d <dir> @@ -433,10 +442,10 @@ namespace build2 cstrings args; - dir_path reld ( + string reld ( cast<string> ((*global_scope)["build.host.class"]) == "windows" ? msys_path (d) - : relative (d)); + : relative (d).string ()); if (base.sudo != nullptr) args.push_back (base.sudo->c_str ()); @@ -449,7 +458,7 @@ namespace build2 args.push_back ("-m"); args.push_back (base.dir_mode->c_str ()); - args.push_back (reld.string ().c_str ()); + args.push_back (reld.c_str ()); args.push_back (nullptr); try @@ -491,13 +500,16 @@ namespace build2 { path relf (relative (t.path ())); - path reld ( + string reld ( cast<string> ((*global_scope)["build.host.class"]) == "windows" ? msys_path (base.dir) - : relative (base.dir)); + : relative (base.dir).string ()); if (!name.empty ()) - reld /= name; + { + reld += path::traits::directory_separator; + reld += name.string (); + } cstrings args; @@ -512,7 +524,7 @@ namespace build2 args.push_back ("-m"); args.push_back (base.mode->c_str ()); args.push_back (relf.string ().c_str ()); - args.push_back (reld.string ().c_str ()); + args.push_back (reld.c_str ()); args.push_back (nullptr); try diff --git a/build2/parser.cxx b/build2/parser.cxx index 1d2766c..87ec8b1 100644 --- a/build2/parser.cxx +++ b/build2/parser.cxx @@ -24,8 +24,6 @@ namespace build2 { using type = token_type; - static const dir_path root_dir; - class parser::enter_scope { public: @@ -33,33 +31,27 @@ namespace build2 enter_scope (parser& p, dir_path&& d): p_ (&p), r_ (p.root_), s_ (p.scope_) { - // Check for the global scope as a special case. Note that the global - // scope (empty) path is a prefix for any other scope path. + // Try hard not to call normalize(). Most of the time we will go just + // one level deeper. // - if (d != root_dir) + bool n (true); + + if (d.relative ()) { - // Try hard not to call normalize(). Most of the time we will go just - // one level deeper. + // Relative scopes are opened relative to out, not src. // - bool n (true); - - if (d.relative ()) + if (d.simple () && d.string () != "." && d.string () != "..") { - // Relative scopes are opened relative to out, not src. - // - if (d.simple () && d.string () != "." && d.string () != "..") - { - d = dir_path (p.scope_->out_path ()) /= d.string (); - n = false; - } - else - d = p.scope_->out_path () / d; + d = dir_path (p.scope_->out_path ()) /= d.string (); + n = false; } - - if (n) - d.normalize (); + else + d = p.scope_->out_path () / d; } + if (n) + d.normalize (); + p.switch_scope (d); } diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx index 1c3baea..059cb93 100644 --- a/build2/test/script/parser.cxx +++ b/build2/test/script/parser.cxx @@ -1338,9 +1338,7 @@ namespace build2 if (!p.empty ()) { - // Current dir collapses to an empty one. - // - p.normalize (false, true); + p.normalize (); return p; } |