diff options
author | Nowar Gu <nowar100@gmail.com> | 2011-07-05 06:04:50 +0800 |
---|---|---|
committer | Nowar Gu <nowar100@gmail.com> | 2011-07-05 06:04:50 +0800 |
commit | e6fd2ec358187c18bc7f6c20ceb7430a3fe43349 (patch) | |
tree | f7f3cbadf91ef34dc9658fdd6544563119c242b5 | |
parent | 414e55e370acf1abe0b20c3ae09276df530d31ce (diff) | |
download | gdk-e6fd2ec358187c18bc7f6c20ceb7430a3fe43349.tar.gz |
Code cleanup. Done yet.
-rw-r--r-- | build/core/add-platform.mk | 33 | ||||
-rw-r--r-- | build/core/add-toolchain.mk | 72 | ||||
-rw-r--r-- | build/core/build-all.mk | 150 | ||||
-rw-r--r-- | build/core/build-bitcode.mk | 15 | ||||
-rw-r--r-- | build/core/build-local.mk | 139 | ||||
-rw-r--r-- | build/core/clear-vars.mk | 22 | ||||
-rw-r--r-- | build/core/init.mk | 373 | ||||
-rw-r--r-- | samples/hello-llvm/jni/Android.mk | 10 | ||||
-rw-r--r-- | toolchains/llvm/setup.mk | 51 |
9 files changed, 45 insertions, 820 deletions
diff --git a/build/core/add-platform.mk b/build/core/add-platform.mk deleted file mode 100644 index da83717..0000000 --- a/build/core/add-platform.mk +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (C) 2009 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -$(call assert-defined,_platform NDK_PLATFORMS_ROOT) - -# For each platform, determine the corresponding supported ABIs -# And record them in NDK_PLATFORM_$(platform)_ABIS -# -_abis := $(strip $(notdir $(wildcard $(NDK_PLATFORMS_ROOT)/$(_platform)/arch-*))) -_abis := $(_abis:arch-%=%) - -$(call ndk_log,PLATFORM $(_platform) supports: $(_abis)) - -NDK_PLATFORM_$(_platform)_ABIS := $(_abis) - -# Record the sysroots for each supported ABI -# -$(foreach _abi,$(_abis),\ - $(eval NDK_PLATFORM_$(_platform)_$(_abi)_SYSROOT := $(NDK_PLATFORMS_ROOT)/$(_platform)/arch-$(_abi))\ - $(call ndk_log, ABI $(_abi) sysroot is: $(NDK_PLATFORM_$(_platform)_$(_abi)_SYSROOT))\ -) diff --git a/build/core/add-toolchain.mk b/build/core/add-toolchain.mk deleted file mode 100644 index 26d1952..0000000 --- a/build/core/add-toolchain.mk +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright (C) 2009 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# this script is included repeatedly by main.mk to add a new toolchain -# definition to the NDK build system. -# -# '_config_mk' must be defined as the path of a toolchain -# configuration file (config.mk) that will be included here. -# -$(call assert-defined, _config_mk) - -# The list of variables that must or may be defined -# by the toolchain configuration file -# -NDK_TOOLCHAIN_VARS_REQUIRED := TOOLCHAIN_ABIS -NDK_TOOLCHAIN_VARS_OPTIONAL := - -# Clear variables that are supposed to be defined by the config file -$(call clear-vars,$(NDK_TOOLCHAIN_VARS_REQUIRED)) -$(call clear-vars,$(NDK_TOOLCHAIN_VARS_OPTIONAL)) - -# Include the config file -include $(_config_mk) - -# Check that the proper variables were defined -$(call check-required-vars,$(NDK_TOOLCHAIN_VARS_REQUIRED),$(_config_mk)) - -# Check that the file didn't do something stupid -$(call assert-defined, _config_mk) - -# Now record the toolchain-specific information -_dir := $(patsubst %/,%,$(dir $(_config_mk))) -_name := $(notdir $(_dir)) -_abis := $(TOOLCHAIN_ABIS) - -_toolchain := NDK_TOOLCHAIN.$(_name) - -# check that the toolchain name is unique -$(if $(strip $($(_toolchain).defined)),\ - $(call __ndk_error,Toolchain $(_name) defined in $(_parent) is\ - already defined in $(NDK_TOOLCHAIN.$(_name).defined))) - -$(_toolchain).defined := $(_toolchain_config) -$(_toolchain).abis := $(_abis) -$(_toolchain).setup := $(wildcard $(_dir)/setup.mk) - -$(if $(strip $($(_toolchain).setup)),,\ - $(call __ndk_error, Toolchain $(_name) lacks a setup.mk in $(_dir))) - -NDK_ALL_TOOLCHAINS += $(_name) -NDK_ALL_ABIS += $(_abis) - -# NKD_ABI.<abi>.toolchains records the list of toolchains that support -# a given ABI -# -$(foreach _abi,$(_abis),\ - $(eval NDK_ABI.$(_abi).toolchains += $(_name)) \ -) - -# done diff --git a/build/core/build-all.mk b/build/core/build-all.mk deleted file mode 100644 index ed577a6..0000000 --- a/build/core/build-all.mk +++ /dev/null @@ -1,150 +0,0 @@ -# Copyright (C) 2009-2010 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# -# This script is used to build all wanted NDK binaries. It is included -# by several scripts. -# - -# ensure that the following variables are properly defined -$(call assert-defined,NDK_APPS NDK_APP_OUT) - -# ==================================================================== -# -# Prepare the build for parsing Android.mk files -# -# ==================================================================== - -# These phony targets are used to control various stages of the build -.PHONY: all \ - copy-llvm-toolchains \ - host_libraries host_executables \ - installed_modules \ - executables libraries static_libraries shared_libraries \ - clean clean-objs-dir \ - clean-executables clean-libraries \ - clean-installed-modules \ - clean-installed-binaries - -# These macros are used in Android.mk to include the corresponding -# build script that will parse the LOCAL_XXX variable definitions. -# -CLEAR_VARS := $(BUILD_SYSTEM)/clear-vars.mk -BUILD_HOST_EXECUTABLE := $(BUILD_SYSTEM)/build-host-executable.mk -BUILD_HOST_STATIC_LIBRARY := $(BUILD_SYSTEM)/build-host-static-library.mk -BUILD_STATIC_LIBRARY := $(BUILD_SYSTEM)/build-static-library.mk -BUILD_SHARED_LIBRARY := $(BUILD_SYSTEM)/build-shared-library.mk -BUILD_EXECUTABLE := $(BUILD_SYSTEM)/build-executable.mk -BUILD_BITCODE := $(BUILD_SYSTEM)/build-bitcode.mk -PREBUILT_SHARED_LIBRARY := $(BUILD_SYSTEM)/prebuilt-shared-library.mk -PREBUILT_STATIC_LIBRARY := $(BUILD_SYSTEM)/prebuilt-static-library.mk - -ANDROID_MK_INCLUDED := \ - $(CLEAR_VARS) \ - $(BUILD_HOST_EXECUTABLE) \ - $(BUILD_HOST_STATIC_LIBRARY) \ - $(BUILD_STATIC_LIBRARY) \ - $(BUILD_SHARED_LIBRARY) \ - $(BUILD_EXECUTABLE) \ - $(BUILD_BITCODE) \ - $(PREBUILT_SHARED_LIBRARY) - -# this is the list of directories containing dependency information -# generated during the build. It will be updated by build scripts -# when module definitions are parsed. -# -ALL_DEPENDENCY_DIRS := - -# this is the list of all generated files that we would need to clean -ALL_HOST_EXECUTABLES := -ALL_HOST_STATIC_LIBRARIES := -ALL_STATIC_LIBRARIES := -ALL_SHARED_LIBRARIES := -ALL_EXECUTABLES := -ALL_BITCODE := - -WANTED_INSTALLED_MODULES := - -# FIXME(Nowar): We will use llvm-ndk-cc in future. -ifeq ($(USE_CLANG),) - USE_CLANG := 1 -endif - -# the first rule -all: copy-llvm-toolchains installed_modules host_libraries host_executables - -ANDROID_SOURCE_ROOT := $(NDK_ROOT)/../ -copy-llvm-toolchains: -ifeq ($(USE_CLANG),0) - $(info **********************************************************************) - $(info Copy llvm toolchains from Android source tree...) - $(info If copy failed, please go to $(NDK_ROOT)/sources/llvm-ndk-cc/ and build them at first.) - $(info **********************************************************************) - @mkdir -p $(NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86/bin/ - @cp -p $(ANDROID_SOURCE_ROOT)/out/host/linux-x86/bin/llvm-ndk-cc \ - $(NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86/bin/ - @cp -p $(ANDROID_SOURCE_ROOT)/out/host/linux-x86/bin/llvm-ndk-link \ - $(NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86/bin/ -endif - -# TODO(Nowar): De-coupling gdk from ndk -# $(info Copy NDK toolchains to toolchains/arm-linux-androideabi-4.4.3/prebuilt) -# $(info **********************************************************************) -# @mkdir -p $(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/ -# @cp -r $(NDK_ROOT)/../ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt $(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt - -# XXX(Nowar): Why we need this? -# $(info Copy clang from Android source tree...) -# $(info If copy failed, please go to $(ANDROID_SOURCE_ROOT)/external/clang and build them at first.) -# $(info **********************************************************************) -# @cp -p $(ANDROID_SOURCE_ROOT)/out/host/linux-x86/bin/clang \ -# $(NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86/bin/llvm-ndk-cc - - - -$(foreach _app,$(NDK_APPS),\ - $(eval include $(BUILD_SYSTEM)/setup-app.mk)\ -) - -# ==================================================================== -# -# Now finish the build preparation with a few rules that depend on -# what has been effectively parsed and recorded previously -# -# ==================================================================== - -clean: clean-intermediates clean-installed-binaries - -distclean: clean - -installed_modules: clean-installed-binaries libraries $(WANTED_INSTALLED_MODULES) -host_libraries: $(HOST_STATIC_LIBRARIES) -host_executables: $(HOST_EXECUTABLES) - -static_libraries: $(STATIC_LIBRARIES) -shared_libraries: $(SHARED_LIBRARIES) -executables: $(EXECUTABLES) - -libraries: static_libraries shared_libraries - -clean-host-intermediates: - $(hide) rm -rf $(HOST_EXECUTABLES) $(HOST_STATIC_LIBRARIES) - -clean-intermediates: clean-host-intermediates - $(hide) rm -rf $(EXECUTABLES) $(STATIC_LIBRARIES) $(SHARED_LIBRARIES) - -# include dependency information -ALL_DEPENDENCY_DIRS := $(sort $(ALL_DEPENDENCY_DIRS)) --include $(wildcard $(ALL_DEPENDENCY_DIRS:%=%/*.d)) diff --git a/build/core/build-bitcode.mk b/build/core/build-bitcode.mk index ba3b8bd..8ed89b0 100644 --- a/build/core/build-bitcode.mk +++ b/build/core/build-bitcode.mk @@ -1,15 +1,4 @@ -LOCAL_BUILD_SCRIPT := BUILD_BITCODE -LOCAL_MAKEFILE := $(local-makefile) +.PHONY: $(LOCAL_MODULE) -$(call check-defined-LOCAL_MODULE,$(LOCAL_BUILD_SCRIPT)) -$(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE)) -$(call check-LOCAL_MODULE_FILENAME) +$(foreach src,$(filter %c,$(LOCAL_SRC_FILES)),$(call compile-c-to-bc,$(src))) -# we are building target objects -my := TARGET_ - -$(call handle-module-filename,lib,.bc) -$(call handle-module-built) - -LOCAL_MODULE_CLASS := BITCODE -include $(BUILD_SYSTEM)/build-module.mk diff --git a/build/core/build-local.mk b/build/core/build-local.mk index 0880515..969beec 100644 --- a/build/core/build-local.mk +++ b/build/core/build-local.mk @@ -1,136 +1,15 @@ -# Copyright (C) 2010 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +GDK_PROJECT_PATH := $(shell pwd) +GDK_ROOT := $(GDK_PROJECT_PATH)/../.. -# This file is designed to be called from the 'ndk-build' script -# or similar wrapper tool. -# +include $(GDK_ROOT)/build/core/init.mk -# Detect the NDK installation path by processing this Makefile's location. -# This assumes we are located under $NDK_ROOT/build/core/main.mk -# -NDK_ROOT := $(dir $(lastword $(MAKEFILE_LIST))) -NDK_ROOT := $(strip $(NDK_ROOT:%build/core/=%)) -NDK_ROOT := $(NDK_ROOT:%/=%) -ifeq ($(NDK_ROOT),) - # for the case when we're invoked from the NDK install path - NDK_ROOT := . -endif -ifdef NDK_LOG - $(info Android NDK: NDK installation path auto-detected: '$(NDK_ROOT)') -endif -ifneq ($(words $(NDK_ROOT)),1) - $(info Android NDK: You NDK installation path contains spaces.) - $(info Android NDK: Please re-install to a different location to fix the issue !) - $(error Aborting.) -endif - -include $(NDK_ROOT)/build/core/init.mk - -# ==================================================================== -# -# If NDK_PROJECT_PATH is not defined, find the application's project -# path by looking at the manifest file in the current directory or -# any of its parents. If none is found, try again with 'jni/Android.mk' -# -# It turns out that some people use ndk-build to generate static -# libraries without a full Android project tree. -# -# ==================================================================== - -find-project-dir = $(strip $(call find-project-dir-inner,$1,$2)) - -find-project-dir-inner = \ - $(eval __found_project_path := )\ - $(eval __find_project_path := $1)\ - $(eval __find_project_file := $2)\ - $(call find-project-dir-inner-2)\ - $(__found_project_path) - -find-project-dir-inner-2 = \ - $(call ndk_log,Looking for $(__find_project_file) in $(__find_project_path))\ - $(eval __find_project_manifest := $(strip $(wildcard $(__find_project_path)/$(__find_project_file))))\ - $(if $(__find_project_manifest),\ - $(call ndk_log, Found it !)\ - $(eval __found_project_path := $(__find_project_path))\ - ,\ - $(eval __find_project_parent := $(patsubst %/,%,$(dir $(__find_project_path))))\ - $(if $(__find_project_parent),\ - $(eval __find_project_path := $(__find_project_parent))\ - $(call find-project-dir-inner-2)\ - )\ - ) - -NDK_PROJECT_PATH := $(strip $(NDK_PROJECT_PATH)) -ifndef NDK_PROJECT_PATH - NDK_PROJECT_PATH := $(call find-project-dir,$(strip $(shell pwd)),AndroidManifest.xml) -endif -ifndef NDK_PROJECT_PATH - NDK_PROJECT_PATH := $(call find-project-dir,$(strip $(shell pwd)),jni/Android.mk) -endif -ifndef NDK_PROJECT_PATH - $(call __ndk_info,Could not find application project directory !) - $(call __ndk_info,Please define the NDK_PROJECT_PATH variable to point to it.) - $(call __ndk_error,Aborting) -endif +include $(GDK_PROJECT_PATH)/jni/Android-portable.mk -# Check that there are no spaces in the project path, or bad things will happen -ifneq ($(words $(NDK_PROJECT_PATH)),1) - $(call __ndk_info,Your Android application project path contains spaces: '$(NDK_PROJECT_PATH)') - $(call __ndk_info,The Android NDK build cannot work here. Please move your project to a different location.) - $(call __ndk_error,Aborting.) -endif - -NDK_APPLICATION_MK := $(strip $(wildcard $(NDK_PROJECT_PATH)/jni/Application.mk)) -ifndef NDK_APPLICATION_MK - NDK_APPLICATION_MK := $(NDK_ROOT)/build/core/default-application.mk -endif - -$(call ndk_log,Found project path: $(NDK_PROJECT_PATH)) - -# Place all generated files here -NDK_APP_OUT := $(NDK_PROJECT_PATH)/obj - -# Fake an application named 'local' -_app := local -_application_mk := $(NDK_APPLICATION_MK) -NDK_APPS := $(_app) - -include $(BUILD_SYSTEM)/add-application.mk +include $(GDK_ROOT)/build/core/build-bitcode.mk -# If a goal is DUMP_xxx then we dump a variable xxx instead -# of building anything -# -DUMP_VAR := $(patsubst DUMP_%,%,$(filter DUMP_%,$(MAKECMDGOALS))) -MAKECMDGOALS := $(filter-out DUMP_$(DUMP_VAR),$(MAKECMDGOALS)) - -include $(BUILD_SYSTEM)/setup-imports.mk - -ifneq (,$(DUMP_VAR)) - -# We only support a single DUMP_XXX goal at a time for now. -ifneq ($(words $(DUMP_VAR)),1) - $(call __ndk_error,!!TOO-MANY-DUMP-VARIABLES!!) +ifeq ($(NDK_ROOT),) + $(info Android GDK: Must figure out NDK_ROOT location.) + $(error Aborting.) endif -$(foreach _app,$(NDK_APPS),\ - $(eval include $(BUILD_SYSTEM)/setup-app.mk)\ -) - -DUMP_$(DUMP_VAR): - @echo $($(DUMP_VAR)) -else - # Build it - include $(BUILD_SYSTEM)/build-all.mk -endif +include $(NDK_ROOT)/build/core/build-local.mk diff --git a/build/core/clear-vars.mk b/build/core/clear-vars.mk deleted file mode 100644 index e9ad319..0000000 --- a/build/core/clear-vars.mk +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (C) 2009 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# this file is included repeatedly from Android.mk files in order to clean -# the module-specific variables from the environment, - -$(call clear-src-tags) - -# Note: As a special exception, we don't want to clear LOCAL_PATH -$(call clear-vars, $(filter-out LOCAL_PATH,$(modules-LOCALS:%=LOCAL_%))) diff --git a/build/core/init.mk b/build/core/init.mk index 56b9d9b..e1771fa 100644 --- a/build/core/init.mk +++ b/build/core/init.mk @@ -1,371 +1,14 @@ -# Copyright (C) 2009-2010 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Initialization of the NDK build system. This file is included by -# several build scripts. -# - -# Define NDK_LOG in your environment to display log traces when -# using the build scripts. See also the definition of ndk_log below. -# -NDK_LOG := $(strip $(NDK_LOG)) - -# Check that we have at least GNU Make 3.81 -# We do this by detecting whether 'lastword' is supported -# -MAKE_TEST := $(lastword a b c d e f) -ifneq ($(MAKE_TEST),f) - $(error Android NDK: GNU Make version $(MAKE_VERSION) is too low (should be >= 3.81)) -endif -ifdef NDK_LOG - $(info Android NDK: GNU Make version $(MAKE_VERSION) detected) -endif - -# NDK_ROOT *must* be defined and point to the root of the NDK installation -NDK_ROOT := $(strip $(NDK_ROOT)) -ifndef NDK_ROOT - $(error ERROR while including init.mk: NDK_ROOT must be defined !) -endif -ifneq ($(words $(NDK_ROOT)),1) - $(info,The Android NDK installation path contains spaces: '$(NDK_ROOT)') - $(error,Please fix the problem by reinstalling to a different location.) -endif - -# ==================================================================== -# -# Define a few useful variables and functions. -# More stuff will follow in definitions.mk. -# -# ==================================================================== - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting NDK_NO_WARNINGS or NDK_NO_ERRORS - -__ndk_name := Android NDK -__ndk_info = $(info $(__ndk_name): $1 $2 $3 $4 $5) -__ndk_warning = $(warning $(__ndk_name): $1 $2 $3 $4 $5) -__ndk_error = $(error $(__ndk_name): $1 $2 $3 $4 $5) - -ifdef NDK_NO_WARNINGS -__ndk_warning := -endif -ifdef NDK_NO_ERRORS -__ndk_error := -endif - -# ----------------------------------------------------------------------------- -# Function : ndk_log -# Arguments: 1: text to print when NDK_LOG is defined -# Returns : None -# Usage : $(call ndk_log,<some text>) -# ----------------------------------------------------------------------------- -ifdef NDK_LOG -ndk_log = $(info $(__ndk_name): $1) -else -ndk_log := -endif - -# ==================================================================== -# -# Host system auto-detection. -# -# ==================================================================== - -# -# Determine host system and architecture from the environment -# -HOST_OS := $(strip $(HOST_OS)) -ifndef HOST_OS - # On all modern variants of Windows (including Cygwin and Wine) - # the OS environment variable is defined to 'Windows_NT' - # - # The value of PROCESSOR_ARCHITECTURE will be x86 or AMD64 - # - ifeq ($(OS),Windows_NT) - HOST_OS := windows - else - # For other systems, use the `uname` output - UNAME := $(shell uname -s) - ifneq (,$(findstring Linux,$(UNAME))) - HOST_OS := linux - endif - ifneq (,$(findstring Darwin,$(UNAME))) - HOST_OS := darwin - endif - # We should not be there, but just in case ! - ifneq (,$(findstring CYGWIN,$(UNAME))) - HOST_OS := windows - endif - ifeq ($(HOST_OS),) - $(call __ndk_info,Unable to determine HOST_OS from uname -s: $(UNAME)) - $(call __ndk_info,Please define HOST_OS in your environment.) - $(call __ndk_error,Aborting.) - endif - endif - $(call ndk_log,Host OS was auto-detected: $(HOST_OS)) -else - $(call ndk_log,Host OS from environment: $(HOST_OS)) -endif - -HOST_ARCH := $(strip $(HOST_ARCH)) -ifndef HOST_ARCH - ifeq ($(HOST_OS),windows) - HOST_ARCH := $(PROCESSOR_ARCHITECTURE) - ifeq ($(HOST_ARCH),AMD64) - HOST_ARCH := x86 - endif - else # HOST_OS != windows - UNAME := $(shell uname -m) - ifneq (,$(findstring 86,$(UNAME))) - HOST_ARCH := x86 - endif - # We should probably should not care at all - ifneq (,$(findstring Power,$(UNAME))) - HOST_ARCH := ppc - endif - ifeq ($(HOST_ARCH),) - $(call __ndk_info,Unsupported host architecture: $(UNAME)) - $(call __ndk_error,Aborting) - endif - endif # HOST_OS != windows - $(call ndk_log,Host CPU was auto-detected: $(HOST_ARCH)) -else - $(call ndk_log,Host CPU from environment: $(HOST_ARCH)) -endif - -HOST_TAG := $(HOST_OS)-$(HOST_ARCH) - -# The directory separator used on this host -HOST_DIRSEP := : - -# For now always use ":" since Windows is Cygwin -#ifeq ($(HOST_OS),windows) -# HOST_DIRSEP := ; -#endif - -# If we are on Windows, we need to check that we are not running -# Cygwin 1.5, which is deprecated and won't run our toolchain -# binaries properly. -# -ifeq ($(HOST_TAG),windows-x86) - # On cygwin, 'uname -r' returns something like 1.5.23(0.225/5/3) - # We recognize 1.5. as the prefix to look for then. - CYGWIN_VERSION := $(shell uname -r) - ifneq ($(filter XX1.5.%,XX$(CYGWIN_VERSION)),) - $(call __ndk_info,You seem to be running Cygwin 1.5, which is not supported.) - $(call __ndk_info,Please upgrade to Cygwin 1.7 or higher.) - $(call __ndk_error,Aborting.) - endif - # special-case the host-tag - HOST_TAG := windows -endif -$(call ndk_log,HOST_TAG set to $(HOST_TAG)) - -# -# Verify that the 'awk' tool has the features we need. -# Both Nawk and Gawk do. -# -HOST_AWK := $(strip $(HOST_AWK)) -ifndef HOST_AWK - HOST_AWK := awk - $(call ndk_log,Host awk tool was auto-detected: $(HOST_AWK)) -else - $(call ndk_log,Host awk tool from environment: $(HOST_AWK)) -endif - -# Location of all awk scripts we use -BUILD_AWK := $(NDK_ROOT)/build/awk - -AWK_TEST := $(shell $(HOST_AWK) -f $(BUILD_AWK)/check-awk.awk) -$(call ndk_log,Host awk test returned: $(AWK_TEST)) -ifneq ($(AWK_TEST),Pass) - $(call __ndk_info,Host awk tool is outdated. Please define HOST_AWK to point to Gawk or Nawk !) - $(call __ndk_error,Aborting.) -endif - -# -# On windows, define the 'cygwin-to-host-path' function here depending on the -# environment. The rules are the following: -# -# 1/ If "cygpath' is not in your path, do not use it at all. It looks like -# this allows to build with the NDK from MSys without problems. -# -# 2/ Since invoking 'cygpath -m' from GNU Make for each source file is -# _very_ slow, try to generate a Make function that performs the mapping -# from cygwin to host paths through simple substitutions. -# -# 3/ In case we fail horribly, allow the user to define NDK_USE_CYGPATH to '1' -# in order to use 'cygpath -m' nonetheless. This is only a backup plan in -# case our automatic substitution function doesn't work (only likely if you -# have a very weird cygwin setup). -# -# The function for 2/ is generated by an awk script. It's really a series -# of nested patsubst calls, that look like: -# -# cygwin-to-host-path = $(patsubst /cygdrive/c/%,c:/%,\ -# $(patsusbt /cygdrive/d/%,d:/%, \ -# $1) -# -# except that the actual definition is built from the list of mounted -# drives as reported by "mount" and deals with drive letter cases (i.e. -# '/cygdrive/c' and '/cygdrive/C') -# -ifeq ($(HOST_OS),windows) - CYGPATH := $(strip $(HOST_CYGPATH)) - ifndef CYGPATH - $(call ndk_log, Probing for 'cygpath' program) - CYGPATH := $(strip $(shell which cygpath 2>/dev/null)) - ifndef CYGPATH - $(call ndk_log, 'cygpath' was *not* found in your path) - else - $(call ndk_log, 'cygpath' found as: $(CYGPATH)) - endif - endif - ifndef CYGPATH - cygwin-to-host-path = $1 - else - ifeq ($(NDK_USE_CYGPATH),1) - $(call ndk_log, Forced usage of 'cygpath -m' through NDK_USE_CYGPATH=1) - cygwin-to-host-path = $(strip $(shell $(CYGPATH) -m $1)) - else - # Call an awk script to generate a Makefile fragment used to define a function - WINDOWS_HOST_PATH_FRAGMENT := $(shell mount | $(HOST_AWK) -f $(BUILD_AWK)/gen-windows-host-path.awk) - ifeq ($(NDK_LOG),1) - $(info Using cygwin substitution rules:) - $(eval $(shell mount | $(HOST_AWK) -f $(BUILD_AWK)/gen-windows-host-path.awk -vVERBOSE=1)) - endif - $(eval cygwin-to-host-path = $(WINDOWS_HOST_PATH_FRAGMENT)) - endif - endif -endif # HOST_OS == windows - -# The location of the build system files -BUILD_SYSTEM := $(NDK_ROOT)/build/core - -# Include common definitions -include $(BUILD_SYSTEM)/definitions.mk - -# ==================================================================== +# ############################################################################ # # Read all toolchain-specific configuration files. # -# Each toolchain must have a corresponding config.mk file located -# in build/toolchains/<name>/ that will be included here. -# -# Each one of these files should define the following variables: -# TOOLCHAIN_NAME toolchain name (e.g. arm-linux-androideabi-4.4.3) -# TOOLCHAIN_ABIS list of target ABIs supported by the toolchain. -# -# Then, it should include $(ADD_TOOLCHAIN) which will perform -# book-keeping for the build system. -# -# ==================================================================== - -# the build script to include in each toolchain config.mk -ADD_TOOLCHAIN := $(BUILD_SYSTEM)/add-toolchain.mk - -# the list of all toolchains in this NDK -NDK_ALL_TOOLCHAINS := -NDK_ALL_ABIS := - -TOOLCHAIN_CONFIGS := $(wildcard $(NDK_ROOT)/toolchains/*/config.mk) -$(foreach _config_mk,$(TOOLCHAIN_CONFIGS),\ - $(eval include $(BUILD_SYSTEM)/add-toolchain.mk)\ -) - -NDK_ALL_TOOLCHAINS := $(call remove-duplicates,$(NDK_ALL_TOOLCHAINS)) -NDK_ALL_ABIS := $(call remove-duplicates,$(NDK_ALL_ABIS)) - -# Allow the user to define NDK_TOOLCHAIN to a custom toolchain name. -# This is normally used when the NDK release comes with several toolchains -# for the same architecture (generally for backwards-compatibility). -# -NDK_TOOLCHAIN := $(strip $(NDK_TOOLCHAIN)) -ifdef NDK_TOOLCHAIN - # check that the toolchain name is supported - $(if $(filter-out $(NDK_ALL_TOOLCHAINS),$(NDK_TOOLCHAIN)),\ - $(call __ndk_info,NDK_TOOLCHAIN is defined to the unsupported value $(NDK_TOOLCHAIN)) \ - $(call __ndk_info,Please use one of the following values: $(NDK_ALL_TOOLCHAINS))\ - $(call __ndk_error,Aborting)\ - ,) - $(call ndk_log, Using specific toolchain $(NDK_TOOLCHAIN)) -endif - -$(call ndk_log, This NDK supports the following toolchains and target ABIs:) -$(foreach tc,$(NDK_ALL_TOOLCHAINS),\ - $(call ndk_log, $(space)$(space)$(tc): $(NDK_TOOLCHAIN.$(tc).abis))\ -) - -# ==================================================================== -# -# Read all platform-specific configuration files. -# -# Each platform must be located in build/platforms/android-<apilevel> -# where <apilevel> corresponds to an API level number, with: -# 3 -> Android 1.5 -# 4 -> next platform release -# -# ==================================================================== - -# The platform files were moved in the Android source tree from -# $TOP/ndk/build/platforms to $TOP/development/ndk/platforms. However, -# the official NDK release packages still place them under the old -# location for now, so deal with this here -# -NDK_PLATFORMS_ROOT := $(strip $(NDK_PLATFORMS_ROOT)) -ifndef NDK_PLATFORMS_ROOT - NDK_PLATFORMS_ROOT := $(strip $(wildcard $(NDK_ROOT)/platforms)) - ifndef NDK_PLATFORMS_ROOT - NDK_PLATFORMS_ROOT := $(strip $(wildcard $(NDK_ROOT)/build/platforms)) - endif - - ifndef NDK_PLATFORMS_ROOT - $(call __ndk_info,Could not find platform files (headers and libraries)) - $(if $(strip $(wildcard $(NDK_ROOT)/RELEASE.TXT)),\ - $(call __ndk_info,Please define NDK_PLATFORMS_ROOT to point to a valid directory.)\ - ,\ - $(call __ndk_info,Please run build/tools/build-platforms.sh to build the corresponding directory.)\ - ) - $(call __ndk_error,Aborting) - endif - - $(call ndk_log,Found platform root directory: $(NDK_PLATFORMS_ROOT)) -endif -ifeq ($(strip $(wildcard $(NDK_PLATFORMS_ROOT)/android-*)),) - $(call __ndk_info,Your NDK_PLATFORMS_ROOT points to an invalid directory) - $(call __ndk_info,Current value: $(NDK_PLATFORMS_ROOT)) - $(call __ndk_error,Aborting) -endif - -NDK_ALL_PLATFORMS := $(strip $(notdir $(wildcard $(NDK_PLATFORMS_ROOT)/android-*))) -$(call ndk_log,Found supported platforms: $(NDK_ALL_PLATFORMS)) - -$(foreach _platform,$(NDK_ALL_PLATFORMS),\ - $(eval include $(BUILD_SYSTEM)/add-platform.mk)\ -) +# ############################################################################ +GDK_PLATFORM_ROOT := $(GDK_ROOT)/platforms/android-portable/arch-llvm +GDK_TOOLCHAIN_ROOT := $(GDK_ROOT)/toolchains/llvm -# we're going to find the maximum platform number of the form android-<number> -# ignore others, which could correspond to special and experimental cases -NDK_ALL_PLATFORM_LEVELS := $(filter android-%,$(NDK_ALL_PLATFORMS)) -NDK_ALL_PLATFORM_LEVELS := $(patsubst android-%,%,$(NDK_ALL_PLATFORM_LEVELS)) -$(call ndk_log,Found stable platform levels: $(NDK_ALL_PLATFORM_LEVELS)) +BUILD_BITCODE := $(GDK_ROOT)/build/core/build-bitcode.mk -NDK_MAX_PLATFORM_LEVEL := 3 -$(foreach level,$(NDK_ALL_PLATFORM_LEVELS),\ - $(eval NDK_MAX_PLATFORM_LEVEL := $$(call max,$$(NDK_MAX_PLATFORM_LEVEL),$$(level)))\ -) -$(call ndk_log,Found max platform level: $(NDK_MAX_PLATFORM_LEVEL)) +parent-dir = $(patsubst %/,%,%(dir $1)) +my-dir = $(call parent-dir,$(lastword $(MAKEFILE_LIST))) +include $(GDK_TOOLCHAIN_ROOT)/setup.mk diff --git a/samples/hello-llvm/jni/Android.mk b/samples/hello-llvm/jni/Android.mk index 9046d53..e69de29 100644 --- a/samples/hello-llvm/jni/Android.mk +++ b/samples/hello-llvm/jni/Android.mk @@ -1,10 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_CFLAGS := -D NUM=7788 - -LOCAL_MODULE := hello_llvm -LOCAL_SRC_FILES := hello_llvm.c test.c - -include $(BUILD_BITCODE) diff --git a/toolchains/llvm/setup.mk b/toolchains/llvm/setup.mk index 99bcd4e..7fd7b19 100644 --- a/toolchains/llvm/setup.mk +++ b/toolchains/llvm/setup.mk @@ -1,28 +1,29 @@ -TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREFIX:%-=%) - -#TARGET_CC := $(TOOLCHAIN_PREFIX)llvm-ndk-cc -#TARGET_CFLAGS := -# -#TARGET_CXX := $(TOOLCHAIN_PREFIX)llvm-ndk-cc -#TARGET_CXXFLAGS := $(TARGET_CFLAGS) -fno-exceptions -fno-rtti -D __cplusplus -# -#TARGET_LD := $(TOOLCHAIN_PREFIX)llvm-ndk-link -#TARGET_LDFLAGS := -# -#TARGET_AR := ar -#TARGET_ARFLAGS := crs -# -#TARGET_C_INCLUDES := \ -# $(SYSROOT)/usr/include - -# -# Break build/core/default-build-commands.mk rules -# -#TARGET_NO_UNDEFINED_LDFLAGS := -#TARGET_NO_EXECUTE_CFLAGS := -#TARGET_NO_EXECUTE_LDFLAGS := -#TARGET_LDLIBS := -#cmd-strip := +GDK_TOOLCHAIN_PREFIX := $(GDK_TOOLCHAIN_ROOT)/toolchains/llvm/prebuilt/ + +# FIXME(Nowar): In future, we will use llvm-ndk-cc +BITCODE_CC := $(TOOLCHAIN_PREFIX)clang +BITCODE_CFLAGS := -emit-llvm + +BITCODE_CXX := $(TOOLCHAIN_PREFIX)clang++ +BITCODE_CXXFLAGS := $(BITCODE_CFLAGS) -fno-exceptions -fno-rtti -D __cplusplus + +BITCODE_LD := $(TOOLCHAIN_PREFIX)llvm-link +BITCODE_LDFLAGS := + +BITCODE_C_INCLUDES := \ + $(GDK_PLATFORM_ROOT)/usr/include + +define ev-compile-c-to-bc +_SRC := $$(LOCAL_PATH)/$(1) +_OBJ := $(GDK_PROJECT_PATH)/$(2) +_FLAGS := $$(LOCAL_CFLAGS) \ + $$(BITCODE_CFLAGS) \ + -I $$(LOCAL_C_INCLUDES) \ + -I $$(BITCODE_C_INCLUDES) \ + -c + + +compile-c-to-bc = $(eval $(call ev-compile-c-to-bc,$1,$(1:%.c=%.bc))) define cmd-build-bitcode $(BITCODE_LD) \ |