Methods.py (SCons-4.3.0) | : | Methods.py (SCons-4.4.0) | ||
---|---|---|---|---|
skipping to change at line 78 | skipping to change at line 78 | |||
def set_build_node_callback(env, node, callback): | def set_build_node_callback(env, node, callback): | |||
if not node.is_conftest(): | if not node.is_conftest(): | |||
node.attributes.ninja_build_callback = callback | node.attributes.ninja_build_callback = callback | |||
def get_generic_shell_command(env, node, action, targets, sources, executor=None ): | def get_generic_shell_command(env, node, action, targets, sources, executor=None ): | |||
return ( | return ( | |||
"GENERATED_CMD", | "GENERATED_CMD", | |||
{ | { | |||
"cmd": generate_command(env, node, action, targets, sources, executo r=executor), | "cmd": generate_command(env, node, action, targets, sources, executo r=executor), | |||
"env": get_command_env(env), | "env": get_command_env(env, targets, sources), | |||
}, | }, | |||
# Since this function is a rule mapping provider, it must return a list of dependencies, | # Since this function is a rule mapping provider, it must return a list of dependencies, | |||
# and usually this would be the path to a tool, such as a compiler, used for this rule. | # and usually this would be the path to a tool, such as a compiler, used for this rule. | |||
# However this function is to generic to be able to reliably extract suc h deps | # However this function is to generic to be able to reliably extract suc h deps | |||
# from the command, so we return a placeholder empty list. It should be noted that | # from the command, so we return a placeholder empty list. It should be noted that | |||
# generally this function will not be used solely and is more like a tem plate to generate | # generally this function will not be used solely and is more like a tem plate to generate | |||
# the basics for a custom provider which may have more specific options for a provider | # the basics for a custom provider which may have more specific options for a provider | |||
# function for a custom NinjaRuleMapping. | # function for a custom NinjaRuleMapping. | |||
[] | [] | |||
) | ) | |||
skipping to change at line 129 | skipping to change at line 129 | |||
executor = node.get_executor() | executor = node.get_executor() | |||
tlist, slist = get_targets_sources(node) | tlist, slist = get_targets_sources(node) | |||
# Generate a real CommandAction | # Generate a real CommandAction | |||
if isinstance(action, SCons.Action.CommandGeneratorAction): | if isinstance(action, SCons.Action.CommandGeneratorAction): | |||
# pylint: disable=protected-access | # pylint: disable=protected-access | |||
action = action._generate(tlist, slist, sub_env, SUBST_CMD, executor=exe cutor) | action = action._generate(tlist, slist, sub_env, SUBST_CMD, executor=exe cutor) | |||
variables = {} | variables = {} | |||
comstr = get_comstr(sub_env, action, tlist, slist) | # since we will check the ninja rule map for this command str, we must make | |||
sure | ||||
# its string so its hashable. | ||||
comstr = str(get_comstr(sub_env, action, tlist, slist)) | ||||
if not comstr: | if not comstr: | |||
return None | return None | |||
provider = __NINJA_RULE_MAPPING.get(comstr, get_generic_shell_command) | provider = __NINJA_RULE_MAPPING.get(comstr, get_generic_shell_command) | |||
rule, variables, provider_deps = provider(sub_env, node, action, tlist, slis t, executor=executor) | rule, variables, provider_deps = provider(sub_env, node, action, tlist, slis t, executor=executor) | |||
if node.get_env().get('NINJA_FORCE_SCONS_BUILD'): | if node.get_env().get('NINJA_FORCE_SCONS_BUILD'): | |||
rule = 'TEMPLATE' | rule = 'TEMPLATE' | |||
# Get the dependencies for all targets | # Get the dependencies for all targets | |||
implicit = list({dep for tgt in tlist for dep in get_dependencies(tgt)}) | implicit = list({dep for tgt in tlist for dep in get_dependencies(tgt)}) | |||
skipping to change at line 249 | skipping to change at line 251 | |||
# Add 1 so we always keep the actual tool inside of cmd | # Add 1 so we always keep the actual tool inside of cmd | |||
tool_idx = cmd_list.index(tool_command) + 1 | tool_idx = cmd_list.index(tool_command) + 1 | |||
except ValueError: | except ValueError: | |||
raise Exception( | raise Exception( | |||
"Could not find tool {} in {} generated from {}".format( | "Could not find tool {} in {} generated from {}".format( | |||
tool, cmd_list, get_comstr(env, action, targets, sources) | tool, cmd_list, get_comstr(env, action, targets, sources) | |||
) | ) | |||
) | ) | |||
cmd, rsp_content = cmd_list[:tool_idx], cmd_list[tool_idx:] | cmd, rsp_content = cmd_list[:tool_idx], cmd_list[tool_idx:] | |||
# Canonicalize the path to have forward (posix style) dir sep characters | ||||
. | ||||
if os.altsep: | ||||
rsp_content = [rsp_content_item.replace(os.sep, os.altsep) for rsp_c | ||||
ontent_item in rsp_content] | ||||
rsp_content = ['"' + rsp_content_item + '"' for rsp_content_item in rsp_ content] | rsp_content = ['"' + rsp_content_item + '"' for rsp_content_item in rsp_ content] | |||
rsp_content = " ".join(rsp_content) | rsp_content = " ".join(rsp_content) | |||
variables = {"rspc": rsp_content, rule: cmd} | variables = {"rspc": rsp_content, rule: cmd} | |||
if use_command_env: | if use_command_env: | |||
variables["env"] = get_command_env(env) | variables["env"] = get_command_env(env, targets, sources) | |||
for key, value in custom_env.items(): | for key, value in custom_env.items(): | |||
variables["env"] += env.subst( | variables["env"] += env.subst( | |||
"export %s=%s;" % (key, value), target=targets, source=sourc es, executor=executor | "export %s=%s;" % (key, value), target=targets, source=sourc es, executor=executor | |||
) + " " | ) + " " | |||
if node.get_env().get('NINJA_FORCE_SCONS_BUILD'): | if node.get_env().get('NINJA_FORCE_SCONS_BUILD'): | |||
ret_rule = 'TEMPLATE' | ret_rule = 'TEMPLATE' | |||
else: | else: | |||
ret_rule = rule | if len(' '.join(cmd_list)) < env.get('MAXLINELENGTH', 2048): | |||
ret_rule = rule | ||||
else: | ||||
ret_rule = rule + '_RSP' | ||||
return ret_rule, variables, [tool_command] | return ret_rule, variables, [tool_command] | |||
return get_response_file_command | return get_response_file_command | |||
End of changes. 5 change blocks. | ||||
4 lines changed or deleted | 16 lines changed or added |