Ejemplo n.º 1
0
def GetVisualCEnv():

    if VSInstallDir == None:
        print("ERROR: Visual Studio install directory not detected")
        return None

    # Locate the batch file that sets up the Visual C build environment
    if not os.path.exists(VCVarsPath):
        print("ERROR: Visual C environment setup batch file not found")
        return None

    # Run the batch file, output the environment and prepare it for parsing
    process = Process.OpenPiped(VCVarsPath +
                                " x86 & echo ===ENVBEGIN=== & set")
    output = Process.WaitForPipeOutput(process)
    output = output.split("===ENVBEGIN=== \r\n")[1]
    output = output.splitlines()

    # Start with the current environment, override with any parsed environment values
    env = os.environ.copy()
    for line in output:
        try:
            var, value = line.split("=")
            env[var.upper()] = value
        except:
            print("WARNING: environment variables skipped -> " + line)

    # This environment variable is defined in the VS2005 IDE and prevents cl.exe output
    # being correctly captured, so remove it!
    if "VS_UNICODE_OUTPUT" in env:
        del env["VS_UNICODE_OUTPUT"]

    return env
Ejemplo n.º 2
0
    def Build(self, env):

        # Node entry point takes precedence over config specified entry-point
        entry_point = self.EntryPoint
        if entry_point == None:
            entry_point = env.CurrentConfig.ShaderCompileOptions.EntryPoint

        # Build command line
        cmdline = [ os.path.join(ShaderCompilerPath, "ShaderCompiler.exe") ]
        cmdline += [ '/T' + self.Profile ]
        cmdline += env.CurrentConfig.ShaderCompileOptions.CommandLine
        cmdline += self.DefineCmdLine
        cmdline += self.BuildCommandLine
        if entry_point:
            cmdline += [ '/E' + entry_point ]
        cmdline += [ "/ShowCppOutputs" ]
        if ShowTrace:
            cmdline += [ "/trace" ]
        cmdline += [ self.Path ]
        Utils.ShowCmdLine(env, cmdline)

        # Create the include scanner and launch the compiler
        scanner = Utils.LineScanner(env)
        scanner.AddLineParser("Includes", "cpp: included", None, lambda line, length: line.lstrip()[15:-1])
        scanner.AddLineParser("Outputs", "cpp: output", None, lambda line, length: line.lstrip()[12:])
        process = Process.OpenPiped(cmdline, env.EnvironmentVariables)
        Process.WaitForPipeOutput(process, scanner)

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

        return process.returncode == 0
Ejemplo n.º 3
0
    def Build(self, env):

        # Ensure command -line for current configuration is up-to-date
        options = self.OptionsMap[env.CurrentConfig.CmdLineArg]
        options.UpdateCommandLine()

        # Augment command-line with current environment
        cmdline = [os.path.join(_InstallPath, "wave.exe")]
        cmdline += self.OptionsMap[env.CurrentConfig.CmdLineArg].CommandLine
        cmdline += ['--output=' + self.GetOutputFiles(env)[0]]
        cmdline += ['--listincludes=-']
        cmdline += [self.GetInputFile(env)]
        Utils.ShowCmdLine(env, cmdline)

        # Launch Wave with a dependency scanner and wait for it to finish
        scanner = Utils.LineScanner(env)
        scanner.AddLineParser(
            "Includes", '"', ["<"],
            lambda line, length: line.split("(")[1].rstrip()[:-1])
        process = Process.OpenPiped(cmdline, env.EnvironmentVariables)
        Process.WaitForPipeOutput(process, scanner)

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

        return process.returncode == 0
Ejemplo n.º 4
0
    def Build(self, env):

        input_file = self.GetInputFile(env)
        output_files = self.GetOutputFiles(env)
        print("clscan: " + os.path.basename(input_file))

        # Construct the command-line
        cmdline = [_MakePath("clscan.exe")]
        cmdline += [input_file]
        cmdline += ["-output", output_files[0]]
        cmdline += ["-ast_log", output_files[1]]
        cmdline += ["-spec_log", output_files[2]]
        for path in self.SysIncludePaths:
            cmdline += ["-isystem", path]
        for path in self.IncludePaths:
            cmdline += ["-i", path]
        for define in self.Defines:
            cmdline += ["-D", define]
        Utils.ShowCmdLine(env, cmdline)

        # Launch the scanner and wait for it to finish
        output = Utils.LineScanner(env)
        output.AddLineParser("Includes", "Included:", None,
                             lambda line, length: line[length:].lstrip())
        process = Process.OpenPiped(cmdline)
        Process.WaitForPipeOutput(process, output)

        return process.returncode == 0
