def setCommonOptions(options): # Scons gets transported many details, that we express as variables, and # have checks for them, leading to many branches and statements, 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(): msvc_version = Options.getMsvcVersion() msvc_version = msvc_version.replace("exp", "Exp") if "." not in msvc_version: msvc_version += ".0" options["msvc_version"] = msvc_version if Options.shallDisableConsoleWindow(): options["win_disable_console"] = asBoolStr(True) if Options.isLto(): options["lto_mode"] = asBoolStr(True) 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() ) link_libraries = Plugins.getExtraLinkLibraries() if link_libraries: options["link_libraries"] = ",".join(link_libraries)
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
def _runOnefileScons(quiet): # 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,too-many-statements source_dir = OutputDirectories.getSourceDirectoryPath(onefile=True) SconsInterface.cleanSconsDirectory(source_dir) asBoolStr = SconsInterface.asBoolStr options = { "result_name": OutputDirectories.getResultBasepath(onefile=True), "result_exe": OutputDirectories.getResultFullpath(onefile=True), "source_dir": source_dir, "debug_mode": asBoolStr(Options.is_debug), "unstripped_mode": asBoolStr(Options.isUnstripped()), "experimental": ",".join(Options.getExperimentalIndications()), "trace_mode": asBoolStr(Options.shallTraceExecution()), "target_arch": getArchitecture(), "python_prefix": sys.prefix, "nuitka_src": SconsInterface.getSconsDataPath(), "compiled_exe": OutputDirectories.getResultFullpath(onefile=False), } # Ask Scons to cache on Windows, except where the directory is thrown # away. On non-Windows you can should use ccache instead. if not Options.isRemoveBuildDir() and getOS() == "Windows": options["cache_mode"] = "true" if Options.isLto(): options["lto_mode"] = "true" if Options.shallDisableConsoleWindow(): options["win_disable_console"] = "true" if Options.isShowScons(): options["show_scons"] = "true" if Options.isMingw64(): options["mingw_mode"] = "true" if Options.getMsvcVersion(): msvc_version = Options.getMsvcVersion() msvc_version = msvc_version.replace("exp", "Exp") if "." not in msvc_version: msvc_version += ".0" options["msvc_version"] = msvc_version if getOS() == "Windows": options["noelf_mode"] = "true" if Options.isClang(): options["clang_mode"] = "true" 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()) link_libraries = Plugins.getExtraLinkLibraries() if link_libraries: options["link_libraries"] = ",".join(link_libraries) if Options.shallRunInDebugger(): options["full_names"] = "true" if Options.assumeYesForDownloads(): options["assume_yes_for_downloads"] = "true" onefile_env_values = {} if not Options.isWindowsOnefileTempDirMode(): # Merge version information if necessary, to avoid collisions, or deep nesting # in file system. product_version = version_resources["ProductVersion"] file_version = version_resources["FileVersion"] if product_version != file_version: effective_version = "%s-%s" % (product_version, file_version) else: effective_version = file_version onefile_env_values["ONEFILE_COMPANY"] = version_resources[ "CompanyName"] onefile_env_values["ONEFILE_PRODUCT"] = version_resources[ "ProductName"] onefile_env_values["ONEFILE_VERSION"] = effective_version with withEnvironmentVarsOverriden(onefile_env_values): result = SconsInterface.runScons(options=options, quiet=quiet, scons_filename="WindowsOnefile.scons") # Exit if compilation failed. if not result: scons_logger.sysexit( "Error, one file bootstrap build for Windows failed.") if Options.isRemoveBuildDir(): general.info("Removing onefile build directory %r." % source_dir) removeDirectory(path=source_dir, ignore_errors=False) assert not os.path.exists(source_dir) else: general.info("Keeping onefile build directory %r." % source_dir)