From 4f923fbdace27f27421bf18dfc9655b73bd68929 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 13 Jun 2021 19:00:13 +0200 Subject: Move execution code into its own function and use from all tasks. --- task_ld.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'task_ld.cc') diff --git a/task_ld.cc b/task_ld.cc index 235523f..0cd4c95 100644 --- a/task_ld.cc +++ b/task_ld.cc @@ -2,14 +2,10 @@ #include #include -#include -#include -#include -#include -#include #include "libcppbuild.h" #include "settings.h" +#include "execute.h" TaskLD::TaskLD(const BuildConfiguration& config, const Settings& settings, @@ -22,8 +18,6 @@ TaskLD::TaskLD(const BuildConfiguration& config, targetFile /= target; for(const auto& object : objects) { - //std::filesystem::path objectFile = settings.builddir; - //objectFile /= object; std::filesystem::path objectFile = object; objectFiles.push_back(objectFile); } @@ -60,15 +54,19 @@ int TaskLD::run() objectlist += std::string(objectFile); } - std::string compiler = "g++ " + objectlist + " " + - config.ldflags + " " + - "-o " + std::string(targetFile); - std::cout << compiler << "\n"; - if(system(compiler.data())) + std::vector args; + for(const auto& objectFile : objectFiles) { - return 1; + args.push_back(std::string(objectFile)); } - return 0; + for(const auto& flag : config.ldflags) + { + args.push_back(flag); + } + args.push_back("-o"); + args.push_back(std::string(targetFile)); + + return execute("/usr/bin/g++", args); } int TaskLD::clean() -- cgit v1.2.3