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

Class MacTool

tools/gyp/pylib/gyp/mac_tool.py:31–683  ·  view source on GitHub ↗

This class performs all the Mac tooling steps. The methods can either be executed directly, or dispatched from an argument list.

Source from the content-addressed store, hash-verified

29
30
31class MacTool:
32 """This class performs all the Mac tooling steps. The methods can either be
33 executed directly, or dispatched from an argument list."""
34
35 def Dispatch(self, args):
36 """Dispatches a string command to a method."""
37 if len(args) < 1:
38 raise Exception("Not enough arguments")
39
40 method = "Exec%s" % self._CommandifyName(args[0])
41 return getattr(self, method)(*args[1:])
42
43 def _CommandifyName(self, name_string):
44 """Transforms a tool name like copy-info-plist to CopyInfoPlist"""
45 return name_string.title().replace("-", "")
46
47 def ExecCopyBundleResource(self, source, dest, convert_to_binary):
48 """Copies a resource file to the bundle/Resources directory, performing any
49 necessary compilation on each resource."""
50 convert_to_binary = convert_to_binary == "True"
51 extension = os.path.splitext(source)[1].lower()
52 if os.path.isdir(source):
53 # Copy tree.
54 # TODO(thakis): This copies file attributes like mtime, while the
55 # single-file branch below doesn't. This should probably be changed to
56 # be consistent with the single-file branch.
57 if os.path.exists(dest):
58 shutil.rmtree(dest)
59 shutil.copytree(source, dest)
60 elif extension in {".xib", ".storyboard"}:
61 return self._CopyXIBFile(source, dest)
62 elif extension == ".strings" and not convert_to_binary:
63 self._CopyStringsFile(source, dest)
64 else:
65 if os.path.exists(dest):
66 os.unlink(dest)
67 shutil.copy(source, dest)
68
69 if convert_to_binary and extension in {".plist", ".strings"}:
70 self._ConvertToBinary(dest)
71
72 def _CopyXIBFile(self, source, dest):
73 """Compiles a XIB file with ibtool into a binary plist in the bundle."""
74
75 # ibtool sometimes crashes with relative paths. See crbug.com/314728.
76 base = os.path.dirname(os.path.realpath(__file__))
77 if os.path.relpath(source):
78 source = os.path.join(base, source)
79 if os.path.relpath(dest):
80 dest = os.path.join(base, dest)
81
82 args = ["xcrun", "ibtool", "--errors", "--warnings", "--notices"]
83
84 if os.environ["XCODE_VERSION_ACTUAL"] > "0700":
85 args.extend(["--auto-activate-custom-fonts"])
86 if "IPHONEOS_DEPLOYMENT_TARGET" in os.environ:
87 args.extend(
88 [

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected