summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2023-01-14 12:05:23 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2023-01-14 12:10:58 +0100
commit321f25af1ba33d8409cd294b4f50d0d3e79cf3bd (patch)
tree586c8297ca89e477ae8dfc228dd71f0b15f96faa /src
parentd5c88fedf517e738490c32fa95097e03178903fe (diff)
Add ar_flag support for ar tool, replacing hardcoded values.HEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/ctor.h5
-rw-r--r--src/task_ar.cc8
-rw-r--r--src/tools.cc18
3 files changed, 29 insertions, 2 deletions
diff --git a/src/ctor.h b/src/ctor.h
index 36aa46a..b8b3ae6 100644
--- a/src/ctor.h
+++ b/src/ctor.h
@@ -120,6 +120,11 @@ enum class ld_opt
enum class ar_opt
{
// gcc/clang
+ replace, // -r
+ add_index, // -s
+ create, // -c
+ output, // <arg>
+
custom, // entire option taken verbatim from <arg>
};
diff --git a/src/task_ar.cc b/src/task_ar.cc
index 81ced0f..426a576 100644
--- a/src/task_ar.cc
+++ b/src/task_ar.cc
@@ -78,9 +78,13 @@ bool TaskAR::dirtyInner()
int TaskAR::runInner()
{
+ auto toolchain = getToolChain(config.system);
+
std::vector<std::string> args;
- args.push_back("rcs");
- args.push_back(targetFile().string());
+ append(args, ar_option(toolchain, ctor::ar_opt::replace));
+ append(args, ar_option(toolchain, ctor::ar_opt::add_index));
+ append(args, ar_option(toolchain, ctor::ar_opt::create));
+ append(args, ar_option(toolchain, ctor::ar_opt::output, targetFile().string()));
for(const auto& task : getDependsTasks())
{
args.push_back(task->targetFile().string());
diff --git a/src/tools.cc b/src/tools.cc
index 476386b..28d3903 100644
--- a/src/tools.cc
+++ b/src/tools.cc
@@ -80,6 +80,10 @@ std::ostream& operator<<(std::ostream& stream, const ctor::ar_opt& opt)
// Adding to this enum should also imply adding to the unit-tests below
switch(opt)
{
+ case ctor::ar_opt::replace: stream << "ctor::ar_opt::replace"; break;
+ case ctor::ar_opt::add_index: stream << "ctor::ar_opt::add_index"; break;
+ case ctor::ar_opt::create: stream << "ctor::ar_opt::create"; break;
+ case ctor::ar_opt::output: stream << "ctor::ar_opt::output"; break;
case ctor::ar_opt::custom: stream << "ctor::ar_opt::custom"; break;
}
@@ -174,6 +178,11 @@ ctor::ld_flag ld_option(const std::string& flag)
return { ctor::ld_opt::custom, flag };
}
+ctor::ar_flag ar_option(const std::string& flag)
+{
+ return { ctor::ar_opt::custom, flag };
+}
+
std::vector<std::string> cxx_option(ctor::cxx_opt opt, const std::string& arg)
{
switch(opt)
@@ -280,6 +289,14 @@ std::vector<std::string> ar_option(ctor::ar_opt opt, const std::string& arg)
{
switch(opt)
{
+ case ctor::ar_opt::replace:
+ return {"-r"};
+ case ctor::ar_opt::add_index:
+ return {"-s"};
+ case ctor::ar_opt::create:
+ return {"-c"};
+ case ctor::ar_opt::output:
+ return {arg};
case ctor::ar_opt::custom:
return {arg};
}
@@ -494,6 +511,7 @@ ctor::ar_flag ar_option(const std::string& flag, ctor::toolchain toolchain)
{
case ctor::toolchain::gcc:
case ctor::toolchain::clang:
+ return gcc::ar_option(flag);
case ctor::toolchain::any:
case ctor::toolchain::none:
break;