From ae1871ca0ffcac3e8bd337f8d8bb4e7fd6c59295 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 10 Jul 2022 17:24:16 +0200 Subject: Make tools abstraction around compiler options to better support tool agnostic arguments. --- src/task_ld.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/task_ld.cc') diff --git a/src/task_ld.cc b/src/task_ld.cc index df50001..20e823d 100644 --- a/src/task_ld.cc +++ b/src/task_ld.cc @@ -9,6 +9,7 @@ #include "libctor.h" #include "execute.h" #include "util.h" +#include "tools.h" TaskLD::TaskLD(const BuildConfiguration& config, const Settings& settings, @@ -81,15 +82,18 @@ bool TaskLD::dirtyInner() int TaskLD::runInner() { + auto tool_chain = getToolChain(config.system); + std::vector args; for(const auto& dep : getDependsTasks()) { auto depFile = dep->targetFile(); if(depFile.extension() == ".so") { - args.push_back(std::string("-L") + targetFile().parent_path().string()); + append(args, getOption(tool_chain, opt::library_path, + targetFile().parent_path().string())); auto lib = depFile.stem().string().substr(3); // strip 'lib' prefix - args.push_back(std::string("-l") + lib); + append(args, getOption(tool_chain, opt::link, lib)); } else if(depFile.extension() == ".a" || depFile.extension() == ".o") { @@ -97,12 +101,8 @@ int TaskLD::runInner() } } - for(const auto& flag : config.flags.ldflags) - { - args.push_back(flag); - } - args.push_back("-o"); - args.push_back(targetFile().string()); + append(args, config.flags.ldflags); + append(args, getOption(tool_chain, opt::output, targetFile().string())); { // Write flags to file. std::ofstream flagsStream(flagsFile); -- cgit v1.2.3