| Index: pylib/gyp/mac_tool.py
|
| diff --git a/pylib/gyp/mac_tool.py b/pylib/gyp/mac_tool.py
|
| index eeeaceb0c7aa2388635855260b3d63edc58cd73a..f68c3d9c281e91eb48a04c7955455f2ea70f47aa 100755
|
| --- a/pylib/gyp/mac_tool.py
|
| +++ b/pylib/gyp/mac_tool.py
|
| @@ -153,7 +153,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 +341,56 @@ class MacTool(object):
|
| command_line.extend(map(os.path.abspath, inputs))
|
| subprocess.check_call(command_line)
|
|
|
| + def ExecCopySwiftLibs(self, swift_libs_dir, app_framework_dir, *inputs):
|
| + libs = set()
|
| + inputs = set(inputs)
|
| + while inputs:
|
| + input_file = inputs.pop()
|
| + symbols = subprocess.check_output(['nm', input_file])
|
| + for m in re.finditer(r'__swift_FORCE_LOAD_\$_(\w+)$', symbols,
|
| + re.MULTILINE):
|
| + lib_name = 'lib' + m.group(1) + '.dylib'
|
| + if not lib_name in libs:
|
| + lib_path = os.path.join(swift_libs_dir, lib_name)
|
| + inputs.add(lib_path)
|
| + libs.add(lib_name)
|
| + if not os.path.exists(app_framework_dir):
|
| + os.makedirs(app_framework_dir)
|
| +
|
| + if libs:
|
| + # This lib is not linked from anywhere directly,
|
| + # but is needed for the app to run with Swift
|
| + libs.add('libswiftCore.dylib')
|
| +
|
| + for lib in libs:
|
| + src = os.path.join(swift_libs_dir, lib)
|
| + dst = os.path.join(app_framework_dir, lib)
|
| + shutil.copyfile(src, dst)
|
| +
|
| + def ExecBuildModuleMapFile(self, module_name, umbrella_header, map_file,
|
| + stamp):
|
| + if not os.path.exists(os.path.dirname(map_file)):
|
| + os.makedirs(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))
|
| + subprocess.check_call(['touch', stamp])
|
| +
|
| + def ExecAppendSwiftToModuleMapFile(self, module_name, swift_header, map_file,
|
| + stamp):
|
| + if not os.path.exists(os.path.dirname(map_file)):
|
| + os.makedirs(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))
|
| + subprocess.check_call(['touch', stamp])
|
| +
|
| def ExecMergeInfoPlist(self, output, *inputs):
|
| """Merge multiple .plist files into a single .plist file."""
|
| merged_plist = {}
|
|
|