Example #1
0
    def Build(self, env):

        output_files = self.GetOutputFiles(env)
        Utils.Print(env, "Linking: " + output_files[0] + "\n")

        # Construct the command-line
        cmdline = ["link.exe"] + env.CurrentConfig.LinkOptions.CommandLine
        cmdline += ['/OUT:' + output_files[0]]
        if env.CurrentConfig.LinkOptions.MapFile:
            cmdline += ["/MAP:" + output_files[1]]
        cmdline += [dep.GetOutputFiles(env)[0] for dep in self.Dependencies]
        cmdline += [dep.GetOutputFiles(env)[0] for dep in self.LibFiles]
        cmdline += [dep.GetOutputFiles(env)[0] for dep in self.WeakLibFiles]
        Utils.ShowCmdLine(env, cmdline)

        #
        # When library files get added as dependencies to this link node they get added without a path.
        # This requires the linker to check its list of search paths for the location of any input
        # library files.
        #
        # The build system however, needs full paths to evaluate dependencies on each build. Rather than
        # trying to search the library paths in the build system (and potentially getting them wrong/different
        # to the linker), the linker is asked to output the full path of all libraries it links with. These
        # then get added as implicit dependencies.
        #
        # Create the lib scanner and run the link process
        #
        scanner = Utils.LineScanner(env)
        scanner.AddLineParser(
            "Includes", "Searching ",
            ["Searching libraries", "Finished searching libraries"],
            lambda line, length: line[length:-1])
        process = Process.OpenPiped(cmdline, env.EnvironmentVariables)
        Process.PollPipeOutput(process, scanner)

        #
        # Weak library files are those that should be provided as input to the link step but not used
        # as dependencies to check if the link step needs to be rebuilt. Search for those in the scanner
        # output and exclude them from the implicit dependency list.
        #
        includes = []
        for include in scanner.Includes:

            ignore_dep = False
            for lib in self.WeakLibFiles:
                lib_name = lib.GetInputFile(env)
                if lib_name in include:
                    ignore_dep = True
                    break

            if not ignore_dep:
                includes.append(include)

        # Record the implicit dependencies for this file
        data = env.GetFileMetadata(self.GetInputFile(env))
        data.SetImplicitDeps(env, includes)

        return process.returncode == 0
Example #2
0
def Extract7ZipFileTo(filename, path):
    if SevenZipExe == None:
        print("ERROR: 7-Zip has not been installed. Call Install7Zip first.")
        return

    # Use previously-installed 7zip
    command_line = f"{SevenZipExe} x -o{path} {filename}"
    process = Process.OpenPiped(command_line)
    Process.PollPipeOutput(process, lambda t: print(t.strip("\r\n")))
Example #3
0
    def Build(self, env):

        output_files = self.GetOutputFiles(env)

        # Construct the command-line
        cpp_opts = self.GetCPPOptions(env)
        cmdline = ["cl.exe"] + cpp_opts.CommandLine
        if len(output_files) > 1:
            cmdline += ["/Fd" + output_files[1]]
        cmdline += ["/Fo" + output_files[0], self.GetInputFile(env)]
        Utils.ShowCmdLine(env, cmdline)

        # Create the include scanner and launch the compiler
        scanner = Utils.LineScanner(env)
        scanner.AddLineParser("Includes", "Note: including file:", None,
                              lambda line, length: line[length:].lstrip())
        process = Process.OpenPiped(cmdline, env.EnvironmentVariables)
        Process.PollPipeOutput(process, scanner)

        # Record the implicit dependencies for this file
        data = env.GetFileMetadata(self.GetInputFile(env))
        data.SetImplicitDeps(env, scanner.Includes)

        return process.returncode == 0