blob: 88b2b416339f6716f822d76ba57f4d94be4f02aa [file] [log] [blame]
Alexei Frolov293b09b2019-12-17 13:22:18 -08001# 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_script.gni")
16
17# Runs a program which isn't in Python.
18#
19# This is provided to avoid having to write a new Python wrapper script every
20# time a program needs to be run from GN.
21#
22# Args:
23# program: The program to run. Can be a full path or just a name (in which case
24# $PATH is searched).
25# args: Optional list of arguments to the program.
26# inputs: Optional list of build inputs to the program.
27# outputs: Optional list of artifacts produced by the program's execution.
28template("pw_exec") {
29 assert(defined(invoker.program), "pw_exec requires a program to run")
30
31 pw_python_script(target_name) {
32 script = "$dir_pw_build/py/exec.py"
33 args = [ invoker.program ]
34
35 if (defined(invoker.args)) {
36 args += invoker.args
37 }
38
39 if (defined(invoker.inputs)) {
40 inputs = invoker.inputs
41 }
42
43 if (defined(invoker.outputs)) {
44 outputs = invoker.outputs
45 } else {
46 stamp = true
47 }
48 }
49}