def _runOnefileScons(quiet): 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), } SconsInterface.setCommonOptions(options) onefile_env_values = {} if Options.isWindowsOnefileTempDirMode() or getOS() != "Windows": onefile_env_values["ONEFILE_TEMP_SPEC"] = Options.getWindowsOnefileTempDirSpec( use_default=True ) else: # Merge version information if possible, 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 _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)