add-application.mk revision eb8d04adaa73dabec176185f1fa0cb5900b9a8d4
1# Copyright (C) 2009 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# 15 16# this script is used to record an application definition in the 17# NDK build system, before performing any build whatsoever. 18# 19# It is included repeatedly from build/core/main.mk and expects a 20# variable named '_application_mk' which points to a given Application.mk 21# file that will be included here. The latter must define a few variables 22# to describe the application to the build system, and the rest of the 23# code here will perform book-keeping and basic checks 24# 25 26$(call assert-defined, _application_mk) 27$(call ndk_log,Parsing $(_application_mk)) 28 29$(call clear-vars, $(NDK_APP_VARS)) 30 31include $(_application_mk) 32 33$(call check-required-vars,$(NDK_APP_VARS_REQUIRED),$(_application_mk)) 34 35_dir := $(patsubst %/,%,$(dir $(_application_mk))) 36_name := $(notdir $(_dir)) 37_map := NDK_APP.$(_name) 38 39# strip the 'lib' prefix in front of APP_MODULES modules 40APP_MODULES := $(call strip-lib-prefix,$(APP_MODULES)) 41 42# check that APP_OPTIM, if defined, is either 'release' or 'debug' 43APP_OPTIM := $(strip $(APP_OPTIM)) 44$(if $(filter-out release debug,$(APP_OPTIM)),\ 45 $(call __ndk_info, The APP_OPTIM defined in $(_application_mk) must only be 'release' or 'debug')\ 46 $(call __ndk_error,Aborting)\ 47) 48 49ifndef APP_OPTIM 50 $(call ndk_log, Defaulted to APP_OPTIM=release) 51 APP_OPTIM := release 52endif 53 54# check whether APP_PLATFORM is defined. If not, look for default.properties in 55# the $(APP_PROJECT_PATH) and extract the value with awk's help. If nothing is here, 56# revert to the default value (i.e. "android-3"). 57# 58# NOTE: APP_PLATFORM is an experimental feature for now. 59# 60APP_PLATFORM := $(strip $(APP_PLATFORM)) 61ifndef APP_PLATFORM 62 _local_props := $(strip $(wildcard $(APP_PROJECT_PATH)/default.properties)) 63 ifdef _local_props 64 APP_PLATFORM := $(strip $(shell $(HOST_AWK) -f $(BUILD_SYSTEM)/extract-platform.awk < $(_local_props))) 65 $(call ndk_log, Found APP_PLATFORM=$(APP_PLATFORM) in $(_local_props)) 66 else 67 APP_PLATFORM := android-3 68 $(call ndk_log, Defaulted to APP_PLATFORM=$(APP_PLATFORM)) 69 endif 70endif 71 72_bad_platform := $(strip $(filter-out $(NDK_ALL_PLATFORMS),$(APP_PLATFORM))) 73ifdef _bad_platform 74 $(call __ndk_info,Application $(_name) targets platform '$(_bad_platform)') 75 $(call __ndk_info,which is not supported by this release of the Android NDK) 76 $(call __ndk_error,Aborting...) 77endif 78 79# If APP_BUILD_SCRIPT is defined, check that the file exists. 80# If undefined, look in $(APP_PROJECT_PATH)/jni/Android.mk 81# 82APP_BUILD_SCRIPT := $(strip $(APP_BUILD_SCRIPT)) 83ifdef APP_BUILD_SCRIPT 84 _build_script := $(strip $(wildcard $(APP_BUILD_SCRIPT))) 85 ifndef _build_script 86 $(call __ndk_info,Your APP_BUILD_SCRIPT points to an unknown file: $(APP_BUILD_SCRIPT)) 87 $(call __ndk_error,Aborting...) 88 endif 89 APP_BUILD_SCRIPT := $(_build_script) 90 $(call ndk_log, Using build script $(APP_BUILD_SCRIPT)) 91else 92 _build_script := $(strip $(wildcard $(APP_PROJECT_PATH)/jni/Android.mk)) 93 ifndef _build_script 94 $(call __ndk_info,There is no Android.mk under $(APP_PROJECT_PATH)/jni) 95 $(call __ndk_info,If this is intentional, please define APP_BUILD_SCRIPT to point) 96 $(call __ndk_info,to a valid NDK build script.) 97 $(call __ndk_error,Aborting...) 98 endif 99 APP_BUILD_SCRIPT := $(_build_script) 100 $(call ndk_log, Defaulted to APP_BUILD_SCRIPT=$(APP_BUILD_SCRIPT)) 101endif 102 103$(if $(call get,$(_map),defined),\ 104 $(call __ndk_info,Weird, the application $(_name) is already defined by $(call get,$(_map),defined))\ 105 $(call __ndk_error,Aborting)\ 106) 107 108$(call set,$(_map),defined,$(_application_mk)) 109 110# Record all app-specific variable definitions 111$(foreach __name,$(NDK_APP_VARS),\ 112 $(call set,$(_map),$(__name),$($(__name)))\ 113) 114 115# Record the Application.mk for debugging 116$(call set,$(_map),Application.mk,$(_application_mk)) 117 118NDK_ALL_APPS += $(_name) 119