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

Function CopyTool

tools/gyp/pylib/gyp/common.py:526–561  ·  view source on GitHub ↗

Finds (flock|mac|win)_tool.gyp in the gyp directory and copies it to |out_path|.

(flavor, out_path, generator_flags={})

Source from the content-addressed store, hash-verified

524
525
526def CopyTool(flavor, out_path, generator_flags={}):
527 """Finds (flock|mac|win)_tool.gyp in the gyp directory and copies it
528 to |out_path|."""
529 # aix and solaris just need flock emulation. mac and win use more complicated
530 # support scripts.
531 prefix = {
532 "aix": "flock",
533 "os400": "flock",
534 "solaris": "flock",
535 "mac": "mac",
536 "ios": "mac",
537 "win": "win",
538 }.get(flavor, None)
539 if not prefix:
540 return
541
542 # Slurp input file.
543 source_path = os.path.join(
544 os.path.dirname(os.path.abspath(__file__)), "%s_tool.py" % prefix
545 )
546 with open(source_path) as source_file:
547 source = source_file.readlines()
548
549 # Set custom header flags.
550 header = "# Generated by gyp. Do not edit.\n"
551 mac_toolchain_dir = generator_flags.get("mac_toolchain_dir", None)
552 if flavor == "mac" and mac_toolchain_dir:
553 header += "import os;\nos.environ['DEVELOPER_DIR']='%s'\n" % mac_toolchain_dir
554
555 # Add header and write it out.
556 tool_path = os.path.join(out_path, "gyp-%s-tool" % prefix)
557 with open(tool_path, "w") as tool_file:
558 tool_file.write("".join([source[0], header] + source[1:]))
559
560 # Make file executable.
561 os.chmod(tool_path, 0o755)
562
563
564# From Alex Martelli,

Callers

nothing calls this directly

Calls 5

getMethod · 0.65
openFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45
chmodMethod · 0.45

Tested by

no test coverage detected