make/common/Execute.gmk
author ihse
Tue, 29 Oct 2019 11:13:39 +0100
branchihse-setupexecute-branch
changeset 58833 ed9ef56bc7d5
parent 57228 f802ad9cf3bc
child 58834 f78e7ce060b0
permissions -rw-r--r--
Add documentation.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57139
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
     1
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
     2
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
     4
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    10
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    15
# accompanied this code).
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    16
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    20
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    23
# questions.
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    24
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    25
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    26
ifeq (,$(_MAKEBASE_GMK))
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    27
  $(error You must include MakeBase.gmk prior to including Execute.gmk)
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    28
endif
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    29
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    30
################################################################################
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    31
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    32
# Code for handling the SetupExecute macro.
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    33
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    34
################################################################################
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    35
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    36
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    37
################################################################################
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    38
# Setup make rules for executing an arbitrary command.
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    39
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    40
# Parameter 1 is the name of the rule. This name is used as variable prefix,
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    41
# and the targets generated are listed in a variable by that name.
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    42
#
58833
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    43
# You need to specify a COMMAND, the actual command line to execute. You are
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    44
# strongly recommended to provide a INFO with the text to display for LOG=info
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    45
# on what operation is performed. You can use DEPS to provide additional
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    46
# dependencies for your command to run. You can optionally include a PRE_COMMAND
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    47
# and a POST_COMMAND, intended for simple pre- and post-processing. The latter
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    48
# might be e.g. a mv from a temporary file to the final destination, the former
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    49
# e.g. a simple sed replacement on the input file. If the operations are
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    50
# unrelated to the main COMMAND, this is not a suitable solution.
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    51
#
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    52
# If your command outputs a variety of files, or if it's really a single file
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    53
# but you don't really care about the output from the perspective, you can just
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    54
# supply an OUTPUT_DIR. You are supposed to make sure the command creates files
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    55
# in this directory (which will be created for you if it does not exist), but
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    56
# this can't be enforced by SetupExecute. Additional support files (like logs
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    57
# and markers) are created in this directory. If you want support files in a
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    58
# separate directory (e.g. if you're targeting an OUTPUT_DIR in the image
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    59
# directly), you can specify a SUPPORT_DIR. If your command outputs only a
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    60
# single file, you can get rid of the marker files (but not the log files) by
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    61
# specifying OUTPUT_FILE. Note that if you specify an OUTPUT_FILE, support log
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    62
# files will be placed in the same directory as the OUTPUT_FILE. If you do not
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    63
# want that, use SUPPORT_DIR as well.
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    64
#
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    65
# After the call to SetupExecute, $1 will contain references to all generated
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    66
# files (that make knows about), and $1_TARGET will contain a reference to the
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    67
# final target (that is OUTPUT_FILE if it exists, or the $1_exec.marker file
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    68
# otherwise).
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    69
#
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    70
# All the above keep functioning as expected even if PRE_COMMAND and
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    71
# POST_COMMAND are given. One special case worth noting is that if OUTPUT_FILE
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    72
# and POST_COMMAND is both given, the actual OUTPUT_FILE is considered to be a
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    73
# result of running the POST_COMMAND.
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    74
#
57139
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    75
# Remaining parameters are named arguments. These include:
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    76
#   COMMAND     : The command to execute
58833
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    77
#   PRE_COMMAND : A helper command to execute before COMMAND
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    78
#   POST_COMMAND: A helper command to execute after COMMAND
57139
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    79
#   OUTPUT_DIR  : The directory that will contain the result from the command
58833
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    80
#   OUTPUT_FILE : Use this if the command results in a single output file
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    81
#   SUPPORT_DIR : Where to store generated support files
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    82
#   INFO        : Message to display at LOG=info level when running command (optional)
ed9ef56bc7d5 Add documentation.
ihse
parents: 57228
diff changeset
    83
#   WARN        : Message to display at LOG=warn level when running command (optional)
57139
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    84
#   DEPS        : Dependencies for the execution to take place
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    85
#
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    86
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    87
# Setup make rules for copying files, with an option to do more complex
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    88
SetupExecute = $(NamedParamsMacroTemplate)
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    89
define SetupExecuteBody
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    90
  ifeq ($$($1_COMMAND), )
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    91
    $$(error COMMAND is missing in SetupExecute $1)
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    92
  endif
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
    93
57158
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
    94
  ifneq ($$($1_OUTPUT_FILE), )
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
    95
    ifneq ($$($1_OUTPUT_DIR), )
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
    96
      $$(error Cannot specify both OUTPUT_DIR and OUTPUT_FILE in SetupExecute $1)
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
    97
    endif
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
    98
    # We need to know output dir since we will make sure it is created.
