summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2018-05-10 16:58:04 +0200
committerMichał Górny <mgorny@gentoo.org>2018-05-10 16:58:04 +0200
commit8d84853f961adef853a34680c4659dca096fa083 (patch)
treeb720eea512abd5b131f36bf0d66ed21195904341 /dev-util/scons
parentapp-portage/elogviewer: Drop old (diff)
downloadgentoo-8d84853f961adef853a34680c4659dca096fa083.tar.gz
gentoo-8d84853f961adef853a34680c4659dca096fa083.tar.bz2
gentoo-8d84853f961adef853a34680c4659dca096fa083.zip
dev-util/scons: Try to force CC/CXX/CFLAGS/... for Gentoo builds
Diffstat (limited to 'dev-util/scons')
-rw-r--r--dev-util/scons/files/scons-3.0.1-respect-cc-etc.patch85
-rw-r--r--dev-util/scons/scons-3.0.1-r2.ebuild73
2 files changed, 158 insertions, 0 deletions
diff --git a/dev-util/scons/files/scons-3.0.1-respect-cc-etc.patch b/dev-util/scons/files/scons-3.0.1-respect-cc-etc.patch
new file mode 100644
index 000000000000..345f39ca548e
--- /dev/null
+++ b/dev-util/scons/files/scons-3.0.1-respect-cc-etc.patch
@@ -0,0 +1,85 @@
+From 7dca875d157f477e05a652f4f1dd1b6903d9dc0a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Thu, 10 May 2018 08:01:08 +0200
+Subject: [PATCH] posix: Also force common toolchain vars for Gentoo
+
+---
+ src/engine/SCons/Platform/posix.py | 17 +++++++++++++++++
+ src/engine/SCons/Tool/cc.py | 3 ++-
+ src/engine/SCons/Tool/cxx.py | 3 ++-
+ src/engine/SCons/Tool/link.py | 3 ++-
+ 4 files changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py
+index af34650c..ee7f96d5 100644
+--- a/src/engine/SCons/Platform/posix.py
++++ b/src/engine/SCons/Platform/posix.py
+@@ -93,6 +93,23 @@ def generate(env):
+ if 'ENV' in env:
+ new_env.update(env['ENV'])
+ env['ENV'] = new_env
++
++ # Furthermore, force common compiler/linker variables as well
++ envvar_mapping = {
++ 'AR': 'AR',
++ 'AS': 'AS',
++ 'AS': 'ASFLAGS',
++ 'CC': 'CC',
++ 'CXX': 'CXX',
++ 'CFLAGS': 'CFLAGS',
++ 'CXXFLAGS': 'CXXFLAGS',
++ 'CPPFLAGS': 'CPPFLAGS',
++ 'LDFLAGS': 'LINKFLAGS',
++ }
++
++ for envvar, toolvar in envvar_mapping.items():
++ if toolvar not in env and envvar in env['ENV']:
++ env[toolvar] = env['ENV'][envvar]
+ else:
+ if 'ENV' not in env:
+ env['ENV'] = {}
+diff --git a/src/engine/SCons/Tool/cc.py b/src/engine/SCons/Tool/cc.py
+index 590ec5fd..5f9229a0 100644
+--- a/src/engine/SCons/Tool/cc.py
++++ b/src/engine/SCons/Tool/cc.py
+@@ -80,7 +80,8 @@ def generate(env):
+
+ if 'CC' not in env:
+ env['CC'] = env.Detect(compilers) or compilers[0]
+- env['CFLAGS'] = SCons.Util.CLVar('')
++ if 'CFLAGS' not in env:
++ env['CFLAGS'] = SCons.Util.CLVar('')
+ env['CCCOM'] = '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
+ env['SHCC'] = '$CC'
+ env['SHCFLAGS'] = SCons.Util.CLVar('$CFLAGS')
+diff --git a/src/engine/SCons/Tool/cxx.py b/src/engine/SCons/Tool/cxx.py
+index 430851c8..ca5ab563 100644
+--- a/src/engine/SCons/Tool/cxx.py
++++ b/src/engine/SCons/Tool/cxx.py
+@@ -74,7 +74,8 @@ def generate(env):
+
+ if 'CXX' not in env:
+ env['CXX'] = env.Detect(compilers) or compilers[0]
+- env['CXXFLAGS'] = SCons.Util.CLVar('')
++ if 'CXXFLAGS' not in env:
++ env['CXXFLAGS'] = SCons.Util.CLVar('')
+ env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
+ env['SHCXX'] = '$CXX'
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py
+index 07e92507..614d1779 100644
+--- a/src/engine/SCons/Tool/link.py
++++ b/src/engine/SCons/Tool/link.py
+@@ -292,7 +292,8 @@ def generate(env):
+ env.Append(SHLIBEMITTER = [shlib_emitter])
+ env['SMARTLINK'] = smart_link
+ env['LINK'] = "$SMARTLINK"
+- env['LINKFLAGS'] = SCons.Util.CLVar('')
++ if 'LINKFLAGS' not in env:
++ env['LINKFLAGS'] = SCons.Util.CLVar('')
+ # __RPATH is only set to something ($_RPATH typically) on platforms that support it.
+ env['LINKCOM'] = '$LINK -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
+ env['LIBDIRPREFIX']='-L'
+--
+2.17.0
+
diff --git a/dev-util/scons/scons-3.0.1-r2.ebuild b/dev-util/scons/scons-3.0.1-r2.ebuild
new file mode 100644
index 000000000000..78842609b21e
--- /dev/null
+++ b/dev-util/scons/scons-3.0.1-r2.ebuild
@@ -0,0 +1,73 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+PYTHON_COMPAT=( python2_7 )
+PYTHON_REQ_USE="threads(+)"
+
+inherit distutils-r1
+
+DESCRIPTION="Extensible Python-based build utility"
+HOMEPAGE="http://www.scons.org/"
+SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz
+ doc? (
+ http://www.scons.org/doc/${PV}/PDF/${PN}-user.pdf -> ${P}-user.pdf
+ http://www.scons.org/doc/${PV}/HTML/${PN}-user.html -> ${P}-user.html
+ )
+ test? ( https://github.com/scons/scons/archive/${PV}.tar.gz -> ${P}.gh.tar.gz )"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
+IUSE="doc test"
+
+S=${WORKDIR}/${P}/src
+
+PATCHES=(
+ # support env passthrough for Gentoo ebuilds
+ "${FILESDIR}"/scons-3.0.1-env-passthrough.patch
+ # respect CC, CXX, C*FLAGS, LDFLAGS by default
+ "${FILESDIR}"/scons-3.0.1-respect-cc-etc.patch
+)
+
+src_unpack() {
+ # use the git directory structure, but put pregenerated release
+ # inside src/ subdirectory to make our life easier
+ if use test; then
+ unpack "${P}.gh.tar.gz"
+ rm -r "${P}/src" || die
+ else
+ mkdir "${P}" || die
+ fi
+
+ cd "${P}" || die
+ unpack "${P}.tar.gz"
+ mv "${P}" src || die
+}
+
+src_prepare() {
+ # apply patches relatively to top directory
+ cd "${WORKDIR}/${P}" || die
+ distutils-r1_src_prepare
+
+ # remove half-broken, useless custom commands
+ # and fix manpage install location
+ sed -i -e '/cmdclass/,/}$/d' \
+ -e '/data_files/s:man/:share/man/:' "${S}"/setup.py || die
+}
+
+python_test() {
+ cd "${WORKDIR}/${P}" || die
+ "${EPYTHON}" runtest.py -as \
+ -j "$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")" \
+ --builddir "${BUILD_DIR}/lib" ||
+ die "Tests fail with ${EPYTHON}"
+}
+
+python_install_all() {
+ local DOCS=( {CHANGES,README,RELEASE}.txt )
+ distutils-r1_python_install_all
+ rm "${ED%/}/usr/bin/scons.bat" || die
+
+ use doc && dodoc "${DISTDIR}"/${P}-user.{pdf,html}
+}