Ejemplo n.º 5
0
    def Build(self, env):

        output_files = self.GetOutputFiles(env)

        # Node entry point takes precendence over config specified entry-point
        entry_point = self.EntryPoint
        if entry_point == None:
            entry_point = env.CurrentConfig.FXCompileOptions.EntryPoint

        # Build command line
        cmdline = [os.path.join(x86BinDir, "fxc.exe")]
        cmdline += [self.Path, '/T' + self.Profile]
        cmdline += env.CurrentConfig.FXCompileOptions.CommandLine
        cmdline += self.DefineCmdLine
        cmdline += self.BuildCommandLine
        if entry_point:
            cmdline += ['/E' + entry_point]
        Utils.ShowCmdLine(env, cmdline)

        # Create the include scanner and launch the compiler
        scanner = Utils.LineScanner(env)
        scanner.AddLineParser("Includes", "Resolved to [",
                              ["Opening file [", "Current working dir ["],
                              lambda line, length: line[length:-1].lstrip())
        process = Process.OpenPiped(cmdline, env.EnvironmentVariables)
        Process.WaitForPipeOutput(process, scanner)

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

        return process.returncode == 0
Ejemplo n.º 6
0
    def Build(self, env):

        # Ensure command -line for current configuration is up-to-date
        options = self.OptionsMap[env.CurrentConfig.CmdLineArg]
        options.UpdateCommandLine()

        output_files = self.GetOutputFiles(env)

        # Build command-line from current configuration
        cmdline = [os.path.join(_InstallPath, "cbpp.exe")]
        cmdline += [self.GetInputFile(env)]
        cmdline += options.CommandLine
        cmdline += ["-noheader"]
        cmdline += ["-output", output_files[0]]
        cmdline += ["-show_includes"]
        if len(output_files) > 1:
            cmdline += ["-output_bin", output_files[1]]
        cmdline += ["-target", self.Target]
        Utils.ShowCmdLine(env, cmdline)

        # Launch cbpp with a dependency scanner and wait for it to finish
        scanner = Utils.LineScanner(env)
        scanner.AddLineParser("Includes", 'cpp: included "', None,
                              lambda line, length: line[length:-1])
        process = Process.OpenPiped(cmdline, env.EnvironmentVariables)
        Process.WaitForPipeOutput(process, scanner)

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

        return process.returncode == 0
Ejemplo n.º 7
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
Ejemplo n.º 8
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")))
Ejemplo n.º 9
0
    def Build(self, env):

        output_files = self.GetOutputFiles(env)

        # Construct the command-line
        cmdline = ["lib.exe"] + env.CurrentConfig.LibOptions.CommandLine
        cmdline += ['/OUT:' + output_files[0]]
        cmdline += [dep.GetOutputFiles(env)[0] for dep in self.Dependencies]
        cmdline += [dep.GetOutputFiles(env)[0] for dep in self.LibFiles]
        Utils.Print(env, "Librarian: " + output_files[0])
        Utils.ShowCmdLine(env, cmdline)

        # Run the librarian process
        process = Process.OpenPiped(cmdline, env.EnvironmentVariables)
        output = Process.WaitForPipeOutput(process)
        if not env.NoToolOutput:
            Utils.Print(env, output)

        return process.returncode == 0
Ejemplo n.º 10
0
    def Build(self, env):

        output_file = self.GetOutputFiles(env)[0]
        print("clmerge: " + os.path.basename(output_file))

        # Construct the command-line
        cmdline = [_MakePath("clmerge.exe")]
        cmdline += [output_file]
        if self.CppCodeGen != None:
            cmdline += ["-cpp_codegen", self.CppCodeGen.GetInputFile(env)]
        cmdline += [file.GetOutputFiles(env)[0] for file in self.Dependencies]
        Utils.ShowCmdLine(env, cmdline)

        # Launch the merger and wait for it to finish
        process = Process.OpenPiped(cmdline)
        output = Process.WaitForPipeOutput(process)
        if not env.NoToolOutput:
            print(output)

        return process.returncode == 0
