57139
|
1 |
#
|
|
2 |
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
#
|
|
5 |
# This code is free software; you can redistribute it and/or modify it
|
|
6 |
# under the terms of the GNU General Public License version 2 only, as
|
|
7 |
# published by the Free Software Foundation. Oracle designates this
|
|
8 |
# particular file as subject to the "Classpath" exception as provided
|
|
9 |
# by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
#
|
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
# accompanied this code).
|
|
16 |
#
|
|
17 |
# You should have received a copy of the GNU General Public License version
|
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
#
|
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
# or visit www.oracle.com if you need additional information or have any
|
|
23 |
# questions.
|
|
24 |
#
|
|
25 |
|
|
26 |
ifeq (,$(_MAKEBASE_GMK))
|
|
27 |
$(error You must include MakeBase.gmk prior to including Execute.gmk)
|
|
28 |
endif
|
|
29 |
|
|
30 |
################################################################################
|
|
31 |
#
|
|
32 |
# Code for handling the SetupExecute macro.
|
|
33 |
#
|
|
34 |
################################################################################
|
|
35 |
|
|
36 |
|
|
37 |
################################################################################
|
|
38 |
# Setup make rules for executing an arbitrary command.
|
|
39 |
#
|
|
40 |
# Parameter 1 is the name of the rule. This name is used as variable prefix,
|
|
41 |
# and the targets generated are listed in a variable by that name.
|
|
42 |
#
|
|
43 |
# Remaining parameters are named arguments. These include:
|
|
44 |
# COMMAND : The command to execute
|
|
45 |
# OUTPUT_DIR : The directory that will contain the result from the command
|
|
46 |
# (OUTPUT_FILE : Use this if the command results in a single output file. (N/A))
|
|
47 |
# INFO : Message to display at LOG=info level when running command (optional).
|
|
48 |
# DEPS : Dependencies for the execution to take place
|
|
49 |
#
|
|
50 |
|
|
51 |
# Setup make rules for copying files, with an option to do more complex
|
|
52 |
SetupExecute = $(NamedParamsMacroTemplate)
|
|
53 |
define SetupExecuteBody
|
|
54 |
ifeq ($$($1_COMMAND), )
|
|
55 |
$$(error COMMAND is missing in SetupExecute $1)
|
|
56 |
endif
|
|
57 |
|
|
58 |
ifeq ($$($1_OUTPUT_DIR), )
|
|
59 |
$$(error OUTPUT_DIR is missing in SetupExecute $1)
|
|
60 |
endif
|
|
61 |
|
|
62 |
ifeq ($$($1_INFO), )
|
|
63 |
$1_INFO := Running commands for $1
|
|
64 |
endif
|
|
65 |
|
|
66 |
$1_BASE := $$($1_OUTPUT_DIR)/_$1
|
|
67 |
|
|
68 |
$1_MARKER := $$($1_BASE).marker
|
|
69 |
|
|
70 |
$$($1_MARKER): $$($1_DEPS)
|
|
71 |
$$(call LogInfo, $$($1_INFO))
|
|
72 |
$$(call MakeDir, $$($1_OUTPUT_DIR))
|
|
73 |
$$(call ExecuteWithLog, $$($1_BASE), \
|
|
74 |
$$($1_COMMAND))
|
|
75 |
$$(TOUCH) $$@
|
|
76 |
|
|
77 |
# Export our generated targets in $1, and also $1_TARGET for clarity.
|
|
78 |
$1 := $$($1_MARKER)
|
|
79 |
$1_TARGET := $$($1)
|
|
80 |
endef
|