aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/cc/compile.cxx30
-rw-r--r--build2/utility.cxx22
-rw-r--r--build2/utility.hxx26
-rw-r--r--build2/utility.ixx24
4 files changed, 59 insertions, 43 deletions
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx
index c703a8a..9fae3c6 100644
--- a/build2/cc/compile.cxx
+++ b/build2/cc/compile.cxx
@@ -1714,8 +1714,13 @@ namespace build2
// is to remove the -fmodules-ts option when preprocessing. Hopefully
// there will be a "pure modules" mode at some point.
//
- append_options (args, t, c_coptions);
- append_options (args, t, x_coptions);
+
+ // Don't treat warnings as errors.
+ //
+ const char* werror (cid == compiler_id::msvc ? "/WX" : "-Werror");
+
+ append_options (args, t, c_coptions, werror);
+ append_options (args, t, x_coptions, werror);
append_options (args, tstd,
tstd.size () -
(modules && cid == compiler_id::clang ? 1 : 0));
@@ -1775,15 +1780,8 @@ namespace build2
// Clang's -M does not imply -w (disable warnings). We also don't
// need them in the -MD case (see above) so disable for both.
//
- // For GCC we want warnings in -MD (see sense_diag) but we don't
- // want then to be treated as errors.
- //
- switch (cid)
- {
- case compiler_id::clang: args.push_back ("-w"); break;
- case compiler_id::gcc: args.push_back ("-Wno-error"); break;
- default: break;
- }
+ if (cid == compiler_id::clang)
+ args.push_back ("-w");
// Previously we used '*' as a target name but it gets expanded to
// the current directory file names by GCC (4.9) that comes with
@@ -2654,8 +2652,14 @@ namespace build2
if (md.symexport)
append_symexport_options (args, t);
- append_options (args, t, c_coptions);
- append_options (args, t, x_coptions);
+ // Make sure we don't fail because of warnings.
+ //
+ // @@ Can be both -WX and /WX.
+ //
+ const char* werror (cid == compiler_id::msvc ? "/WX" : "-Werror");
+
+ append_options (args, t, c_coptions, werror);
+ append_options (args, t, x_coptions, werror);
append_options (args, tstd,
tstd.size () -
(modules && cid == compiler_id::clang ? 1 : 0));
diff --git a/build2/utility.cxx b/build2/utility.cxx
index b0325fb..36f8a4d 100644
--- a/build2/utility.cxx
+++ b/build2/utility.cxx
@@ -266,17 +266,17 @@ namespace build2
const dir_path empty_dir_path;
void
- append_options (cstrings& args, const lookup& l)
+ append_options (cstrings& args, const lookup& l, const char* e)
{
if (l)
- append_options (args, cast<strings> (l));
+ append_options (args, cast<strings> (l), e);
}
void
- append_options (strings& args, const lookup& l)
+ append_options (strings& args, const lookup& l, const char* e)
{
if (l)
- append_options (args, cast<strings> (l));
+ append_options (args, cast<strings> (l), e);
}
void
@@ -287,26 +287,32 @@ namespace build2
}
void
- append_options (cstrings& args, const strings& sv, size_t n)
+ append_options (cstrings& args, const strings& sv, size_t n, const char* e)
{
if (n != 0)
{
args.reserve (args.size () + n);
for (size_t i (0); i != n; ++i)
- args.push_back (sv[i].c_str ());
+ {
+ if (e == nullptr || e != sv[i])
+ args.push_back (sv[i].c_str ());
+ }
}
}
void
- append_options (strings& args, const strings& sv, size_t n)
+ append_options (strings& args, const strings& sv, size_t n, const char* e)
{
if (n != 0)
{
args.reserve (args.size () + n);
for (size_t i (0); i != n; ++i)
- args.push_back (sv[i]);
+ {
+ if (e == nullptr || e != sv[i])
+ args.push_back (sv[i]);
+ }
}
}
diff --git a/build2/utility.hxx b/build2/utility.hxx
index f6f9fe9..b057add 100644
--- a/build2/utility.hxx
+++ b/build2/utility.hxx
@@ -277,23 +277,25 @@ namespace build2
// Append all the values from a variable to the C-string list. T is either
// target or scope. The variable is expected to be of type strings.
//
+ // If excl is not NULL, then filter this option out (note: case sensitive).
+ //
struct variable;
template <typename T>
void
- append_options (cstrings&, T&, const variable&);
+ append_options (cstrings&, T&, const variable&, const char* excl = nullptr);
template <typename T>
void
- append_options (cstrings&, T&, const char*);
+ append_options (cstrings&, T&, const char*, const char* excl = nullptr);
template <typename T>
void
- append_options (strings&, T&, const variable&);
+ append_options (strings&, T&, const variable&, const char* excl = nullptr);
template <typename T>
void
- append_options (strings&, T&, const char*);
+ append_options (strings&, T&, const char*, const char* excl = nullptr);
template <typename T>
void
@@ -309,28 +311,32 @@ namespace build2
struct lookup;
void
- append_options (cstrings&, const lookup&);
+ append_options (cstrings&, const lookup&, const char* excl = nullptr);
void
- append_options (strings&, const lookup&);
+ append_options (strings&, const lookup&, const char* excl = nullptr);
void
hash_options (sha256&, const lookup&);
void
- append_options (cstrings&, const strings&);
+ append_options (cstrings&, const strings&, const char* excl = nullptr);
void
- append_options (strings&, const strings&);
+ append_options (strings&, const strings&, const char* excl = nullptr);
void
hash_options (sha256&, const strings&);
void
- append_options (cstrings&, const strings&, size_t);
+ append_options (cstrings&,
+ const strings&, size_t,
+ const char* excl = nullptr);
void
- append_options (strings&, const strings&, size_t);
+ append_options (strings&,
+ const strings&, size_t,
+ const char* excl = nullptr);
void
hash_options (sha256&, const strings&, size_t);
diff --git a/build2/utility.ixx b/build2/utility.ixx
index 7a706f8..0622e99 100644
--- a/build2/utility.ixx
+++ b/build2/utility.ixx
@@ -35,16 +35,16 @@ namespace build2
template <typename T>
inline void
- append_options (cstrings& args, T& s, const variable& var)
+ append_options (cstrings& args, T& s, const variable& var, const char* e)
{
- append_options (args, s[var]);
+ append_options (args, s[var], e);
}
template <typename T>
inline void
- append_options (strings& args, T& s, const variable& var)
+ append_options (strings& args, T& s, const variable& var, const char* e)
{
- append_options (args, s[var]);
+ append_options (args, s[var], e);
}
template <typename T>
@@ -56,16 +56,16 @@ namespace build2
template <typename T>
inline void
- append_options (cstrings& args, T& s, const char* var)
+ append_options (cstrings& args, T& s, const char* var, const char* e)
{
- append_options (args, s[var]);
+ append_options (args, s[var], e);
}
template <typename T>
inline void
- append_options (strings& args, T& s, const char* var)
+ append_options (strings& args, T& s, const char* var, const char* e)
{
- append_options (args, s[var]);
+ append_options (args, s[var], e);
}
template <typename T>
@@ -76,17 +76,17 @@ namespace build2
}
inline void
- append_options (cstrings& args, const strings& sv)
+ append_options (cstrings& args, const strings& sv, const char* e)
{
if (size_t n = sv.size ())
- append_options (args, sv, n);
+ append_options (args, sv, n, e);
}
inline void
- append_options (strings& args, const strings& sv)
+ append_options (strings& args, const strings& sv, const char* e)
{
if (size_t n = sv.size ())
- append_options (args, sv, n);
+ append_options (args, sv, n, e);
}
inline void