public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* [gentoo-dev] [PATCH 2/2] toolchain-funcs.eclass: Add helpful tc-is-{gcc,clang} wrappers
  @ 2016-06-23  9:18 99%   ` Michał Górny
  0 siblings, 0 replies; 1+ results
From: Michał Górny @ 2016-06-23  9:18 UTC (permalink / raw
  To: gentoo-dev; +Cc: toolchain, Michał Górny

---
 eclass/tests/toolchain-funcs.sh | 28 ++++++++++++++++++++++++++++
 eclass/toolchain-funcs.eclass   | 14 ++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index 0b9b7d7..d86eee4 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -118,6 +118,20 @@ export CC=gcc
 )
 tend $?
 
+tbegin "tc-is-gcc (gcc)"
+(
+export CC=gcc
+tc-is-gcc
+)
+tend $?
+
+tbegin "! tc-is-clang (gcc)"
+(
+export CC=gcc
+! tc-is-clang
+)
+tend $?
+
 if type -P clang &>/dev/null; then
 	tbegin "tc-get-compiler-type (clang)"
 	(
@@ -125,6 +139,20 @@ if type -P clang &>/dev/null; then
 	[[ $(tc-get-compiler-type) == clang ]]
 	)
 	tend $?
+
+	tbegin "! tc-is-gcc (clang)"
+	(
+	export CC=clang
+	! tc-is-gcc
+	)
+	tend $?
+
+	tbegin "tc-is-clang (clang)"
+	(
+	export CC=clang
+	tc-is-clang
+	)
+	tend $?
 fi
 
 texit
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 4a45f78..67eab38 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -604,6 +604,20 @@ tc-get-compiler-type() {
 	esac
 }
 
+# @FUNCTION: tc-is-gcc
+# @DESCRIPTION:
+# Return true if the current compiler is pure GCC.
+tc-is-gcc() {
+	[[ $(tc-get-compiler-type) == gcc ]]
+}
+
+# @FUNCTION: tc-is-clang
+# @DESCRIPTION:
+# Return true if the current compiler is clang.
+tc-is-clang() {
+	[[ $(tc-get-compiler-type) == clang ]]
+}
+
 # Internal func.  The first argument is the version info to expand.
 # Query the preprocessor to improve compatibility across different
 # compilers rather than maintaining a --version flag matrix. #335943
-- 
2.9.0



^ permalink raw reply related	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-06-22 20:06     [gentoo-dev] [PATCH 0/4] toolchain-funcs.eclass: fix for version checks (v2) + compiler identification Michał Górny
2016-06-23  9:18     ` [gentoo-dev] [PATCH 0/2] v3: tc-get-compiler-type() & wrappers Michał Górny
2016-06-23  9:18 99%   ` [gentoo-dev] [PATCH 2/2] toolchain-funcs.eclass: Add helpful tc-is-{gcc,clang} wrappers Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox