* [gentoo-dev] [PATCH 1/2] toolchain-funcs.eclass: rework _tc-getPROG to accept a colon-separated list of default programs
@ 2017-06-01 18:03 Mike Gilbert
2017-06-01 18:03 ` [gentoo-dev] [PATCH 2/2] toolchain-funcs.eclass: use gcc-{ar,nm,ranlib} when available Mike Gilbert
0 siblings, 1 reply; 2+ messages in thread
From: Mike Gilbert @ 2017-06-01 18:03 UTC (permalink / raw
To: gentoo-dev; +Cc: toolchain
---
eclass/toolchain-funcs.eclass | 39 +++++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index a0c359a950b2..b402a9ff2780 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -17,12 +17,13 @@ _TOOLCHAIN_FUNCS_ECLASS=1
inherit multilib
-# tc-getPROG <VAR [search vars]> <default> [tuple]
+# tc-getPROG <VAR [search vars]> [prog:...]<default> [tuple]
_tc-getPROG() {
- local tuple=$1
- local v var vars=$2
- local prog=( $3 )
+ local IFS
+ IFS='
+'
+ local v var vars=$2
var=${vars%% *}
for v in ${vars} ; do
if [[ -n ${!v} ]] ; then
@@ -32,10 +33,32 @@ _tc-getPROG() {
fi
done
- local search=
- [[ -n $4 ]] && search=$(type -p $4-${prog[0]})
- [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]})
- [[ -n ${search} ]] && prog[0]=${search##*/}
+ local tuple=$4
+ [[ -z ${tuple} ]] && tuple=${!1}
+
+ IFS=:
+ local proglist=( $3 )
+
+ IFS='
+'
+ local p prog search=
+ for p in "${proglist[@]}"; do
+ # Look for tuple-prog first
+ prog=( ${p} )
+ search=$(type -p "${tuple}-${prog[0]}")
+ if [[ -n ${search} ]]; then
+ prog[0]="${tuple}-${prog[0]}"
+ break
+ fi
+ done
+ if [[ -z ${search} ]]; then
+ # Then try prog with no prefix
+ for p in "${proglist[@]}"; do
+ prog=( ${p} )
+ search=$(type -p "${prog[0]}")
+ [[ -n ${search} ]] && break
+ done
+ fi
export ${var}="${prog[*]}"
echo "${!var}"
--
2.13.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-dev] [PATCH 2/2] toolchain-funcs.eclass: use gcc-{ar,nm,ranlib} when available
2017-06-01 18:03 [gentoo-dev] [PATCH 1/2] toolchain-funcs.eclass: rework _tc-getPROG to accept a colon-separated list of default programs Mike Gilbert
@ 2017-06-01 18:03 ` Mike Gilbert
0 siblings, 0 replies; 2+ messages in thread
From: Mike Gilbert @ 2017-06-01 18:03 UTC (permalink / raw
To: gentoo-dev; +Cc: toolchain
This will come in handy for users who enable LTO, since they need to use
the gcc wrappers for 'ar', 'nm', and 'ranlib'.
The default program search order becomes:
${CHOST}-gcc-ar
${CHOST}-ar
gcc-ar
ar
This matches the behavior of a typical autoconf call:
AC_CHECK_TOOLS(AR, [gcc-ar ar])
---
eclass/toolchain-funcs.eclass | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index b402a9ff2780..d1f9ac019362 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -69,7 +69,7 @@ tc-getPROG() { _tc-getPROG CHOST "$@"; }
# @FUNCTION: tc-getAR
# @USAGE: [toolchain prefix]
# @RETURN: name of the archiver
-tc-getAR() { tc-getPROG AR ar "$@"; }
+tc-getAR() { tc-getPROG AR gcc-ar:ar "$@"; }
# @FUNCTION: tc-getAS
# @USAGE: [toolchain prefix]
# @RETURN: name of the assembler
@@ -97,11 +97,11 @@ tc-getSTRIP() { tc-getPROG STRIP strip "$@"; }
# @FUNCTION: tc-getNM
# @USAGE: [toolchain prefix]
# @RETURN: name of the symbol/object thingy
-tc-getNM() { tc-getPROG NM nm "$@"; }
+tc-getNM() { tc-getPROG NM gcc-nm:nm "$@"; }
# @FUNCTION: tc-getRANLIB
# @USAGE: [toolchain prefix]
# @RETURN: name of the archiver indexer
-tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; }
+tc-getRANLIB() { tc-getPROG RANLIB gcc-ranlib:ranlib "$@"; }
# @FUNCTION: tc-getOBJCOPY
# @USAGE: [toolchain prefix]
# @RETURN: name of the object copier
@@ -142,7 +142,7 @@ tc-getDLLWRAP() { tc-getPROG DLLWRAP dllwrap "$@"; }
# @FUNCTION: tc-getBUILD_AR
# @USAGE: [toolchain prefix]
# @RETURN: name of the archiver for building binaries to run on the build machine
-tc-getBUILD_AR() { tc-getBUILD_PROG AR ar "$@"; }
+tc-getBUILD_AR() { tc-getBUILD_PROG AR gcc-ar:ar "$@"; }
# @FUNCTION: tc-getBUILD_AS
# @USAGE: [toolchain prefix]
# @RETURN: name of the assembler for building binaries to run on the build machine
@@ -170,11 +170,11 @@ tc-getBUILD_STRIP() { tc-getBUILD_PROG STRIP strip "$@"; }
# @FUNCTION: tc-getBUILD_NM
# @USAGE: [toolchain prefix]
# @RETURN: name of the symbol/object thingy for building binaries to run on the build machine
-tc-getBUILD_NM() { tc-getBUILD_PROG NM nm "$@"; }
+tc-getBUILD_NM() { tc-getBUILD_PROG NM gcc-nm:nm "$@"; }
# @FUNCTION: tc-getBUILD_RANLIB
# @USAGE: [toolchain prefix]
# @RETURN: name of the archiver indexer for building binaries to run on the build machine
-tc-getBUILD_RANLIB() { tc-getBUILD_PROG RANLIB ranlib "$@"; }
+tc-getBUILD_RANLIB() { tc-getBUILD_PROG RANLIB gcc-ranlib:ranlib "$@"; }
# @FUNCTION: tc-getBUILD_OBJCOPY
# @USAGE: [toolchain prefix]
# @RETURN: name of the object copier for building binaries to run on the build machine
--
2.13.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-01 18:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-01 18:03 [gentoo-dev] [PATCH 1/2] toolchain-funcs.eclass: rework _tc-getPROG to accept a colon-separated list of default programs Mike Gilbert
2017-06-01 18:03 ` [gentoo-dev] [PATCH 2/2] toolchain-funcs.eclass: use gcc-{ar,nm,ranlib} when available Mike Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox