Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1551)

Unified Diff: pylib/gyp/mac_tool.py

Issue 1160773005: Support for Swift language and Clang modules for ninja generator. Base URL: https://chromium.googlesource.com/external/gyp@master
Patch Set: Fixed rare build failure when compiling with modules for multiple archs Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pylib/gyp/generator/ninja.py ('k') | pylib/gyp/xcode_emulation.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pylib/gyp/mac_tool.py
diff --git a/pylib/gyp/mac_tool.py b/pylib/gyp/mac_tool.py
index eeeaceb0c7aa2388635855260b3d63edc58cd73a..8a6fe964ea830ce2ecb49e1d2e6e015a90522b82 100755
--- a/pylib/gyp/mac_tool.py
+++ b/pylib/gyp/mac_tool.py
@@ -8,6 +8,7 @@
These functions are executed via gyp-mac-tool when using the Makefile generator.
"""
+import errno
import fcntl
import fnmatch
import glob
@@ -153,7 +154,7 @@ class MacTool(object):
# Go through all the environment variables and replace them as variables in
# the file.
- IDENT_RE = re.compile(r'[/\s]')
+ IDENT_RE = re.compile(r'[/\s_-]')
for key in os.environ:
if key.startswith('_'):
continue
@@ -341,6 +342,64 @@ class MacTool(object):
command_line.extend(map(os.path.abspath, inputs))
subprocess.check_call(command_line)
+ def _EnsureDirExists(self, dir_path):
+ if not os.path.exists(dir_path):
+ try:
+ os.makedirs(dir_path)
+ except OSError as exc:
+ if exc.errno != errno.EEXIST:
+ raise
+
+ def _MakeStamp(self, stamp):
+ self._EnsureDirExists(os.path.dirname(stamp))
+ subprocess.check_call(['touch', stamp])
+
+ def ExecCopySwiftLibs(self, executable_path, platform, dst_path, codesign_key,
+ stamp):
+ args = [
+ 'xcrun', 'swift-stdlib-tool', '--copy',
+ '--scan-executable', executable_path,
+ '--platform', platform,
+ '--destination', dst_path,
+ ]
+ if codesign_key:
+ args.extend(['--sign', codesign_key])
+
+ # Using only PATH variable from environment,
+ # to prevent swift-stdlib-tool from using variables like
+ # CODE_SIGNING_REQUIRED which may be set by Xcode
+ env = {'PATH' : os.environ.get('PATH', '')}
+ p = subprocess.Popen(args, env=env)
+ retcode = p.wait()
+ if retcode != 0:
+ raise subprocess.CalledProcessError(retcode, args)
+
+ self._MakeStamp(stamp)
+
+ def ExecBuildModuleMapFile(self, module_name, umbrella_header, map_file,
+ stamp):
+ self._EnsureDirExists(os.path.dirname(map_file))
+ with open(map_file, 'w') as f:
+ f.write(
+ 'framework module %s {\n'
+ ' umbrella header \"%s\"\n'
+ ' export *\n'
+ ' module * { export * }\n'
+ '}\n' % (module_name, umbrella_header))
+
+ self._MakeStamp(stamp)
+
+ def ExecAppendSwiftToModuleMapFile(self, module_name, swift_header, map_file,
+ stamp):
+ self._EnsureDirExists(os.path.dirname(map_file))
+ with open(map_file, 'a') as f:
+ f.write(
+ 'module %s.Swift {\n'
+ ' header \"%s\"\n'
+ '}\n' % (module_name, swift_header))
+
+ self._MakeStamp(stamp)
+
def ExecMergeInfoPlist(self, output, *inputs):
"""Merge multiple .plist files into a single .plist file."""
merged_plist = {}
« no previous file with comments | « pylib/gyp/generator/ninja.py ('k') | pylib/gyp/xcode_emulation.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698