1# Copyright 2019 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("python_action.gni") 16 17declare_args() { 18 # Whether to build host-side tooling. 19 pw_build_HOST_TOOLS = false 20} 21 22if (pw_build_HOST_TOOLS) { 23 # Defines a Pigweed host tool and installs it into the host_tools directory. 24 # 25 # Args: 26 # tool: The target that outputs the binary tool. 27 # name: Optional name for the installed program. Defaults to the name of 28 # the compiled binary. 29 template("pw_host_tool") { 30 assert(defined(invoker.tool), 31 "pw_host_tool must specify an executable as the tool variable") 32 33 _script_args = [ 34 "--src", 35 "<TARGET_FILE(${invoker.tool})>", 36 "--dst", 37 rebase_path("$root_out_dir/host_tools"), 38 "--out-root", 39 rebase_path(root_out_dir), 40 ] 41 42 if (defined(invoker.name) && invoker.name != "") { 43 _script_args += [ 44 "--name", 45 invoker.name, 46 ] 47 } 48 49 pw_python_action(target_name) { 50 script = "$dir_pw_build/py/pw_build/host_tool.py" 51 args = _script_args 52 deps = [ invoker.tool ] 53 stamp = true 54 } 55 } 56} else { 57 # For builds without host tools, create an empty target. 58 template("pw_host_tool") { 59 not_needed("*") 60 not_needed(invoker, "*") 61 62 group(target_name) { 63 } 64 } 65} # pw_build_HOST_TOOLS 66