summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-06-11 21:29:09 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-06-11 21:29:09 +0200
commitee825bf2e966a1b565473753adb3f2b74f6d0ce4 (patch)
tree1c88ce85788c1678f0946d880b0a3737c592e9d7
parent6e3070181fadbe47511b52c12af5e1409a9a70b0 (diff)
Flags'n'stuff
-rw-r--r--cppbuild.cc8
-rw-r--r--libcppbuild.cc15
-rw-r--r--task.cc7
-rw-r--r--task.h3
4 files changed, 25 insertions, 8 deletions
diff --git a/cppbuild.cc b/cppbuild.cc
index b06b082..275512f 100644
--- a/cppbuild.cc
+++ b/cppbuild.cc
@@ -14,6 +14,12 @@ BuildConfiguration configs()
// source files
"src/foo.cc",
"src/bar.cc",
- }
+ },
+ // cxx flags
+ "-g -Wall -Werror -std=c++17",
+ // c flags
+ "-g -Wall -Werror",
+ // linker flags
+ "-lm",
};
}
diff --git a/libcppbuild.cc b/libcppbuild.cc
index 46f1bfc..35eff8f 100644
--- a/libcppbuild.cc
+++ b/libcppbuild.cc
@@ -11,20 +11,23 @@
int main(int argc, const char* argv[])
{
Settings settings;
+
+ // TODO: Set from commandline
settings.builddir = "build/foo";
+
std::filesystem::path builddir(settings.builddir);
std::filesystem::create_directories(builddir);
- auto project = configs();
- std::string output = builddir / project.target;
- const auto& files = project.sources;
+ auto config = configs();
+ std::string output = builddir / config.target;
+ const auto& files = config.sources;
std::vector<std::string> objects;
std::vector<Task> tasks;
for(const auto& file : files)
{
- tasks.emplace_back(project, settings, file);
+ tasks.emplace_back(config, settings, file);
objects.push_back(tasks.back().targetFile);
}
@@ -91,7 +94,9 @@ int main(int argc, const char* argv[])
{
objectlist += object + " ";
}
- std::string compiler = "g++ " + objectlist + " -o " + output;
+ std::string compiler = "g++ " + objectlist + " " +
+ config.ldflags + " " +
+ "-o " + output;
std::cout << compiler << "\n";
if(system(compiler.data()))
{
diff --git a/task.cc b/task.cc
index 0b4240f..19e4712 100644
--- a/task.cc
+++ b/task.cc
@@ -84,6 +84,8 @@ std::vector<std::string> readDeps(const std::string& depFile)
Task::Task(const BuildConfiguration& config, const Settings& settings,
const std::string& source)
+ : config(config)
+ , settings(settings)
{
sourceFile = source;
targetFile = settings.builddir / sourceFile.stem();
@@ -155,8 +157,9 @@ void Task::start()
if(recompile)
{
std::string cmd =
- "g++ -MMD -c " + std::string(sourceFile) +
- " -o " + std::string(targetFile);
+ "g++ -MMD -c " + std::string(sourceFile) + " " +
+ config.cxxflags + " " +
+ "-o " + std::string(targetFile);
std::cout << cmd << "\n";
if(system(cmd.data()))
diff --git a/task.h b/task.h
index d788645..ac56e8a 100644
--- a/task.h
+++ b/task.h
@@ -29,4 +29,7 @@ public:
std::filesystem::path depsFile;
std::future<int> future;
+
+ const BuildConfiguration& config;
+ const Settings& settings;
};