Skip to content

Commit

Permalink
Add Android.mk to aid integration with FirefoxOS
Browse files Browse the repository at this point in the history
This Android.mk is part of "Bug 831147 - Integrate apitrace into build"
https://bugzilla.mozilla.org/831147
With this addition, when apitrace sources are cloned into
B2GROOT/external/apitrace, then the FirefoxOS build system picks
up automatically apitrace, compiles and install is to the right place.
  • Loading branch information
vasild committed Mar 20, 2013
1 parent 983f270 commit 799b65c
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#
# This file helps integrate apitrace into FirefoxOS - when apitrace
# sources are put in B2GROOT/external/apitrace (including this Android.mk
# file), then the B2G build system will pick apitrace automatically and
# compile and install it into the system images seamlessly.
#

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := egltrace
LOCAL_MODULE_TAGS := debug eng

include $(BUILD_SHARED_LIBRARY)

# Below we hook the whole process of configuring and compiling apitrace,
# described in INSTALL.markdown. We override the
# $(linked_module): targed, which is already defined by
# $(BUILD_SHARED_LIBRARY) - by default it would want to compile the
# library out of some source files.
# We also override the target $(LOCAL_INSTALLED_MODULE): which installs
# the shared library because we want it installed in
# /lib/apitrace/wrappers/egltrace.so instead of /lib/egltrace.so because
# /bin/apitrace searches for the library in that directory.
# The rules will end up with /lib/apitrace/wrappers/egltrace.so and
# /bin/apitrace inside system.img.
MY_APITRACE_ROOT := $(TOPDIR)external/apitrace
MY_APITRACE_BUILD_ROOT_HOST := out/host/apitrace
MY_APITRACE_BUILD_ROOT_TARGET := out/target/apitrace
MY_APITRACE_NDK_BZ2 := android-ndk-r8-linux-x86.tar.bz2
MY_APITRACE_NDK := android-ndk-r8

apitrace_private_target:
$(hide) # apitrace: run cmake for the host if it has not been run
$(hide) if [ ! -e $(MY_APITRACE_BUILD_ROOT_HOST)/Makefile ] ; then \
cd $(MY_APITRACE_ROOT) && \
cmake -H. -B../../$(MY_APITRACE_BUILD_ROOT_HOST) ; \
fi
$(hide) # apitrace: compile for the host
$(hide) make -C $(MY_APITRACE_BUILD_ROOT_HOST)
$(hide) # apitrace: download NDK archive if it is not present
$(hide) if [ ! -e $(MY_APITRACE_ROOT)/$(MY_APITRACE_NDK_BZ2) ] ; then \
cd $(MY_APITRACE_ROOT) && \
curl -O http://dl.google.com/android/ndk/$(MY_APITRACE_NDK_BZ2) ; \
fi
$(hide) # apitrace: extract NDK archive if it is not extracted
$(hide) if [ ! -e $(MY_APITRACE_ROOT)/$(MY_APITRACE_NDK) ] ; then \
cd $(MY_APITRACE_ROOT) && \
tar -jxf $(MY_APITRACE_NDK_BZ2) ; \
fi
$(hide) # apitrace: run cmake for android if it has not been run
$(hide) if [ ! -e $(MY_APITRACE_BUILD_ROOT_TARGET)/Makefile ] ; then \
cd $(MY_APITRACE_ROOT) && \
ANDROID_NDK=$(MY_APITRACE_NDK) \
cmake \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/android.toolchain.cmake \
-DANDROID_API_LEVEL=9 -H. -B../../$(MY_APITRACE_BUILD_ROOT_TARGET) ; \
fi
$(hide) # apitrace: compile for android
$(hide) make -C $(MY_APITRACE_BUILD_ROOT_TARGET)

$(linked_module): apitrace_private_target
$(hide) # apitrace: copy egltrace lib to where the build system expects it
$(hide) mkdir -p $(dir $@)
$(hide) cp $(MY_APITRACE_BUILD_ROOT_TARGET)/wrappers/egltrace$(TARGET_SHLIB_SUFFIX) $@

$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
@echo "Install (overridden): $@"
@mkdir -p $(dir $@)/apitrace/wrappers
$(hide) $(ACP) -fp $< $(dir $@)/apitrace/wrappers/egltrace$(TARGET_SHLIB_SUFFIX)

#

include $(CLEAR_VARS)

LOCAL_MODULE := apitrace
LOCAL_MODULE_TAGS := debug eng

include $(BUILD_EXECUTABLE)

$(linked_module): apitrace_private_target
$(hide) # apitrace: copy apitrace executable to where the build system expects it
$(hide) mkdir -p $(dir $@)
$(hide) cp $(MY_APITRACE_BUILD_ROOT_TARGET)/apitrace$(TARGET_EXECUTABLE_SUFFIX) $@

0 comments on commit 799b65c

Please sign in to comment.