def copyDllFile(source_path, dest_path): """Copy an extension/DLL file making some adjustments on the way.""" copyFile(source_path=source_path, dest_path=dest_path) if isWin32Windows() and python_version < 0x300: _removeSxsFromDLL(dest_path) if isMacOS() and Options.getMacOSTargetArch() != "universal": makeMacOSThinBinary(dest_path)
def makeMacOSThinBinary(filename): file_output = executeToolChecked( logger=postprocessing_logger, command=("file", filename), absence_message=_file_usage, ) if str is not bytes: file_output = file_output.decode("utf8") assert file_output.startswith(filename + ":") file_output = file_output[len(filename) + 1:].splitlines()[0].strip() macos_target_arch = Options.getMacOSTargetArch() if "universal" in file_output: executeToolChecked( logger=postprocessing_logger, command=( "lipo", "-thin", macos_target_arch, filename, "-o", filename + ".tmp", ), absence_message=_lipo_usage, ) with withMadeWritableFileMode(filename): os.unlink(filename) os.rename(filename + ".tmp", filename) elif macos_target_arch not in file_output: postprocessing_logger.sysexit( "Error, cannot use file '%s' (%s) to build arch '%s' result" % (filename, file_output, macos_target_arch))
def setCommonOptions(options): # Scons gets transported many details, that we express as variables, and # have checks for them, leading to many branches and statements, # pylint: disable=too-many-branches if Options.shallRunInDebugger(): options["full_names"] = "true" if Options.assumeYesForDownloads(): options["assume_yes_for_downloads"] = asBoolStr(True) if not Options.shallUseProgressBar(): options["progress_bar"] = "false" if Options.isClang(): options["clang_mode"] = "true" if Options.isShowScons(): options["show_scons"] = "true" if Options.isMingw64(): options["mingw_mode"] = "true" if Options.getMsvcVersion(): options["msvc_version"] = Options.getMsvcVersion() if Options.shallDisableCCacheUsage(): options["disable_ccache"] = asBoolStr(True) if Options.shallDisableConsoleWindow(): options["disable_console"] = asBoolStr(True) if Options.getLtoMode() != "auto": options["lto_mode"] = Options.getLtoMode() cpp_defines = Plugins.getPreprocessorSymbols() if cpp_defines: options["cpp_defines"] = ",".join( "%s%s%s" % (key, "=" if value else "", value or "") for key, value in cpp_defines.items()) cpp_include_dirs = Plugins.getExtraIncludeDirectories() if cpp_include_dirs: options["cpp_include_dirs"] = ",".join(cpp_include_dirs) link_dirs = Plugins.getExtraLinkDirectories() if link_dirs: options["link_dirs"] = ",".join(link_dirs) link_libraries = Plugins.getExtraLinkLibraries() if link_libraries: options["link_libraries"] = ",".join(link_libraries) if Utils.isMacOS(): macos_min_version = detectBinaryMinMacOS(sys.executable) if macos_min_version is None: Tracing.general.sysexit( "Could not detect minimum macOS version for %r." % sys.executable) options["macos_min_version"] = macos_min_version macos_target_arch = Options.getMacOSTargetArch() if macos_target_arch == "universal": Tracing.general.sysexit( "Cannot create universal macOS binaries (yet), please pick an arch and create two binaries." ) options["macos_target_arch"] = macos_target_arch