summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ctor.h8
-rw-r--r--src/tools.cc6
-rw-r--r--test/tools_test.cc15
3 files changed, 23 insertions, 6 deletions
diff --git a/src/ctor.h b/src/ctor.h
index 9738949..4e0a247 100644
--- a/src/ctor.h
+++ b/src/ctor.h
@@ -122,10 +122,10 @@ enum class ld_opt
enum class ar_opt
{
// gcc/clang
- replace, // -r
- add_index, // -s
- create, // -c
- output, // <arg>
+ replace, // -r
+ add_index, // -s
+ create, // -c
+ output, // <arg>
custom, // entire option taken verbatim from <arg>
};
diff --git a/src/tools.cc b/src/tools.cc
index 6d4c34b..a83f115 100644
--- a/src/tools.cc
+++ b/src/tools.cc
@@ -109,11 +109,13 @@ ctor::toolchain getToolChain(const std::string& compiler)
auto cc_cmd = cc.stem().string();
// Note: "g++" is a substring of "clang++" so "clang++" must be tested first.
- if(cc_cmd.find("clang++") != std::string::npos)
+ if(cc_cmd.find("clang++") != std::string::npos ||
+ cc_cmd.find("clang") != std::string::npos)
{
return ctor::toolchain::clang;
}
- else if(cc_cmd.find("g++") != std::string::npos)
+ else if(cc_cmd.find("g++") != std::string::npos ||
+ cc_cmd.find("gcc") != std::string::npos)
{
return ctor::toolchain::gcc;
}
diff --git a/test/tools_test.cc b/test/tools_test.cc
index 7127b8d..a428ea1 100644
--- a/test/tools_test.cc
+++ b/test/tools_test.cc
@@ -172,9 +172,24 @@ public:
void getToolChain_test()
{
+ //
+ // gcc
+ //
+ uASSERT_EQUAL(ctor::toolchain::gcc, getToolChain("/usr/bin/gcc"));
+ uASSERT_EQUAL(ctor::toolchain::gcc, getToolChain("/usr/bin/gcc-10"));
+ uASSERT_EQUAL(ctor::toolchain::gcc, getToolChain("/usr/bin/x86_64-pc-linux-gnu-g++-9.3.0"));
+
uASSERT_EQUAL(ctor::toolchain::gcc, getToolChain("/usr/bin/g++"));
uASSERT_EQUAL(ctor::toolchain::gcc, getToolChain("/usr/bin/g++-10"));
uASSERT_EQUAL(ctor::toolchain::gcc, getToolChain("/usr/bin/x86_64-pc-linux-gnu-g++-9.3.0"));
+
+ //
+ // clang
+ //
+ uASSERT_EQUAL(ctor::toolchain::clang, getToolChain("/usr/bin/clang"));
+ uASSERT_EQUAL(ctor::toolchain::clang, getToolChain("/usr/bin/clang-16"));
+ uASSERT_EQUAL(ctor::toolchain::clang, getToolChain("/usr/lib/llvm/16/bin/i686-pc-linux-gnu-clang-16"));
+
uASSERT_EQUAL(ctor::toolchain::clang, getToolChain("/usr/bin/clang++"));
uASSERT_EQUAL(ctor::toolchain::clang, getToolChain("/usr/bin/clang++-16"));
uASSERT_EQUAL(ctor::toolchain::clang, getToolChain("/usr/lib/llvm/16/bin/i686-pc-linux-gnu-clang++-16"));