summaryrefslogtreecommitdiff
path: root/src/task_ld.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2023-01-13 19:56:35 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2023-01-13 22:32:09 +0100
commit916060cb53fddb94f64b20d3616e7360c5e91f64 (patch)
tree4a2bcef4672b5e04b106f88cca3bec631b214c00 /src/task_ld.cc
parentc093758b4688fb5bae2cc7727b6c9b52b824043e (diff)
Capture flags in a class instead of a string and add conversion functions between them.
Diffstat (limited to 'src/task_ld.cc')
-rw-r--r--src/task_ld.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/task_ld.cc b/src/task_ld.cc
index 4915de9..3d917e4 100644
--- a/src/task_ld.cc
+++ b/src/task_ld.cc
@@ -90,10 +90,10 @@ int TaskLD::runInner()
auto depFile = dep->targetFile();
if(depFile.extension() == ".so")
{
- append(args, getOption(toolchain, ctor::opt::library_path,
+ append(args, ld_option(toolchain, ctor::ld_opt::library_path,
targetFile().parent_path().string()));
auto lib = depFile.stem().string().substr(3); // strip 'lib' prefix
- append(args, getOption(toolchain, ctor::opt::link, lib));
+ append(args, ld_option(toolchain, ctor::ld_opt::link, lib));
}
else if(depFile.extension() == ".a" || depFile.extension() == ".o")
{
@@ -101,8 +101,12 @@ int TaskLD::runInner()
}
}
- append(args, config.flags.ldflags);
- append(args, getOption(toolchain, ctor::opt::output, targetFile().string()));
+ for(const auto& flag : config.flags.ldflags)
+ {
+ append(args, to_strings(toolchain, flag));
+ }
+
+ append(args, ld_option(toolchain, ctor::ld_opt::output, targetFile().string()));
{ // Write flags to file.
std::ofstream flagsStream(flagsFile);
@@ -168,14 +172,20 @@ bool TaskLD::derived() const
std::string TaskLD::flagsString() const
{
+ auto toolchain = getToolChain(config.system);
std::string flagsStr;
+ bool first{true};
for(const auto& flag : config.flags.ldflags)
{
- if(flag != config.flags.ldflags[0])
+ for(const auto& str : to_strings(toolchain, flag))
{
- flagsStr += " ";
+ if(first)
+ {
+ flagsStr += " ";
+ first = false;
+ }
+ flagsStr += str;
}
- flagsStr += flag;
}
flagsStr += "\n";