diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-06-13 19:00:13 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-06-13 19:00:13 +0200 |
commit | 4f923fbdace27f27421bf18dfc9655b73bd68929 (patch) | |
tree | 7bfe332416020e9e70d807b7ca9b7b3c59bb8f1e /task_ld.cc | |
parent | 19195e2bbdcd7a0db8f84732ce54b1c9d07c006c (diff) |
Move execution code into its own function and use from all tasks.
Diffstat (limited to 'task_ld.cc')
-rw-r--r-- | task_ld.cc | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -2,14 +2,10 @@ #include <iostream> #include <fstream> -#include <unistd.h> -#include <cstring> -#include <sys/types.h> -#include <sys/wait.h> -#include <spawn.h> #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<std::string> 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() |