-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix default behavior for API level clamping.
When not specified this was evaluating to an empty string, so CMake was receiving only one argument... Test: added a test Bug: android/ndk#1560 Change-Id: I1340a7b0afd271568c5f8aadbc4ca345479e95fa
- Loading branch information
Showing
6 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cmake_minimum_required(VERSION 3.6) | ||
project(ToolchainDefaultsTest CXX) | ||
|
||
add_library(foo SHARED foo.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#if !defined(__ARM_ARCH_7A__) | ||
#error ABI did not default to armeabi-v7a | ||
#endif | ||
|
||
// Update this whenever we raise the minimum API level in the NDK. | ||
#if __ANDROID_API__ != 19 | ||
#error API level did not default to 19 | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
# Copyright (C) 2021 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 that the default CMake toolchain behavior works.""" | ||
from pathlib import Path | ||
import subprocess | ||
|
||
from ndk.cmake import find_cmake, find_ninja | ||
from ndk.test.spec import BuildConfiguration, CMakeToolchainFile | ||
|
||
|
||
def run_test(ndk_path: str, config: BuildConfiguration) -> tuple[bool, str]: | ||
"""Check that the default CMake toolchain behavior works. | ||
All our regular CMake tests pass the API level and ABI explicitly. This | ||
test checks that the defaults (armeabi-v7a, minimum supported API level) | ||
work. | ||
""" | ||
cmake = find_cmake() | ||
ninja = find_ninja() | ||
toolchain_path = Path(ndk_path) / 'build/cmake/android.toolchain.cmake' | ||
project_path = 'project' | ||
if config.toolchain_file is CMakeToolchainFile.Legacy: | ||
toolchain_mode = 'ON' | ||
else: | ||
toolchain_mode = 'OFF' | ||
cmake_cmd = [ | ||
str(cmake), | ||
f'-DCMAKE_TOOLCHAIN_FILE={toolchain_path}', | ||
f'-DCMAKE_MAKE_PROGRAM={ninja}', | ||
f'-DANDROID_USE_LEGACY_TOOLCHAIN_FILE={toolchain_mode}', | ||
'-GNinja', | ||
] | ||
result = subprocess.run(cmake_cmd, | ||
check=False, | ||
cwd=project_path, | ||
capture_output=True, | ||
text=True) | ||
return result.returncode == 0, result.stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from typing import Optional | ||
|
||
from ndk.abis import LP32_ABIS | ||
from ndk.test.types import Test | ||
|
||
|
||
def build_unsupported(test: Test) -> Optional[str]: | ||
if test.config.abi in LP32_ABIS: | ||
return test.config.abi | ||
return None |