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

Function _BuildCommandLineForRuleRaw

tools/gyp/pylib/gyp/generator/msvs.py:361–438  ·  view source on GitHub ↗
(
    spec, cmd, cygwin_shell, has_input_path, quote_cmd, do_setup_env
)

Source from the content-addressed store, hash-verified

359
360
361def _BuildCommandLineForRuleRaw(
362 spec, cmd, cygwin_shell, has_input_path, quote_cmd, do_setup_env
363):
364 if [x for x in cmd if "$(InputDir)" in x]:
365 input_dir_preamble = (
366 "set INPUTDIR=$(InputDir)\n"
367 "if NOT DEFINED INPUTDIR set INPUTDIR=.\\\n"
368 "set INPUTDIR=%INPUTDIR:~0,-1%\n"
369 )
370 else:
371 input_dir_preamble = ""
372
373 if cygwin_shell:
374 # Find path to cygwin.
375 cygwin_dir = _FixPath(spec.get("msvs_cygwin_dirs", ["."])[0])
376 # Prepare command.
377 direct_cmd = cmd
378 direct_cmd = [
379 i.replace("$(IntDir)", '`cygpath -m "${INTDIR}"`') for i in direct_cmd
380 ]
381 direct_cmd = [
382 i.replace("$(OutDir)", '`cygpath -m "${OUTDIR}"`') for i in direct_cmd
383 ]
384 direct_cmd = [
385 i.replace("$(InputDir)", '`cygpath -m "${INPUTDIR}"`') for i in direct_cmd
386 ]
387 if has_input_path:
388 direct_cmd = [
389 i.replace("$(InputPath)", '`cygpath -m "${INPUTPATH}"`')
390 for i in direct_cmd
391 ]
392 direct_cmd = ['\\"%s\\"' % i.replace('"', '\\\\\\"') for i in direct_cmd]
393 # direct_cmd = gyp.common.EncodePOSIXShellList(direct_cmd)
394 direct_cmd = " ".join(direct_cmd)
395 # TODO(quote): regularize quoting path names throughout the module
396 cmd = ""
397 if do_setup_env:
398 cmd += 'call "$(ProjectDir)%(cygwin_dir)s\\setup_env.bat" && '
399 cmd += "set CYGWIN=nontsec&& "
400 if direct_cmd.find("NUMBER_OF_PROCESSORS") >= 0:
401 cmd += "set /a NUMBER_OF_PROCESSORS_PLUS_1=%%NUMBER_OF_PROCESSORS%%+1&& "
402 if direct_cmd.find("INTDIR") >= 0:
403 cmd += "set INTDIR=$(IntDir)&& "
404 if direct_cmd.find("OUTDIR") >= 0:
405 cmd += "set OUTDIR=$(OutDir)&& "
406 if has_input_path and direct_cmd.find("INPUTPATH") >= 0:
407 cmd += "set INPUTPATH=$(InputPath) && "
408 cmd += 'bash -c "%(cmd)s"'
409 cmd = cmd % {"cygwin_dir": cygwin_dir, "cmd": direct_cmd}
410 return input_dir_preamble + cmd
411 else:
412 # Convert cat --> type to mimic unix.
413 command = ["type"] if cmd[0] == "cat" else [cmd[0].replace("/", "\\")]
414 # Add call before command to ensure that commands can be tied together one
415 # after the other without aborting in Incredibuild, since IB makes a bat
416 # file out of the raw command string, and some commands (like python) are
417 # actually batch files themselves.
418 command.insert(0, "call")

Callers 3

_BuildCommandLineForRuleFunction · 0.85
_GenerateExternalRulesFunction · 0.85

Calls 5

_FixPathFunction · 0.85
getMethod · 0.65
findMethod · 0.65
joinMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected