-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add android toolchain to GN build system (#2241)
Adding an android toolchain for arm and x86_64 target cpus. Subsequent CLs may add target arch to select armv6, armv7, arm64 and x86 targets if required. Added a check to only attempt to run tests when current_os == host_os, otherwise cross compiled tests attempt to execute on the wrong architecture and fail. Need to temporarily omit lib/messages from android build due to RNG dependency on openssl.
- Loading branch information
1 parent
5b4345e
commit 90988b6
Showing
13 changed files
with
215 additions
and
18 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
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
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
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
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
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,54 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# 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. | ||
|
||
if (current_cpu == "x86" || current_cpu == "x86_64") { | ||
declare_args() { | ||
# Build file to import for X86 defaults. | ||
x86_platform_config = "" | ||
} | ||
|
||
# Allow platforms to override how ARM architecture flags are chosen by | ||
# providing a file to import. | ||
if (x86_platform_config != "") { | ||
_platform_defaults = { | ||
import(x86_platform_config) | ||
} | ||
} | ||
|
||
_defaults = { | ||
x86_arch = "" | ||
x86_cpu = "" | ||
x86_tune = "" | ||
x86_sysroot = "" | ||
|
||
# Update defaults with platform values, if any. | ||
if (x86_platform_config != "") { | ||
forward_variables_from(_platform_defaults, "*") | ||
} | ||
} | ||
|
||
declare_args() { | ||
# ARM architecture (value for -march flag). | ||
x86_arch = _defaults.x86_arch | ||
|
||
# ARM CPU (value for -mcpu flag). | ||
x86_cpu = _defaults.x86_cpu | ||
|
||
# ARM tuning (value for -mtune flag). | ||
x86_tune = _defaults.x86_tune | ||
|
||
# ARM sysroot (value for --sysroot flag). | ||
x86_sysroot = _defaults.x86_sysroot | ||
} | ||
} |
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,32 @@ | ||
# Copyright 2020 The Pigweed Authors | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# 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. | ||
|
||
import("android_toolchain.gni") | ||
|
||
if (current_cpu == "arm") { | ||
android_arm_toolchain("armv7_clang") { | ||
toolchain_args = { | ||
is_clang = true | ||
} | ||
} | ||
} else if (current_cpu == "x86_64") { | ||
android_x86_64_toolchain("x86_64_clang") { | ||
toolchain_args = { | ||
is_clang = true | ||
} | ||
} | ||
} else { | ||
assert(false, "Unknown target cpu ${current_cpu}") | ||
} |
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,58 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# 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. | ||
|
||
import("//build/toolchain/gcc_toolchain.gni") | ||
|
||
template("android_arm_toolchain") { | ||
gcc_toolchain(target_name) { | ||
# TODO : arm64 | ||
# TODO: Drop API level to 21 after getifaddrs issue fixed | ||
_tool_name_root = "armv7a-linux-androideabi24-" | ||
|
||
toolchain_args = { | ||
current_cpu = "arm" | ||
arm_arch = "armv7-a" | ||
arm_fpu = "vfpv3-d16" | ||
arm_float_abi = "softfp" | ||
current_os = "android" | ||
is_clang = true | ||
|
||
forward_variables_from(invoker.toolchain_args, "*") | ||
} | ||
ar = "llvm-ar" | ||
cc = _tool_name_root + "clang" | ||
cxx = _tool_name_root + "clang++" | ||
} | ||
} | ||
|
||
template("android_x86_64_toolchain") { | ||
gcc_toolchain(target_name) { | ||
# TODO : x86 | ||
# TODO: Drop API level to 21 after getifaddrs issue fixed | ||
_tool_name_root = "x86_64-linux-android24-" | ||
|
||
toolchain_args = { | ||
current_cpu = "x86_64" | ||
x86_arch = "x86-64" | ||
x86_tune = "intel" | ||
current_os = "android" | ||
is_clang = true | ||
|
||
forward_variables_from(invoker.toolchain_args, "*") | ||
} | ||
ar = "llvm-ar" | ||
cc = _tool_name_root + "clang" | ||
cxx = _tool_name_root + "clang++" | ||
} | ||
} |
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
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
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
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
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