From 85399cf60764b0fe54d44d4a5bacb54feae8dd62 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 21 Jun 2019 15:01:41 +0200 Subject: Add support for [config.]{cc,c,cxx}.aoptions (archive options) In particular, this can be used to suppress lib.exe warnings, for example: cc.aoptions += /IGNORE:4221 --- build2/c/init.cxx | 7 ++++++- build2/cc/common.hxx | 3 +++ build2/cc/init.cxx | 5 +++++ build2/cc/link-rule.cxx | 23 ++++++++++++----------- build2/cc/module.cxx | 3 +++ build2/cxx/init.cxx | 5 +++++ doc/manual.cli | 19 ++++++++++++++++--- 7 files changed, 50 insertions(+), 15 deletions(-) diff --git a/build2/c/init.cxx b/build2/c/init.cxx index 0f74539..7c12fdd 100644 --- a/build2/c/init.cxx +++ b/build2/c/init.cxx @@ -168,6 +168,7 @@ namespace build2 v.insert ("config.c.poptions", true), v.insert ("config.c.coptions", true), v.insert ("config.c.loptions", true), + v.insert ("config.c.aoptions", true), v.insert ("config.c.libs", true), nullptr /* config.c.importable_headers */, @@ -176,15 +177,19 @@ namespace build2 v.insert ("c.sys_inc_dirs"), v.insert ("c.std", variable_visibility::project), + v.insert ("c.poptions"), v.insert ("c.coptions"), v.insert ("c.loptions"), + v.insert ("c.aoptions"), v.insert ("c.libs"), - nullptr /* c.importable_headers */, + + nullptr /* c.importable_headers */, v["cc.poptions"], v["cc.coptions"], v["cc.loptions"], + v["cc.aoptions"], v["cc.libs"], v.insert ("c.export.poptions"), diff --git a/build2/cc/common.hxx b/build2/cc/common.hxx index 3f0f9fb..6eccf23 100644 --- a/build2/cc/common.hxx +++ b/build2/cc/common.hxx @@ -48,6 +48,7 @@ namespace build2 const variable& config_x_poptions; const variable& config_x_coptions; const variable& config_x_loptions; + const variable& config_x_aoptions; const variable& config_x_libs; const variable* config_x_importable_headers; @@ -59,12 +60,14 @@ namespace build2 const variable& x_poptions; const variable& x_coptions; const variable& x_loptions; + const variable& x_aoptions; const variable& x_libs; const variable* x_importable_headers; const variable& c_poptions; // cc.* const variable& c_coptions; const variable& c_loptions; + const variable& c_aoptions; const variable& c_libs; const variable& x_export_poptions; diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx index 4223d84..882b205 100644 --- a/build2/cc/init.cxx +++ b/build2/cc/init.cxx @@ -85,11 +85,13 @@ namespace build2 v.insert ("config.cc.poptions", true); v.insert ("config.cc.coptions", true); v.insert ("config.cc.loptions", true); + v.insert ("config.cc.aoptions", true); v.insert ("config.cc.libs", true); v.insert ("cc.poptions"); v.insert ("cc.coptions"); v.insert ("cc.loptions"); + v.insert ("cc.aoptions"); v.insert ("cc.libs"); v.insert ("cc.export.poptions"); @@ -259,6 +261,9 @@ namespace build2 rs.assign ("cc.loptions") += cast_null ( config::optional (rs, "config.cc.loptions")); + rs.assign ("cc.aoptions") += cast_null ( + config::optional (rs, "config.cc.aoptions")); + rs.assign ("cc.libs") += cast_null ( config::optional (rs, "config.cc.libs")); diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index 3b58ab7..588f3ae 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -1870,7 +1870,15 @@ namespace build2 { if (tsys == "win32-msvc") { - // No options for lib.exe. + // lib.exe has /LIBPATH but it's not clear/documented what it's used + // for. Perhaps for link-time code generation (/LTCG)? If that's the + // case, then we may need to pass *.loptions. + // + args.push_back ("/NOLOGO"); + + // Add /MACHINE. + // + args.push_back (msvc_machine (cast (rs[x_target_cpu]))); } else { @@ -1914,6 +1922,9 @@ namespace build2 args.push_back (arg1.c_str ()); } + + append_options (args, t, c_aoptions); + append_options (args, t, x_aoptions); } else { @@ -2172,16 +2183,6 @@ namespace build2 if (tsys == "win32-msvc") { - // lib.exe has /LIBPATH but it's not clear/documented what it's used - // for. Perhaps for link-time code generation (/LTCG)? If that's the - // case, then we may need to pass *.loptions. - // - args.push_back ("/NOLOGO"); - - // Add /MACHINE. - // - args.push_back (msvc_machine (cast (rs[x_target_cpu]))); - out = "/OUT:" + relt.string (); args.push_back (out.c_str ()); } diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index aa775ae..00c5aa9 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -520,6 +520,9 @@ namespace build2 rs.assign (x_loptions) += cast_null ( config::optional (rs, config_x_loptions)); + rs.assign (x_aoptions) += cast_null ( + config::optional (rs, config_x_aoptions)); + rs.assign (x_libs) += cast_null ( config::optional (rs, config_x_libs)); diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx index 25b6c0d..518a823 100644 --- a/build2/cxx/init.cxx +++ b/build2/cxx/init.cxx @@ -393,6 +393,7 @@ namespace build2 v.insert ("config.cxx.poptions", true), v.insert ("config.cxx.coptions", true), v.insert ("config.cxx.loptions", true), + v.insert ("config.cxx.aoptions", true), v.insert ("config.cxx.libs", true), // List of importable headers. Inclusion of such headers is translated @@ -411,15 +412,19 @@ namespace build2 v.insert ("cxx.sys_inc_dirs"), v.insert ("cxx.std", variable_visibility::project), + v.insert ("cxx.poptions"), v.insert ("cxx.coptions"), v.insert ("cxx.loptions"), + v.insert ("cxx.aoptions"), v.insert ("cxx.libs"), + &v.insert ("cxx.importable_headers"), v["cc.poptions"], v["cc.coptions"], v["cc.loptions"], + v["cc.aoptions"], v["cc.libs"], v.insert ("cxx.export.poptions"), diff --git a/doc/manual.cli b/doc/manual.cli index b145818..ac6cb24 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -1349,9 +1349,19 @@ int main () \ \N|Besides \c{poptions}, there are also \c{coptions} (compile options), -\c{loptions} (link options) and \c{libs} (extra libraries to link). If you are -familiar with \c{make}, these are roughly equivalent to \c{CPPFLAGS}, -\c{CFLAGS}/\c{CXXFLAGS}, \c{LDFLAGS}, and \c{LIBS}. +\c{loptions} (link options), \c{aoptions} (archive options) and \c{libs} +(extra libraries to link). If you are familiar with \c{make}, these are +roughly equivalent to \c{CPPFLAGS}, \c{CFLAGS}/\c{CXXFLAGS}, \c{LDFLAGS}, +\c{ARFLAGS}, and \c{LIBS}, respectively. Here they are again in the tabular +form: + +\ +*.poptions preprocess CPPFLAGS +*.coptions compile CFLAGS/CXXFLAGS +*.loptions link LDFLAGS +*.aoptions archive ARFLAGS +*.libs extra libraries LIBS +\ More specifically, there are three sets of these variables: \c{cc.*} (stands for \i{C-common}) which applies to all C-like languages as well as \c{c.*} and @@ -1663,6 +1673,7 @@ config.cxx = clang++ config.cxx.poptions = [null] config.cxx.coptions = -g config.cxx.loptions = [null] +config.cxx.aoptions = [null] config.cxx.libs = [null] ... \ @@ -1681,6 +1692,7 @@ config.cxx = g++ config.cxx.poptions = [null] config.cxx.coptions = -g config.cxx.loptions = [null] +config.cxx.aoptions = [null] config.cxx.libs = [null] ... \ @@ -2975,6 +2987,7 @@ config.cxx = clang++ config.cxx.poptions = [null] config.cxx.coptions = -g config.cxx.loptions = [null] +config.cxx.aoptions = [null] config.cxx.libs = [null] ... -- cgit v1.1