Ejemplo n.º 11
0
    def Build(self, env):

        input_file = self.GetInputFile(env)
        output_files = self.GetOutputFiles(env)
        Utils.Print(
            env,
            "clscan: " + Utils.GetOSFilename(os.path.basename(input_file)))

        # Construct the command-line
        cmdline = [_MakePath("clscan.exe")]
        cmdline += [input_file]
        cmdline += ["--output", output_files[0]]
        cmdline += ["--ast_log", output_files[1]]
        cmdline += ["--spec_log", output_files[2]]
        cmdline += ["--"]
        cmdline += ["-fdiagnostics-format=msvc"]
        cmdline += ["-D__clcpp_parse__"]
        cmdline += ["-m32"]
        cmdline += ["-fms-extensions"]
        cmdline += ["-fms-compatibility"]
        cmdline += ["-mms-bitfields"]
        cmdline += ["-fdelayed-template-parsing"]
        cmdline += ["-std=c++17"]
        cmdline += ["-fno-rtti"]
        cmdline += ["-Wno-microsoft-enum-forward-reference"]
        for path in self.SysIncludePaths:
            cmdline += ["-isystem", path]
        for path in self.IncludePaths:
            cmdline += ["-I", path]
        for define in self.Defines:
            cmdline += ["-D", define]
        Utils.ShowCmdLine(env, cmdline)

        # Launch the scanner and wait for it to finish
        output = Utils.LineScanner(env)
        output.AddLineParser("Includes", "Included:", None,
                             lambda line, length: line[length:].lstrip())
        process = Process.OpenPiped(cmdline)
        Process.WaitForPipeOutput(process, output)

        return process.returncode == 0
Ejemplo n.º 12
0
    def Build(self, env):

        # Build command-line from current configuration
        cmdline = [ os.path.join(_InstallPath, "oclpc.exe") ]
        cmdline += env.CurrentConfig.OpenCLCompileOptions.CommandLine
        cmdline += [ self.GetInputFile(env) ]
        Utils.ShowCmdLine(env, cmdline)

        # Launch the compiler and wait for it to finish
        process = Process.OpenPiped(cmdline)
        output = Process.WaitForPipeOutput(process)
        if not env.NoToolOutput:
            print(output)

        # Write a dummy output file on build success
        if process.returncode == 0:
            output_files = self.GetOutputFiles(env)
            with open(output_files[0], "w") as out_file:
                print("Built successfully", file=out_file)

        return process.returncode == 0
Ejemplo n.º 13
0
    def Build(self, env):

        input_file = self.GetInputFile(env)
        output_file = self.GetOutputFiles(env)[0]
        Utils.Print(env, "clexport: " + os.path.basename(output_file))

        # Construct the command-line
        cmdline = [_MakePath("clexport.exe")]
        cmdline += [input_file]
        cmdline += ["-cpp", output_file]
        cmdline += ["-cpp_log", output_file + ".log"]
        if self.MapFile != None:
            cmdline += ["-map", self.MapFile.GetOutputFiles(env)[0]]
        Utils.ShowCmdLine(env, cmdline)

        # Launch the exporter and wait for it to finish
        process = Process.OpenPiped(cmdline)
        output = Process.WaitForPipeOutput(process)
        if not env.NoToolOutput:
            Utils.Print(env, output)

        return process.returncode == 0
Ejemplo n.º 14
0
    def Build(self, env):

        # Build command-line from current configuration
        cmdline = [ os.path.join(BinDir, "nvcc.exe") ]
        cmdline += [ '--ptx' ]
        cmdline += env.CurrentConfig.CUDACompileOptions.CommandLine

        # Add the output .ptx file
        output_files = self.GetOutputFiles(env)
        cmdline += [ '--output-file=' + output_files[0] ]

        # Add input file before finishing
        cmdline += [ self.GetInputFile(env) ]
        Utils.ShowCmdLine(env, cmdline)

        # Launch the compiler and wait for it to finish
        process = Process.OpenPiped(cmdline)
        output = Process.WaitForPipeOutput(process)
        if not env.NoToolOutput:
            print(output)

        return process.returncode == 0
Ejemplo n.º 15
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