summaryrefslogtreecommitdiff
path: root/src/tools.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2022-07-10 17:24:16 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2022-07-15 10:11:05 +0200
commitae1871ca0ffcac3e8bd337f8d8bb4e7fd6c59295 (patch)
treed15df8a03fab6bdacebb6ba53c8ad30c290781fc /src/tools.h
parent2a55edcc40372403fb2de8ed20ed5c44464d416e (diff)
Make tools abstraction around compiler options to better support tool agnostic arguments.
Diffstat (limited to 'src/tools.h')
-rw-r--r--src/tools.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/tools.h b/src/tools.h
new file mode 100644
index 0000000..39118d2
--- /dev/null
+++ b/src/tools.h
@@ -0,0 +1,52 @@
+// -*- c++ -*-
+// Distributed under the BSD 2-Clause License.
+// See accompanying file LICENSE for details.
+#pragma once
+
+#include <vector>
+#include <string>
+
+#include "libctor.h"
+
+enum class ToolChain
+{
+ gcc,
+ clang,
+};
+
+enum class opt
+{
+ // gcc/clang
+ output, // -o
+ debug, // -g
+ strip, // -s
+ warn_all, // -Wall
+ warnings_as_errors, // -Werror
+ generate_dep_tree, // -MMD
+ no_link, // -c
+ include_path, // -I<arg>
+ library_path, // -L<arg>
+ link, // -l<arg>
+ cpp_std, // -std=<arg>
+ build_shared, // -shared
+ threads, // -pthread
+ optimization, // -O<arg>
+ position_independent_code, // -fPIC
+ position_independent_executable, // -fPIE
+ custom, // entire option taken verbatim from <arg>
+};
+
+//! Get tool-chain type from output system (via configuration)
+ToolChain getToolChain(OutputSystem system);
+
+//! Get tool argument(s) for specific option type matching the supplied
+//! tool-chain
+std::vector<std::string> getOption(ToolChain tool_chain,
+ opt option,
+ const std::string& arg = {});
+
+//! Get opt enum value and argument from string,
+//! ie. { opt::InludePath, "foo/bar" } from "-Ifoo/bar"
+//! Returns { opt::Custom, flag } if unknown.
+std::pair<opt, std::string> getOption(const std::string& flag,
+ ToolChain tool_chain = ToolChain::gcc);