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)
def runScons(main_module, 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 options = { "name": os.path.basename( OutputDirectories.getTreeFilenameWithSuffix(main_module, "")), "result_name": OutputDirectories.getResultBasepath(), "source_dir": OutputDirectories.getSourceDirectoryPath(), "debug_mode": _asBoolStr(Options.isDebug()), "python_debug": _asBoolStr(Options.isPythonDebug()), "unstripped_mode": _asBoolStr(Options.isUnstripped()), "module_mode": _asBoolStr(Options.shallMakeModule()), "full_compat": _asBoolStr(Options.isFullCompat()), "experimental": ",".join(Options.getExperimentalIndications()), "trace_mode": _asBoolStr(Options.shallTraceExecution()), "python_version": python_version_str, "target_arch": Utils.getArchitecture(), "python_prefix": sys.prefix, "nuitka_src": SconsInterface.getSconsDataPath(), "nuitka_cache": getCacheDir(), "module_count": "%d" % (1 + len(ModuleRegistry.getDoneUserModules()) + len(ModuleRegistry.getUncompiledNonTechnicalModules())), } if not Options.shallMakeModule(): options["result_exe"] = OutputDirectories.getResultFullpath() # 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 Utils.getOS() == "Windows": options["cache_mode"] = "true" if Options.isLto(): options["lto_mode"] = "true" if Options.shallUseStaticLibPython(): options["static_libpython"] = "true" if Options.shallDisableConsoleWindow(): options["win_disable_console"] = "true" if Options.isStandaloneMode(): options["standalone_mode"] = "true" if Options.shallTreatUninstalledPython(): options["uninstalled_python"] = "true" if ModuleRegistry.getUncompiledTechnicalModules(): options["frozen_modules"] = str( len(ModuleRegistry.getUncompiledTechnicalModules())) 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 Utils.getOS() == "Windows": options["noelf_mode"] = "true" if Options.isClang(): options["clang_mode"] = "true" if Options.getIconPath(): options["icon_path"] = Options.getIconPath() if Options.isProfile(): options["profile_mode"] = "true" if "no_warnings" in getPythonFlags(): options["no_python_warnings"] = "true" if "no_asserts" in getPythonFlags(): options["python_sysflag_optimize"] = "true" if python_version < 300 and sys.flags.py3k_warning: options["python_sysflag_py3k_warning"] = "true" if python_version < 300 and (sys.flags.division_warning or sys.flags.py3k_warning): options["python_sysflag_division_warning"] = "true" if sys.flags.bytes_warning: options["python_sysflag_bytes_warning"] = "true" if int( os.environ.get("NUITKA_SITE_FLAG", "no_site" in Options.getPythonFlags())): options["python_sysflag_no_site"] = "true" if "trace_imports" in Options.getPythonFlags(): options["python_sysflag_verbose"] = "true" if "no_randomization" in Options.getPythonFlags(): options["python_sysflag_no_randomization"] = "true" if python_version < 300 and sys.flags.unicode: options["python_sysflag_unicode"] = "true" if python_version >= 370 and sys.flags.utf8_mode: options["python_sysflag_utf8"] = "true" abiflags = getPythonABI() if abiflags: options["abiflags"] = abiflags 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) return SconsInterface.runScons(options, quiet), options