summaryrefslogtreecommitdiff
path: root/task_ld.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-06-13 19:00:13 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-06-13 19:00:13 +0200
commit4f923fbdace27f27421bf18dfc9655b73bd68929 (patch)
tree7bfe332416020e9e70d807b7ca9b7b3c59bb8f1e /task_ld.cc
parent19195e2bbdcd7a0db8f84732ce54b1c9d07c006c (diff)
Move execution code into its own function and use from all tasks.
Diffstat (limited to 'task_ld.cc')
-rw-r--r--task_ld.cc26
1 files changed, 12 insertions, 14 deletions
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 <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()