You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.0 KiB

# Copyright 2020 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("//build_overrides/pigweed.gni")
import("$dir_pw_toolchain/generate_toolchain.gni")
# Generates a toolchain using the currently active toolchain as a foundation.
# WARNING: Only works with toolchains generated by Pigweed's generate_toolchain.
# WARNING: This can quickly create an explosion of toolchains and compile times.
# Use sparingly!
#
# Args:
# build_args: (required) A scope setting GN build arg values to apply to GN
# targets in this toolchain. These take precedence over args.gni settings,
# and any build_args set by the currently active toolchain.
# (other): You can optionally override all other generate_toolchain args. See
# that template's documentation for more information.
template("pw_generate_subtoolchain") {
assert(defined(invoker.build_args), "Sub-toolchain is missing 'build_args'")
_original_scope = pw_toolchain_SCOPE
assert(defined(_original_scope.name),
"Sub-toolchain must be generated from a Pigweed toolchain")
generate_toolchain(target_name) {
forward_variables_from(_original_scope, "*", [ "defaults" ])
forward_variables_from(invoker, "*", [ "build_args" ])
# Subtoolchains must always be generated from the toolchain that parses
# them rather than relying on the default_toolchain.
generate_from = current_toolchain
defaults = {
forward_variables_from(_original_scope.defaults, "*")
forward_variables_from(invoker.build_args, "*")
}
}
}