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