build_test.py: set env vars for cross compile

Now that minijail-sys is added a simple run of ./build_test fails with
messages like:

error: failed to run custom build command for `minijail-sys v0.0.11
(/mnt/host/source/src/aosp/external/minijail)`

thread 'main' panicked at 'called `Result::unwrap()` on an `Err`
value: CrossCompilation', src/libcore/result.rs:1165:5

This change adds various environment variables to address the problem.

BUG=None
TEST=./build_test.py --arm-sysroot /build/cheza/ --aarch64-sysroot /build/kevin64/

Change-Id: Iba15ceafa35ba3ab2d08dc5827af3cb8ee07530c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2064821
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Matt Delco <delco@chromium.org>
This commit is contained in:
Matt Delco 2020-02-19 12:24:43 -08:00 committed by Commit Bot
parent 2647a1916d
commit 4f48eab602

View file

@ -160,10 +160,20 @@ def check_build(sysroot, triple, kind, test_it, clean):
is_release = kind == 'release' is_release = kind == 'release'
# The pkgconfig dir could be in either lib or lib64 depending on the target.
# Rather than checking to see which one is valid, just add both and let
# pkg-config search.
libdir = os.path.join(sysroot, 'usr', 'lib', 'pkgconfig')
lib64dir = os.path.join(sysroot, 'usr', 'lib64', 'pkgconfig')
env = os.environ.copy() env = os.environ.copy()
env['TARGET_CC'] = '%s-clang'%triple env['TARGET_CC'] = '%s-clang'%triple
env['SYSROOT'] = sysroot env['SYSROOT'] = sysroot
env['CARGO_TARGET_DIR'] = target_path env['CARGO_TARGET_DIR'] = target_path
env['PKG_CONFIG_ALLOW_CROSS'] = '1'
env['PKG_CONFIG_LIBDIR'] = libdir + ':' + lib64dir
env['PKG_CONFIG_SYSROOT_DIR'] = sysroot
env['RUSTFLAGS'] = '-C linker=' + env['TARGET_CC']
if test_it: if test_it:
if not test_target(triple, is_release, env): if not test_target(triple, is_release, env):