Skip to content

Commit

Permalink
Fix case of APP_WRAP_SH being empty.
Browse files Browse the repository at this point in the history
I used the wrong variable to check the sanitizer flags, so it was
always using ASAN, causing the asan wrap.sh to be installed unless
the user specified their own.

Fix the problem and add a test case to make sure this is only
installed if it's requested.

Also clean up some debug logging that was accidentally left in.

Test: ./run_tests.py --rebuild
Bug: android/ndk#540
Change-Id: I0e6d4b0222a4aeb1b491f6869c338011b74e2e8f
(cherry picked from commit 38b57e4af408b0df9288f110dd6cffa0edef30ba)
  • Loading branch information
DanAlbert committed Feb 16, 2018
1 parent 86d7480 commit f336f22
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/core/sanitizers.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ include $(BUILD_SYSTEM)/install_sanitizer.mk

# If the user has not specified their own wrap.sh and is using ASAN, install a
# default ASAN wrap.sh for them.
ifneq (,$(filter address,$(NDK_SANITIZER_FSANITIZE_ARGS)))
ifneq (,$(filter address,$(NDK_SANITIZERS)))
ifeq ($(NDK_NO_USER_WRAP_SH),true)
NDK_APP_WRAP_SH_$(TARGET_ARCH_ABI) := \
$(NDK_ROOT)/wrap.sh/asan.$(TARGET_ARCH_ABI).sh
Expand Down
1 change: 0 additions & 1 deletion build/core/setup-toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ include $(NDK_APP_BUILD_SCRIPT)
# -fsanitize in its ldflags.
include $(BUILD_SYSTEM)/sanitizers.mk

$(info NDK_APP_WRAP_SH_$(TARGET_ARCH_ABI)=$(NDK_APP_WRAP_SH_$(TARGET_ARCH_ABI)))
ifneq ($(NDK_APP_WRAP_SH_$(TARGET_ARCH_ABI)),)
include $(BUILD_SYSTEM)/install_wrap_sh.mk
endif
Expand Down
Empty file.
6 changes: 6 additions & 0 deletions tests/build/wrap_sh_none/project/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := foo.cpp
include $(BUILD_SHARED_LIBRARY)
1 change: 1 addition & 0 deletions tests/build/wrap_sh_none/project/jni/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void foo() {}
44 changes: 44 additions & 0 deletions tests/build/wrap_sh_none/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Copyright (C) 2018 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.
#
"""Check for correct link order from ndk-build.
"""
import os
import subprocess
import sys


def run_test(ndk_path, abi, platform, toolchain, build_flags):
"""Checks that the proper wrap.sh scripts were installed."""
ndk_build = os.path.join(ndk_path, 'ndk-build')
if sys.platform == 'win32':
ndk_build += '.cmd'
project_path = 'project'
ndk_args = build_flags + [
'APP_ABI=' + abi,
'APP_PLATFORM=android-{}'.format(platform),
'NDK_TOOLCHAIN_VERSION=' + toolchain,
]
proc = subprocess.Popen([ndk_build, '-C', project_path] + ndk_args,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = proc.communicate()
out = out.decode('utf-8')
if proc.returncode != 0:
return proc.returncode == 0, out

wrap_sh = os.path.join(project_path, 'libs', abi, 'wrap.sh')
if os.path.exists(wrap_sh):
return False, '{} should not exist'.format(wrap_sh)
return True, ''

0 comments on commit f336f22

Please sign in to comment.