Пример #1
0
def _runOnefileScons(quiet, onefile_compression):

    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),
        "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),
        "onefile_compression":
        asBoolStr(onefile_compression),
        "onefile_splash_screen":
        asBoolStr(Options.getWindowsSplashScreen() is not None),
    }

    if Options.isClang():
        options["clang_mode"] = "true"

    SconsInterface.setCommonOptions(options)

    onefile_env_values = {}

    if Options.isOnefileTempDirMode():
        onefile_env_values[
            "ONEFILE_TEMP_SPEC"] = Options.getOnefileTempDirSpec(
                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 withEnvironmentVarsOverridden(onefile_env_values):
        result = SconsInterface.runScons(options=options,
                                         quiet=quiet,
                                         scons_filename="Onefile.scons")

    # Exit if compilation failed.
    if not result:
        onefile_logger.sysexit("Error, onefile bootstrap binary build failed.")

    if Options.isRemoveBuildDir():
        onefile_logger.info("Removing onefile build directory %r." %
                            source_dir)

        removeDirectory(path=source_dir, ignore_errors=False)
        assert not os.path.exists(source_dir)
    else:
        onefile_logger.info("Keeping onefile build directory %r." % source_dir)