From 11c170d174b4da1682b507a30cae6ff6f0cce50f Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Thu, 8 Apr 2010 14:24:34 -0700 Subject: [PATCH] Extract the debuggable flag from the application's manifest and only copy the gdbserver binary to $PROJECT/libs/ if it is set to TRUE. Change-Id: I06bc0c0c7993d93d7ee22b9b055b10ad8ef3cd86 --- build/core/extract-package-debuggable.awk | 49 +++++++++++++++++++++++++++++++ build/core/setup-app.mk | 8 ++++- build/core/setup-toolchain.mk | 2 +- 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 build/core/extract-package-debuggable.awk diff --git a/build/core/extract-package-debuggable.awk b/build/core/extract-package-debuggable.awk new file mode 100644 index 0000000..6b55a34 --- /dev/null +++ b/build/core/extract-package-debuggable.awk @@ -0,0 +1,49 @@ +# 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. +# +# A nawk/gawk script used to extract the debuggable flag from an application's +# manifest (i.e. AndroidManifest.xml). +# +# The name itself is the value of the 'android:debuggable' attribute in the +# 'application' element. +# + +BEGIN { + FS=" " + in_tag=0 + regex1="android:debuggable=\"true\"" + regex2="android:debuggable='true'" + DEBUGGABLE="false" +} + +// { + in_tag=0 +} + +END { + print DEBUGGABLE +} diff --git a/build/core/setup-app.mk b/build/core/setup-app.mk index 365ad3e..c684580 100644 --- a/build/core/setup-app.mk +++ b/build/core/setup-app.mk @@ -34,7 +34,9 @@ $(foreach __name,$(NDK_APP_VARS),\ $(eval NDK_$(__name) := $(call get,$(_map),$(__name)))\ ) -# set release/debug build flags +# set release/debug build flags. We always use the -g flag because +# we generate symbol versions of the binaries that are later stripped +# when they are copied to the final project's libs/ directory. # ifeq ($(NDK_APP_OPTIM),debug) NDK_APP_CFLAGS := -O0 -g $(NDK_APP_CFLAGS) @@ -69,6 +71,10 @@ ifneq ($(_bad_abis),) $(call __ndk_error,Aborting) endif +# extract the debuggable flag from the application's manifest +NDK_APP_DEBUGGABLE := $(shell $(HOST_AWK) -f $(BUILD_SYSTEM)/extract-package-debuggable.awk $(NDK_APP_PROJECT_PATH)/AndroidManifest.xml) +$(info NDK_APP_DEBUGGABLE=$(NDK_APP_DEBUGGABLE)) + # Clear all installed binaries for this application # This ensures that if the build fails, you're not going to mistakenly # package an obsolete version of it. Or if you change the ABIs you're targetting, diff --git a/build/core/setup-toolchain.mk b/build/core/setup-toolchain.mk index 3114a48..410cd56 100644 --- a/build/core/setup-toolchain.mk +++ b/build/core/setup-toolchain.mk @@ -75,7 +75,7 @@ NDK_APP_DEST := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ARCH_ABI) # Ensure that for debuggable applications, gdbserver will be copied to # the proper location -ifeq ($(NDK_APP_OPTIM),debug) +ifeq ($(NDK_APP_DEBUGGABLE),true) NDK_APP_GDBSERVER := $(NDK_APP_DEST)/gdbserver -- 2.11.0