57158
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
    99
    $1_OUTPUT_DIR := $$(patsubst %/,%, $$(dir $$($1_OUTPUT_FILE)))
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   100
    ifeq ($$($1_SUPPORT_DIR), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   101
      # If support dir is not given, use base dir of output file.
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   102
      $1_SUPPORT_DIR := $$($1_OUTPUT_DIR)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   103
    endif
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   104
  else ifneq ($$($1_OUTPUT_DIR), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   105
    ifeq ($$($1_SUPPORT_DIR), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   106
      # If support dir is not given, use output dir.
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   107
      $1_SUPPORT_DIR := $$($1_OUTPUT_DIR)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   108
    endif
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   109
  else
57158
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
   110
    $$(error OUTPUT_DIR or OUTPUT_FILE is required in SetupExecute $1)
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
   111
  endif
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
   112
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   113
  $1_BASE := $$($1_SUPPORT_DIR)/_$1
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   114
  $1_PRE_MARKER := $$($1_BASE)_pre.marker
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   115
  $1_EXEC_MARKER := $$($1_BASE)_exec.marker
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   116
  $1_POST_MARKER := $$($1_BASE)_post.marker
57139
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
   117
57158
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
   118
  ifeq ($$($1_OUTPUT_FILE), )
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   119
    # No specified output file, use markers everywhere
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   120
    $1_EXEC_RESULT := $$($1_EXEC_MARKER)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   121
    ifeq ($$($1_POST_COMMAND), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   122
      $1_FINAL_RESULT := $$($1_EXEC_MARKER)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   123
    else
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   124
      $1_FINAL_RESULT := $$($1_POST_MARKER)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   125
    endif
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   126
57155
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   127
  else
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   128
    # If we have a single output file, we don't need a separate marker
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   129
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   130
    ifeq ($$($1_POST_COMMAND), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   131
      $1_EXEC_RESULT := $$($1_OUTPUT_FILE)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   132
      $1_FINAL_RESULT := $$($1_EXEC_RESULT)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   133
    else
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   134
      $1_EXEC_RESULT := $$($1_EXEC_MARKER)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   135
      $1_FINAL_RESULT := $$($1_OUTPUT_FILE)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   136
    endif
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   137
57155
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   138
  endif
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   139
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   140
  ifeq ($$($1_INFO)$$($1_WARN), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   141
    # If neither info nor warn is provided, add basic info text.
57158
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
   142
    $1_INFO := Running commands for $1
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
   143
  endif
003703d03633 Bug fixes. Now hotspot works.
ihse
parents: 57155
diff changeset
   144
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   145
  ifneq ($$($1_PRE_COMMAND), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   146
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   147
    $$($1_PRE_MARKER): $$($1_DEPS)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   148
        ifneq ($$($1_WARN), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   149
	  $$(call LogWarn, $$($1_WARN))
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   150
        endif
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   151
        ifneq ($$($1_INFO), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   152
	  $$(call LogInfo, $$($1_INFO))
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   153
        endif
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   154
	$$(call MakeDir, $$($1_SUPPORT_DIR) $$($1_OUTPUT_DIR))
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   155
	$$(call ExecuteWithLog, $$($1_BASE)_pre, \
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   156
	    $$($1_PRE_COMMAND))
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   157
	$$(TOUCH) $$@
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   158
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   159
    $$($1_EXEC_RESULT): $$($1_PRE_MARKER)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   160
	$$(call ExecuteWithLog, $$($1_BASE)_exec, \
57139
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
   161
	    $$($1_COMMAND))
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   162
        ifeq ($$($1_EXEC_RESULT), $$($1_EXEC_MARKER))
57155
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   163
	  $$(TOUCH) $$@
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   164
        endif
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   165
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   166
    $1 := $$($1_PRE_MARKER) $$($1_EXEC_RESULT)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   167
  else
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   168
    $$($1_EXEC_RESULT): $$($1_DEPS)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   169
        ifneq ($$($1_WARN), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   170
	  $$(call LogWarn, $$($1_WARN))
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   171
        endif
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   172
        ifneq ($$($1_INFO), )
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   173
	  $$(call LogInfo, $$($1_INFO))
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   174
        endif
57228
f802ad9cf3bc Use same logic as in MakeTargetDir.
ihse
parents: 57159
diff changeset
   175
	$$(call MakeDir, $$(call EncodeSpace, $$($1_SUPPORT_DIR)) $$(call EncodeSpace, $$($1_OUTPUT_DIR)))
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   176
	$$(call ExecuteWithLog, $$($1_BASE)_exec, \
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   177
	    $$($1_COMMAND))
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   178
        ifeq ($$($1_EXEC_RESULT), $$($1_EXEC_MARKER))
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   179
	  $$(TOUCH) $$@
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   180
        endif
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   181
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   182
    $1 := $$($1_EXEC_RESULT)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   183
  endif
57155
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   184
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   185
  ifneq ($$($1_POST_COMMAND), )
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   186
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   187
    $$($1_FINAL_RESULT): $$($1_EXEC_RESULT)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   188
	$$(call ExecuteWithLog, $$($1_BASE)_post, \
57155
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   189
	    $$($1_POST_COMMAND))
57139
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
   190
	$$(TOUCH) $$@
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
   191
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   192
    $1 += $$($1_FINAL_RESULT)
57155
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   193
  endif
ba61956ea598 Convert some more to SetupExecute.
ihse
parents: 57139
diff changeset
   194
57159
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   195
  # Export all our generated targets in $1, and the final target in $1_TARGET.
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   196
  $1_TARGET := $$($1_FINAL_RESULT)
0258a6f7d03f Adding SetupExecute to more places, and adding functionality.
ihse
parents: 57158
diff changeset
   197
57139
94ff48d6eee4 Initial implementation and test case of SetupExecute.
ihse
parents:
diff changeset
   198
endef