From c53e622b648635539e4870fd0c9159c5d8c3be4a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 20 Jun 2021 20:21:58 +0200 Subject: Introduction of configuration generation for controlling tool-chain. --- task_ld.cc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'task_ld.cc') diff --git a/task_ld.cc b/task_ld.cc index 874ec6d..7bf68ed 100644 --- a/task_ld.cc +++ b/task_ld.cc @@ -40,10 +40,12 @@ TaskLD::TaskLD(const BuildConfiguration& config, const Settings& settings, const std::string& target, const std::vector& objects) - : Task(addPrefix(config.depends, settings)) + : Task(config, addPrefix(config.depends, settings)) , config(config) , settings(settings) { + target_type = TargetType::Executable; + targetFile = settings.builddir; targetFile /= target; for(const auto& object : objects) @@ -62,6 +64,17 @@ TaskLD::TaskLD(const BuildConfiguration& config, flagsFile = settings.builddir / targetFile.stem(); flagsFile += ".flags"; + + target_type = TargetType::Executable; + _language = Language::C; + for(const auto& source : config.sources) + { + std::filesystem::path sourceFile(source); + if(sourceFile.extension().string() != ".c") + { + _language = Language::Cpp; + } + } } bool TaskLD::dirtyInner() @@ -146,7 +159,13 @@ int TaskLD::runInner() std::cout << "LD => " << targetFile.string() << "\n"; } - return execute("/usr/bin/g++", args, settings.verbose > 0); + auto tool = getConfiguration("host-cpp", "/usr/bin/g++"); + if(language() == Language::C) + { + tool = getConfiguration("host-cc", "/usr/bin/gcc"); + } + + return execute(tool, args, settings.verbose > 0); } int TaskLD::clean() -- cgit v1.2.3