summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2015-10-02 16:56:24 -0400
committerMike Frysinger <vapier@google.com>2015-10-03 00:38:15 -0400
commit3b1b415bdfa467f9a736517dff2be072feb7425e (patch)
tree201228ebb47f0a9c65b3d87876c0757238872db9
parent43cac7ddd56461903d4f0e4f129fbdeef3753566 (diff)
downloadintegration-3b1b415bdfa467f9a736517dff2be072feb7425e.tar.gz
toolchain: add wrapper logic
The way android builds things is via relative paths everywhere and with the working directory of the top level checkout. When we go to build external packages though, they often need to be in a different working directory which means all of the relative paths break. Add a compiler wrapper to merge the existing android env vars and the relative paths to create absolute paths we can leverage. Further, android will pass flags to the system paths during compile and link. If those aren't used, then the build/link will fail in weird ways. Unfortunately, some build systems might filter/sort flags, so add those to the wrapper too rather than try and track down/fix every build system. BUG=24611334 TEST=built packages and they worked in qemu Change-Id: I93432c7ed23941cd44d799e7a8bdb83d745d1952
-rw-r--r--toolchain/3rd-party-compiler.in8
-rw-r--r--toolchain/Android.mk25
2 files changed, 33 insertions, 0 deletions
diff --git a/toolchain/3rd-party-compiler.in b/toolchain/3rd-party-compiler.in
new file mode 100644
index 0000000..ef8e708
--- /dev/null
+++ b/toolchain/3rd-party-compiler.in
@@ -0,0 +1,8 @@
+#!/bin/sh
+exec \
+ "${ANDROID_TOOLCHAIN}/@CC@" \
+ @CFLAGS@ \
+ @LDFLAGS@ \
+ --sysroot "${ANDROID_PRODUCT_OUT}/@ROOT_SUBDIR@" \
+ -Wl,-rpath,/system/usr/lib \
+ "$@"
diff --git a/toolchain/Android.mk b/toolchain/Android.mk
new file mode 100644
index 0000000..2e40683
--- /dev/null
+++ b/toolchain/Android.mk
@@ -0,0 +1,25 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := 3rd-party-compiler
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_IS_HOST_MODULE := true
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
+compiler = $(intermediates)/$(LOCAL_MODULE)
+$(compiler): $(LOCAL_PATH)/3rd-party-compiler.in
+ @mkdir -p $(dir $@)
+ $(hide): $(PRODUCT_OUT) $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
+ $(hide)sed \
+ -e 's:@CC@:$(notdir $(TARGET_CC)):' \
+ -e 's:@CFLAGS@:$(foreach p,$(TARGET_C_INCLUDES),-isystem "$${ANDROID_BUILD_TOP}/$(p)"):' \
+ -e 's:@LDFLAGS@:-B"$(patsubst $(PRODUCT_OUT)/%,$${ANDROID_PRODUCT_OUT}/%,$(TARGET_OUT_INTERMEDIATE_LIBRARIES))":' \
+ -e 's:@ROOT_SUBDIR@:$(3RD_PARTY_ROOT_SUBDIR):g' \
+ $< > $@.tmp \
+ && chmod a+rx $@.tmp && mv $@.tmp $@
+
+LOCAL_BUILT_MODULE = $(compiler)
+LOCAL_GENERATED_SOURCES += $(3RD_PARTY_COMPILER)
+
+include $(CLEAR_VARS)