From d9a8a346bc560c7730cd784ccae950e82e1b3417 Mon Sep 17 00:00:00 2001 From: Armando Montanez Date: Thu, 11 Jun 2020 13:42:03 -0700 Subject: [PATCH] Clean up host toolchains Update the host toolchains to be prefixed with their target name and use a slightly more compact style to define the toolchain scopes. Change-Id: Ib0dae237299e74c6c48cd4c35869fd215563a7bf --- BUILD.gn | 6 +-- targets/host/target_config.gni | 37 --------------- targets/host/target_toolchains.gni | 74 +++++++++++------------------- 3 files changed, 29 insertions(+), 88 deletions(-) delete mode 100644 targets/host/target_config.gni diff --git a/BUILD.gn b/BUILD.gn index ae6a83206..69ebdc960 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -29,11 +29,11 @@ declare_args() { group("default") { # Auto select a toolchain based on host. if (host_os == "linux") { - _host_target_toolchain = "$dir_pigweed/targets/host:gcc_debug" + _host_target_toolchain = "$dir_pigweed/targets/host:host_gcc_debug" } else if (host_os == "mac") { - _host_target_toolchain = "$dir_pigweed/targets/host:clang_debug" + _host_target_toolchain = "$dir_pigweed/targets/host:host_clang_debug" } else if (host_os == "win") { - _host_target_toolchain = "$dir_pigweed/targets/host:gcc_debug" + _host_target_toolchain = "$dir_pigweed/targets/host:host_gcc_debug" } else { assert(false, "Please define a host config for your system: $host_os") } diff --git a/targets/host/target_config.gni b/targets/host/target_config.gni deleted file mode 100644 index 47a887bbc..000000000 --- a/targets/host/target_config.gni +++ /dev/null @@ -1,37 +0,0 @@ -# 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. - -# This is the target config to import when building for host. All this does is -# import the appropriate target configuration for the current host OS. -# -# Due to GN-isms, lowest-precedence target variable definitions must be imported -# at the deepest point. This causes the following structure: -# -# target_system.gni (e.g. Linux) -# └ host_common.gni -# └ pw_vars_default.gni -# -# This allows host_common to override variables defined in pw_vars_default, -# and target_system to override defaults in host_common. - -# Load target-specific config file for a host desktop system. -if (host_os == "linux") { - import("linux.gni") -} else if (host_os == "mac") { - import("macos.gni") -} else if (host_os == "win") { - import("windows.gni") -} else { - assert(false, "Please define a host config for your system: $host_os") -} diff --git a/targets/host/target_toolchains.gni b/targets/host/target_toolchains.gni index 6ea32bb9a..4a6a233ff 100644 --- a/targets/host/target_toolchains.gni +++ b/targets/host/target_toolchains.gni @@ -62,16 +62,16 @@ _os_specific_config = { } pw_target_toolchain_host = { + _excluded_members = [ + "defaults", + "name", + ] + clang_debug = { - name = "clang_debug" - forward_variables_from(pw_toolchain_host_clang.debug, - "*", - [ - "defaults", - "name", - ]) + name = "host_clang_debug" + _toolchain_base = pw_toolchain_host_clang.debug + forward_variables_from(_toolchain_base, "*", _excluded_members) defaults = { - _toolchain_base = pw_toolchain_host_clang.debug forward_variables_from(_toolchain_base.defaults, "*") forward_variables_from(_host_common, "*") forward_variables_from(_os_specific_config, "*") @@ -79,15 +79,10 @@ pw_target_toolchain_host = { } clang_speed_optimized = { - name = "clang_speed_optimized" - forward_variables_from(pw_toolchain_host_clang.speed_optimized, - "*", - [ - "defaults", - "name", - ]) + name = "host_clang_speed_optimized" + _toolchain_base = pw_toolchain_host_clang.speed_optimized + forward_variables_from(_toolchain_base, "*", _excluded_members) defaults = { - _toolchain_base = pw_toolchain_host_clang.speed_optimized forward_variables_from(_toolchain_base.defaults, "*") forward_variables_from(_host_common, "*") forward_variables_from(_os_specific_config, "*") @@ -95,15 +90,10 @@ pw_target_toolchain_host = { } clang_size_optimized = { - name = "clang_size_optimized" - forward_variables_from(pw_toolchain_host_clang.size_optimized, - "*", - [ - "defaults", - "name", - ]) + name = "host_clang_size_optimized" + _toolchain_base = pw_toolchain_host_clang.size_optimized + forward_variables_from(_toolchain_base, "*", _excluded_members) defaults = { - _toolchain_base = pw_toolchain_host_clang.size_optimized forward_variables_from(_toolchain_base.defaults, "*") forward_variables_from(_host_common, "*") forward_variables_from(_os_specific_config, "*") @@ -111,15 +101,10 @@ pw_target_toolchain_host = { } gcc_debug = { - name = "gcc_debug" - forward_variables_from(pw_toolchain_host_gcc.debug, - "*", - [ - "defaults", - "name", - ]) + name = "host_gcc_debug" + _toolchain_base = pw_toolchain_host_gcc.debug + forward_variables_from(_toolchain_base, "*", _excluded_members) defaults = { - _toolchain_base = pw_toolchain_host_gcc.debug forward_variables_from(_toolchain_base.defaults, "*") forward_variables_from(_host_common, "*") forward_variables_from(_os_specific_config, "*") @@ -127,15 +112,10 @@ pw_target_toolchain_host = { } gcc_speed_optimized = { - name = "gcc_speed_optimized" - forward_variables_from(pw_toolchain_host_gcc.speed_optimized, - "*", - [ - "defaults", - "name", - ]) + name = "host_gcc_speed_optimized" + _toolchain_base = pw_toolchain_host_gcc.speed_optimized + forward_variables_from(_toolchain_base, "*", _excluded_members) defaults = { - _toolchain_base = pw_toolchain_host_gcc.speed_optimized forward_variables_from(_toolchain_base.defaults, "*") forward_variables_from(_host_common, "*") forward_variables_from(_os_specific_config, "*") @@ -143,15 +123,10 @@ pw_target_toolchain_host = { } gcc_size_optimized = { - name = "gcc_size_optimized" - forward_variables_from(pw_toolchain_host_gcc.size_optimized, - "*", - [ - "defaults", - "name", - ]) + name = "host_gcc_size_optimized" + _toolchain_base = pw_toolchain_host_gcc.size_optimized + forward_variables_from(_toolchain_base, "*", _excluded_members) defaults = { - _toolchain_base = pw_toolchain_host_gcc.size_optimized forward_variables_from(_toolchain_base.defaults, "*") forward_variables_from(_host_common, "*") forward_variables_from(_os_specific_config, "*") @@ -159,6 +134,9 @@ pw_target_toolchain_host = { } } +# This list just contains the members of the above scope for convenience to make +# it trivial to generate all the toolchains in this file via a +# `generate_toolchains` target. pw_target_toolchain_host_list = [ pw_target_toolchain_host.clang_debug, pw_target_toolchain_host.clang_speed_optimized,