aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/bin/module.cxx18
-rw-r--r--build2/cxx/link.cxx61
2 files changed, 67 insertions, 12 deletions
diff --git a/build2/bin/module.cxx b/build2/bin/module.cxx
index 1e79e9e..472ee86 100644
--- a/build2/bin/module.cxx
+++ b/build2/bin/module.cxx
@@ -46,6 +46,9 @@ namespace build2
{
auto& v (var_pool);
+ v.find ("config.bin.ar", string_type); //@@ VAR path_type
+ v.find ("config.bin.ranlib", string_type); //@@ VAR path_type
+
v.find ("config.bin.lib", string_type);
v.find ("config.bin.exe.lib", strings_type);
v.find ("config.bin.liba.lib", strings_type);
@@ -154,6 +157,21 @@ namespace build2
if (const value& v = config::optional (r, "config.bin.rpath"))
b.assign ("bin.rpath") += as<strings> (v);
+ // config.bin.ar
+ // config.bin.ranlib
+ //
+ // For config.bin.ar we default to 'ar' while ranlib should be explicitly
+ // specified by the user in order for us to use it (most targets support
+ // -s option to ar).
+ //
+ if (first)
+ {
+ // @@ Maybe, if explicitly specified by the user, we should try to run
+ // them?
+ //
+ config::required (r, "config.bin.ar", "ar");
+ config::optional (r, "config.bin.ranlib");
+ }
// Configure "installability" of our target types.
//
diff --git a/build2/cxx/link.cxx b/build2/cxx/link.cxx
index 05c045f..7e0ff71 100644
--- a/build2/cxx/link.cxx
+++ b/build2/cxx/link.cxx
@@ -505,7 +505,13 @@ namespace build2
{
case type::e:
{
- t.derive_path (""); // "exe"
+ const char* e;
+ if (sys == "mingw32")
+ e = "exe";
+ else
+ e = "";
+
+ t.derive_path (e);
break;
}
case type::a:
@@ -774,12 +780,20 @@ namespace build2
string soname1, soname2;
strings sargs;
+ lookup<const value> ranlib;
+
if (lt == type::a)
{
- //@@ ranlib
+ // If the user asked for ranlib, don't try to do its function
+ // with -s.
//
- args.push_back ("ar");
- args.push_back ("-rc");
+ ranlib = rs["config.bin.ranlib"];
+
+ if (ranlib->empty ()) // @@ TMP until proper NULL support.
+ ranlib = lookup<const value> ();
+
+ args.push_back (as<string> (*rs["config.bin.ar"]).c_str ());
+ args.push_back (ranlib ? "-rc" : "-rcs");
args.push_back (relt.string ().c_str ());
}
else
@@ -881,14 +895,6 @@ namespace build2
if (!pr.wait ())
throw failed ();
-
- // Should we go to the filesystem and get the new mtime? We
- // know the file has been modified, so instead just use the
- // current clock time. It has the advantage of having the
- // subseconds precision.
- //
- t.mtime (system_clock::now ());
- return target_state::changed;
}
catch (const process_error& e)
{
@@ -903,6 +909,37 @@ namespace build2
throw failed ();
}
+
+ if (ranlib)
+ {
+ const char* args[] = {
+ as<string> (*ranlib).c_str (), relt.string ().c_str (), nullptr};
+
+ try
+ {
+ process pr (args);
+
+ if (!pr.wait ())
+ throw failed ();
+ }
+ catch (const process_error& e)
+ {
+ error << "unable to execute " << args[0] << ": " << e.what ();
+
+ if (e.child ())
+ exit (1);
+
+ throw failed ();
+ }
+ }
+
+ // Should we go to the filesystem and get the new mtime? We
+ // know the file has been modified, so instead just use the
+ // current clock time. It has the advantage of having the
+ // subseconds precision.
+ //
+ t.mtime (system_clock::now ());
+ return target_state::changed;
}
link link::instance;