mirror of
https://fuchsia.googlesource.com/third_party/pigweed.googlesource.com/pigweed/pigweed
synced 2024-09-20 22:00:58 +00:00
586719197a
This adds a generic host_clang toolchain, targeting hosts running Mac and Linux to start, and likely Windows later. For now, on Mac the default toolchain is set to host_clang_og Change-Id: Iea457c61586930d509439c6616574c9a74919433
143 lines
4.0 KiB
Plaintext
143 lines
4.0 KiB
Plaintext
# Copyright 2019 The Pigweed 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
|
|
#
|
|
# https://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("arm_gcc.gni")
|
|
import("host_clang.gni")
|
|
import("x86_linux_gcc.gni")
|
|
|
|
# Creates a series of toolchain targets with common compiler options.
|
|
#
|
|
# Args:
|
|
# toolchain_template: The target template to use to create the toolchains.
|
|
# common_toolchain_cflags: cflags to be shared by all toolchains.
|
|
# common_toolchain_ldflags: ldflags to be shared by all toolchains.
|
|
# toolchains: List of scopes defining each of the desired toolchains.
|
|
# Each scope contains up to three variables:
|
|
# toolchain_name: The full target name of the toolchain.
|
|
# additional_cflags: Optional list of extra cflags for the toolchain.
|
|
# additional_ldflags: Optional list of extra ldflags for the toolchain.
|
|
template("generate_toolchains") {
|
|
not_needed([ "target_name" ])
|
|
|
|
assert(defined(invoker.toolchain_template),
|
|
"generate_toolchains requires a toolchain template")
|
|
assert(defined(invoker.toolchains),
|
|
"generate_toolchains must be called with a list of toolchains")
|
|
|
|
if (defined(invoker.common_toolchain_cflags)) {
|
|
_common_cflags = invoker.common_toolchain_cflags
|
|
} else {
|
|
_common_cflags = []
|
|
}
|
|
|
|
if (defined(invoker.common_toolchain_ldflags)) {
|
|
_common_ldflags = invoker.common_toolchain_ldflags
|
|
} else {
|
|
_common_ldflags = []
|
|
}
|
|
|
|
# Create a target for each of the desired toolchains, appending its own cflags
|
|
# and ldflags to the common ones.
|
|
foreach(toolchain_config, invoker.toolchains) {
|
|
# GN does not allow assigning a non-empty array to a non-empty array.
|
|
# This must be done as two assignments, first clearing the original value.
|
|
_toolchain_cflags = []
|
|
_toolchain_cflags = _common_cflags
|
|
if (defined(toolchain_config.additional_cflags)) {
|
|
_toolchain_cflags += toolchain_config.additional_cflags
|
|
}
|
|
|
|
_toolchain_ldflags = []
|
|
_toolchain_ldflags = _common_ldflags
|
|
if (defined(toolchain_config.additional_ldflags)) {
|
|
_toolchain_ldflags += toolchain_config.additional_ldflags
|
|
}
|
|
|
|
target(invoker.toolchain_template, toolchain_config.toolchain_name) {
|
|
toolchain_cflags = _toolchain_cflags
|
|
toolchain_ldflags = _toolchain_ldflags
|
|
}
|
|
}
|
|
}
|
|
|
|
generate_toolchains("cortex_m4") {
|
|
toolchain_template = "arm_gcc_toolchain"
|
|
|
|
common_toolchain_cflags = [
|
|
"-mabi=aapcs",
|
|
"-mcpu=cortex-m4",
|
|
"-mfpu=fpv4-sp-d16",
|
|
"-mfloat-abi=hard",
|
|
"-mthumb",
|
|
]
|
|
|
|
common_toolchain_ldflags = [
|
|
"--specs=nosys.specs",
|
|
"-lnosys",
|
|
"-lc",
|
|
]
|
|
|
|
toolchains = [
|
|
{
|
|
toolchain_name = "arm_gcc_cortex_m4_og"
|
|
additional_cflags = [ "-Og" ]
|
|
},
|
|
{
|
|
toolchain_name = "arm_gcc_cortex_m4_o1"
|
|
additional_cflags = [ "-O1" ]
|
|
},
|
|
{
|
|
toolchain_name = "arm_gcc_cortex_m4_o2"
|
|
additional_cflags = [ "-O2" ]
|
|
},
|
|
{
|
|
toolchain_name = "arm_gcc_cortex_m4_os"
|
|
additional_cflags = [ "-Os" ]
|
|
},
|
|
]
|
|
}
|
|
|
|
generate_toolchains("linux") {
|
|
toolchain_template = "x86_gcc_toolchain"
|
|
|
|
toolchains = [
|
|
{
|
|
toolchain_name = "x86_linux_o2"
|
|
additional_cflags = [ "-O2" ]
|
|
},
|
|
]
|
|
}
|
|
|
|
generate_toolchains("host_clang_suite") {
|
|
toolchain_template = "host_clang"
|
|
common_toolchain_cflags = [
|
|
"-g3",
|
|
]
|
|
|
|
toolchains = [
|
|
{
|
|
toolchain_name = "host_clang_og"
|
|
additional_cflags = [ "-Og" ]
|
|
},
|
|
{
|
|
toolchain_name = "host_clang_o2"
|
|
additional_cflags = [ "-O2" ]
|
|
},
|
|
{
|
|
toolchain_name = "host_clang_os"
|
|
additional_cflags = [ "-Os" ]
|
|
},
|
|
]
|
|
}
|