1# Copyright 2021 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/cc_library.gni") 18import("$dir_pw_build/gn_internal/build_target.gni") 19 20# Note: In general, prefer to import target_types.gni rather than this file. 21# cc_executable.gni and cc_library.gni are both provided by target_types.gni. 22# 23# cc_library.gni is split out from cc_executable.gni because pw_executable 24# templates may need to create pw_source_set targets internally, and can't 25# import target_types.gni because it creates a circular import path. 26 27# This template wraps a configurable target type specified by the current 28# toolchain to be used for all pw_executable targets. This allows projects to 29# stamp out unique build logic for each pw_executable target, such as generating 30# .bin files from .elf files, creating token databases, injecting custom data 31# as late-bound build steps, and more. 32# 33# Like pw_source_set, pw_static_library, and pw_shared_library, default configs 34# default visibility, and link deps are applied to the target before forwarding 35# to the underlying type as specified by pw_build_EXECUTABLE_TARGET_TYPE. 36# 37# For more information on the features provided by this template, see the full 38# docs at https://pigweed.dev/pw_build/?highlight=pw_executable#target-types. 39# 40# In addition to the arguments supported by a native executable target, this 41# template introduces the following arguments: 42# 43# remove_configs: (optional) A list of configs / config patterns to remove from 44# the set of default configs specified by the current toolchain 45# configuration. 46# remove_public_deps: (optional) A list of targets to remove from the set of 47# default public_deps specified by the current toolchain configuration. 48 49template("pw_executable") { 50 pw_internal_build_target(target_name) { 51 forward_variables_from(invoker, "*") 52 if (!defined(output_dir)) { 53 output_dir = "${target_out_dir}/bin" 54 } 55 add_global_link_deps = true 56 underlying_target_type = pw_build_EXECUTABLE_TARGET_TYPE 57 target_type_file = pw_build_EXECUTABLE_TARGET_TYPE_FILE 58 } 59} 60