www-client/chromium: wire-up cross-compile support

Cross-compiling still does not work, but this gets us closer.

- Build GN with the host (CBUILD) compiler, skip rebuild after bootstrap.
- Add a toolchain definition for the host (CBUILD) compiler.
- Set the host_toolchain option.
- Set the target_cpu option based on the target arch (CHOST).

The host_toolchain option is also set for native builds. This makes
clang work without setting clang_base_path.

Package-Manager: Portage-2.3.6_p7, Repoman-2.3.2_p75
This commit is contained in:
Mike Gilbert
2017-06-19 01:01:05 -04:00
parent be7285a362
commit 2dd4eba091
2 changed files with 50 additions and 15 deletions
+32 -15
View File
@@ -333,6 +333,22 @@ src_prepare() {
build/linux/unbundle/remove_bundled_libraries.py "${keeplibs[@]}" --do-remove || die
}
bootstrap_gn() {
if tc-is-cross-compiler; then
local -x AR=${BUILD_AR}
local -x CC=${BUILD_CC}
local -x CXX=${BUILD_CXX}
local -x NM=${BUILD_NM}
local -x CFLAGS=${BUILD_CFLAGS}
local -x CXXFLAGS=${BUILD_CXXFLAGS}
local -x LDFLAGS=${BUILD_LDFLAGS}
fi
einfo "Building GN..."
set -- tools/gn/bootstrap/bootstrap.py -s -v --no-clean
echo "$@"
"$@" || die
}
src_configure() {
local myconf_gn=""
@@ -398,7 +414,6 @@ src_configure() {
if tc-is-clang; then
myconf_gn+=" is_clang=true clang_use_chrome_plugins=false"
myconf_gn+=" clang_base_path=\"$(realpath $(dirname `which clang`)/..)\""
else
myconf_gn+=" is_clang=false"
fi
@@ -425,16 +440,16 @@ src_configure() {
local myarch="$(tc-arch)"
if [[ $myarch = amd64 ]] ; then
target_arch=x64
myconf_gn+=" target_cpu=\"x64\""
ffmpeg_target_arch=x64
elif [[ $myarch = x86 ]] ; then
target_arch=ia32
myconf_gn+=" target_cpu=\"x86\""
ffmpeg_target_arch=ia32
elif [[ $myarch = arm64 ]] ; then
target_arch=arm64
myconf_gn+=" target_cpu=\"arm64\""
ffmpeg_target_arch=arm64
elif [[ $myarch = arm ]] ; then
target_arch=arm
myconf_gn+=" target_cpu=\"arm\""
ffmpeg_target_arch=$(usex neon arm-neon arm)
else
die "Failed to determine target arch, got '$myarch'."
@@ -467,20 +482,19 @@ src_configure() {
# Make sure the build system will use the right tools, bug #340795.
tc-export AR CC CXX NM
# https://bugs.gentoo.org/588596
append-cxxflags $(test-flags-CXX -fno-delete-null-pointer-checks)
# Define a custom toolchain for GN
myconf_gn+=" custom_toolchain=\"${FILESDIR}/toolchain:default\""
# Tools for building programs to be executed on the build system, bug #410883.
if tc-is-cross-compiler; then
export AR_host=$(tc-getBUILD_AR)
export CC_host=$(tc-getBUILD_CC)
export CXX_host=$(tc-getBUILD_CXX)
export NM_host=$(tc-getBUILD_NM)
tc-export BUILD_{AR,CC,CXX,NM}
myconf_gn+=" host_toolchain=\"${FILESDIR}/toolchain:host\""
else
myconf_gn+=" host_toolchain=\"${FILESDIR}/toolchain:default\""
fi
# https://bugs.gentoo.org/588596
append-cxxflags $(test-flags-CXX -fno-delete-null-pointer-checks)
# Bug 491582.
export TMPDIR="${WORKDIR}/temp"
mkdir -p -m 755 "${TMPDIR}" || die
@@ -505,9 +519,12 @@ src_configure() {
touch chrome/test/data/webui/i18n_process_css_test.html || die
bootstrap_gn
einfo "Configuring Chromium..."
tools/gn/bootstrap/bootstrap.py -v --no-clean --gn-gen-args "${myconf_gn}" || die
out/Release/gn gen --args="${myconf_gn}" out/Release || die
set -- out/Release/gn gen --args="${myconf_gn}" out/Release
echo "$@"
"$@" || die
}
src_compile() {
@@ -17,3 +17,21 @@ gcc_toolchain("default") {
current_os = current_os
}
}
gcc_toolchain("host") {
cc = getenv("BUILD_CC")
cxx = getenv("BUILD_CXX")
ar = getenv("BUILD_AR")
nm = getenv("BUILD_NM")
ld = cxx
extra_cflags = getenv("BUILD_CFLAGS")
extra_cppflags = getenv("BUILD_CPPFLAGS")
extra_cxxflags = getenv("BUILD_CXXFLAGS")
extra_ldflags = getenv("BUILD_LDFLAGS")
toolchain_args = {
current_cpu = current_cpu
current_os = current_os
}
}