summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/configure.cc2
-rw-r--r--src/execute.cc9
-rw-r--r--src/execute.h9
-rw-r--r--src/rebuild.cc4
-rw-r--r--src/task_ar.cc2
-rw-r--r--src/task_cc.cc3
-rw-r--r--src/task_ld.cc7
-rw-r--r--src/task_ld.h4
-rw-r--r--src/task_so.cc3
-rw-r--r--src/tasks.cc7
-rw-r--r--src/tasks.h3
-rw-r--r--src/unittest.cc2
12 files changed, 36 insertions, 19 deletions
diff --git a/src/configure.cc b/src/configure.cc
index c08ed88..4b2fbf0 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -915,5 +915,5 @@ int reconfigure(const ctor::settings& global_settings, int argc, char* argv[])
return 0; // this was originally invoked by configure, don't loop
}
- return execute(argv[0], args);
+ return execute(settings, argv[0], args);
}
diff --git a/src/execute.cc b/src/execute.cc
index b4013d0..94a3d73 100644
--- a/src/execute.cc
+++ b/src/execute.cc
@@ -3,6 +3,8 @@
// See accompanying file LICENSE for details.
#include "execute.h"
+#include "ctor.h"
+
#include <unistd.h>
#include <cstring>
#include <sys/types.h>
@@ -57,10 +59,11 @@ int parent_waitpid(pid_t pid)
extern char **environ; // see 'man environ'
-int execute(const std::string& command,
+int execute(const ctor::settings& settings,
+ const std::string& command,
const std::vector<std::string>& args,
const std::map<std::string, std::string>& env,
- bool verbose)
+ [[maybe_unused]] bool terminate)
{
std::vector<const char*> argv;
argv.push_back(command.data());
@@ -84,7 +87,7 @@ int execute(const std::string& command,
cmd += arg;
}
- if(verbose)
+ if(settings.verbose)
{
std::cout << cmd << std::endl;
}
diff --git a/src/execute.h b/src/execute.h
index 336c3ef..4288bb7 100644
--- a/src/execute.h
+++ b/src/execute.h
@@ -7,7 +7,12 @@
#include <vector>
#include <map>
-int execute(const std::string& command,
+namespace ctor {
+struct settings;
+}//ctor::
+
+int execute(const ctor::settings& settings,
+ const std::string& command,
const std::vector<std::string>& args = {},
const std::map<std::string, std::string>& env = {},
- bool verbose = true);
+ bool terminate = false);
diff --git a/src/rebuild.cc b/src/rebuild.cc
index 76fcbef..460bbfb 100644
--- a/src/rebuild.cc
+++ b/src/rebuild.cc
@@ -225,7 +225,7 @@ bool recompileCheck(const ctor::settings& global_settings, int argc, char* argv[
}
}
- auto tasks = taskFactory({config}, settings, {});
+ auto tasks = taskFactory({config}, settings, {}, true);
for(auto task : tasks)
{
@@ -270,7 +270,7 @@ bool recompileCheck(const ctor::settings& global_settings, int argc, char* argv[
{
args.push_back(argv[i]);
}
- auto ret = execute(argv[0], args);
+ auto ret = execute(settings, argv[0], args);
//if(ret != 0)
{
exit(ret);
diff --git a/src/task_ar.cc b/src/task_ar.cc
index 19a65ae..b15ad4e 100644
--- a/src/task_ar.cc
+++ b/src/task_ar.cc
@@ -120,7 +120,7 @@ int TaskAR::runInner()
break;
}
- return execute(tool, args, {}, settings.verbose > 0);
+ return execute(settings, tool, args, c.env);
}
int TaskAR::clean()
diff --git a/src/task_cc.cc b/src/task_cc.cc
index 4eb07ae..dabeefa 100644
--- a/src/task_cc.cc
+++ b/src/task_cc.cc
@@ -193,7 +193,8 @@ int TaskCC::runInner()
targetFile().lexically_normal().string() << std::endl;
}
- return execute(compiler(), args, {}, settings.verbose > 0);
+ const auto& cfg = ctor::get_configuration();
+ return execute(settings, compiler(), args, cfg.env);
}
int TaskCC::clean()
diff --git a/src/task_ld.cc b/src/task_ld.cc
index b0aa4ae..dc1006a 100644
--- a/src/task_ld.cc
+++ b/src/task_ld.cc
@@ -15,11 +15,13 @@ TaskLD::TaskLD(const ctor::build_configuration& config,
const ctor::settings& settings,
const std::string& target,
const std::vector<std::string>& objects,
- const std::string& sourceDir)
+ const std::string& sourceDir,
+ bool is_self)
: Task(config, settings, sourceDir)
, config(config)
, settings(settings)
, sourceDir(sourceDir)
+ , is_self(is_self)
{
target_type = config.type;
output_system = config.system;
@@ -125,7 +127,8 @@ int TaskLD::runInner()
}
auto tool = compiler();
- return execute(tool, args, {}, settings.verbose > 0);
+ const auto& c = ctor::get_configuration();
+ return execute(settings, tool, args, c.env, is_self);
}
int TaskLD::clean()
diff --git a/src/task_ld.h b/src/task_ld.h
index dbe7db1..c0e3ebb 100644
--- a/src/task_ld.h
+++ b/src/task_ld.h
@@ -18,7 +18,8 @@ public:
const ctor::settings& settings,
const std::string& target,
const std::vector<std::string>& objects,
- const std::string& _sourceDir);
+ const std::string& _sourceDir,
+ bool is_self);
virtual ~TaskLD() = default;
bool dirtyInner() override;
@@ -44,4 +45,5 @@ private:
const ctor::build_configuration& config;
const ctor::settings& settings;
std::string sourceDir;
+ bool is_self;
};
diff --git a/src/task_so.cc b/src/task_so.cc
index ba96388..25839c5 100644
--- a/src/task_so.cc
+++ b/src/task_so.cc
@@ -114,7 +114,8 @@ int TaskSO::runInner()
}
auto tool = compiler();
- return execute(tool, args, {}, settings.verbose > 0);
+ const auto& cfg = ctor::get_configuration();
+ return execute(settings, tool, args, cfg.env);
}
int TaskSO::clean()
diff --git a/src/tasks.cc b/src/tasks.cc
index 61c130b..a4c455b 100644
--- a/src/tasks.cc
+++ b/src/tasks.cc
@@ -72,7 +72,8 @@ const std::deque<Target>& getTargets(const ctor::settings& settings,
std::vector<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& config,
const ctor::settings& settings,
- const std::string& sourceDir)
+ const std::string& sourceDir,
+ bool is_self)
{
std::vector<std::shared_ptr<Task>> tasks;
@@ -145,7 +146,7 @@ std::vector<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration&
case ctor::target_type::executable:
case ctor::target_type::unit_test:
tasks.push_back(std::make_shared<TaskLD>(config, settings, config.target,
- objects, sourceDir));
+ objects, sourceDir, is_self));
break;
case ctor::target_type::object:
@@ -192,7 +193,7 @@ std::vector<std::shared_ptr<Task>> getTasks(const ctor::settings& settings,
std::find(std::begin(names), std::end(names), target.config.target) != std::end(names))
{
std::vector<std::string> objects;
- auto t = taskFactory(target.config, settings, target.path);
+ auto t = taskFactory(target.config, settings, target.path, false);
tasks.insert(tasks.end(), t.begin(), t.end());
}
}
diff --git a/src/tasks.h b/src/tasks.h
index cc34f56..6573784 100644
--- a/src/tasks.h
+++ b/src/tasks.h
@@ -36,4 +36,5 @@ std::vector<std::shared_ptr<Task>> getTasks(const ctor::settings& settings,
//! link target and all its objects files (if any).
std::vector<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& config,
const ctor::settings& settings,
- const std::string& sourceDir);
+ const std::string& sourceDir,
+ bool is_self);
diff --git a/src/unittest.cc b/src/unittest.cc
index 9e85187..b95a931 100644
--- a/src/unittest.cc
+++ b/src/unittest.cc
@@ -24,7 +24,7 @@ int runUnitTests(std::vector<std::shared_ptr<Task>>& tasks,
name = task->target();
}
std::cout << name << ": " << std::flush;
- auto ret = execute(task->targetFile(), {}, {}, settings.verbose > 0);
+ auto ret = execute(settings, task->targetFile().string(), {}, {});
ok &= ret == 0;
if(ret == 0)
{