MCPcopy Create free account
hub / github.com/nodejs/node / _GenerateActionsForMSBuild

Function _GenerateActionsForMSBuild

tools/gyp/pylib/gyp/generator/msvs.py:3876–3938  ·  view source on GitHub ↗

Add actions accumulated into an actions_to_add, merging as needed. Arguments: spec: the target project dict actions_to_add: dictionary keyed on input name, which maps to a list of dicts describing the actions attached to that input file. Returns: A pair of (acti

(spec, actions_to_add)

Source from the content-addressed store, hash-verified

3874
3875
3876def _GenerateActionsForMSBuild(spec, actions_to_add):
3877 """Add actions accumulated into an actions_to_add, merging as needed.
3878
3879 Arguments:
3880 spec: the target project dict
3881 actions_to_add: dictionary keyed on input name, which maps to a list of
3882 dicts describing the actions attached to that input file.
3883
3884 Returns:
3885 A pair of (action specification, the sources handled by this action).
3886 """
3887 sources_handled_by_action = OrderedSet()
3888 actions_spec = []
3889 for primary_input, actions in actions_to_add.items():
3890 if generator_supports_multiple_toolsets:
3891 primary_input = primary_input.replace(".exe", "_host.exe")
3892 inputs = OrderedSet()
3893 outputs = OrderedSet()
3894 descriptions = []
3895 commands = []
3896 for action in actions:
3897
3898 def fixup_host_exe(i):
3899 if "$(OutDir)" in i:
3900 i = i.replace(".exe", "_host.exe")
3901 return i
3902
3903 if generator_supports_multiple_toolsets:
3904 action["inputs"] = [fixup_host_exe(i) for i in action["inputs"]]
3905 inputs.update(OrderedSet(action["inputs"]))
3906 outputs.update(OrderedSet(action["outputs"]))
3907 descriptions.append(action["description"])
3908 cmd = action["command"]
3909 if generator_supports_multiple_toolsets:
3910 cmd = cmd.replace(".exe", "_host.exe")
3911 # For most actions, add 'call' so that actions that invoke batch files
3912 # return and continue executing. msbuild_use_call provides a way to
3913 # disable this but I have not seen any adverse effect from doing that
3914 # for everything.
3915 if action.get("msbuild_use_call", True):
3916 cmd = "call " + cmd
3917 commands.append(cmd)
3918 # Add the custom build action for one input file.
3919 description = ", and also ".join(descriptions)
3920
3921 # We can't join the commands simply with && because the command line will
3922 # get too long. See also _AddActions: cygwin's setup_env mustn't be called
3923 # for every invocation or the command that sets the PATH will grow too
3924 # long.
3925 command = "\r\n".join(
3926 [c + "\r\nif %errorlevel% neq 0 exit /b %errorlevel%" for c in commands]
3927 )
3928 _AddMSBuildAction(
3929 spec,
3930 primary_input,
3931 inputs,
3932 outputs,
3933 command,

Callers 1

_GenerateMSBuildProjectFunction · 0.85

Calls 8

updateMethod · 0.95
OrderedSetClass · 0.90
fixup_host_exeFunction · 0.85
_AddMSBuildActionFunction · 0.85
getMethod · 0.65
itemsMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected