1 |
commit: 6984a5b149a215dd96a9759d3d1f251354faf38f |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jun 22 19:54:44 2016 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jun 26 15:34:47 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6984a5b1 |
7 |
|
8 |
toolchain-funcs.eclass: Add helpful tc-is-{gcc,clang} wrappers |
9 |
|
10 |
eclass/tests/toolchain-funcs.sh | 28 ++++++++++++++++++++++++++++ |
11 |
eclass/toolchain-funcs.eclass | 12 ++++++++++++ |
12 |
2 files changed, 40 insertions(+) |
13 |
|
14 |
diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh |
15 |
index 6f37996..e6a1538 100755 |
16 |
--- a/eclass/tests/toolchain-funcs.sh |
17 |
+++ b/eclass/tests/toolchain-funcs.sh |
18 |
@@ -120,6 +120,20 @@ export CC=gcc |
19 |
) |
20 |
tend $? |
21 |
|
22 |
+tbegin "tc-is-gcc (gcc)" |
23 |
+( |
24 |
+export CC=gcc |
25 |
+tc-is-gcc |
26 |
+) |
27 |
+tend $? |
28 |
+ |
29 |
+tbegin "! tc-is-clang (gcc)" |
30 |
+( |
31 |
+export CC=gcc |
32 |
+! tc-is-clang |
33 |
+) |
34 |
+tend $? |
35 |
+ |
36 |
if type -P clang &>/dev/null; then |
37 |
tbegin "tc-get-compiler-type (clang)" |
38 |
( |
39 |
@@ -127,6 +141,20 @@ if type -P clang &>/dev/null; then |
40 |
[[ $(tc-get-compiler-type) == clang ]] |
41 |
) |
42 |
tend $? |
43 |
+ |
44 |
+ tbegin "! tc-is-gcc (clang)" |
45 |
+ ( |
46 |
+ export CC=clang |
47 |
+ ! tc-is-gcc |
48 |
+ ) |
49 |
+ tend $? |
50 |
+ |
51 |
+ tbegin "tc-is-clang (clang)" |
52 |
+ ( |
53 |
+ export CC=clang |
54 |
+ tc-is-clang |
55 |
+ ) |
56 |
+ tend $? |
57 |
fi |
58 |
|
59 |
if type -P pathcc &>/dev/null; then |
60 |
|
61 |
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass |
62 |
index a29784c..d3abfb5 100644 |
63 |
--- a/eclass/toolchain-funcs.eclass |
64 |
+++ b/eclass/toolchain-funcs.eclass |
65 |
@@ -607,6 +607,18 @@ tc-get-compiler-type() { |
66 |
esac |
67 |
} |
68 |
|
69 |
+# @FUNCTION: tc-is-gcc |
70 |
+# @RETURN: Shell true if the current compiler is GCC, false otherwise. |
71 |
+tc-is-gcc() { |
72 |
+ [[ $(tc-get-compiler-type) == gcc ]] |
73 |
+} |
74 |
+ |
75 |
+# @FUNCTION: tc-is-clang |
76 |
+# @RETURN: Shell true if the current compiler is clang, false otherwise. |
77 |
+tc-is-clang() { |
78 |
+ [[ $(tc-get-compiler-type) == clang ]] |
79 |
+} |
80 |
+ |
81 |
# Internal func. The first argument is the version info to expand. |
82 |
# Query the preprocessor to improve compatibility across different |
83 |
# compilers rather than maintaining a --version flag matrix. #335943 |