Exemple #1
0
    def doResource(self, message):
        task_folder = message['task_folder']
        task_data = message['task_data']
        tools_env = message['task_tools_env']
        cl_argv = task_data['cl_argv']
        rc_argv = task_data['rc_argv']

        inclusion_pattern = GetMsvcInclusionPattern(self.vars, tools_env)

        env = None
        if tools_env is not None:
            if tools_env.env_cmds is not None:
                env = util.BuildEnv(tools_env.env_cmds)
            if 'cl' in tools_env.tools:
                cl_argv[0] = tools_env.tools['cl']
            if 'rc' in tools_env.tools:
                rc_argv[0] = tools_env.tools['rc']

        with util.FolderChanger(task_folder):
            # Includes go to stderr when we preprocess to stdout.
            p, out, err = util.Execute(cl_argv, env=env)
            out, deps = util.ParseMSVCDeps(err, inclusion_pattern)
            paths = self.rewriteDeps(deps)

            if p.returncode == 0:
                p, out, err = util.Execute(rc_argv, env=env)

        reply = {
            'ok': p.returncode == 0,
            'cmdline': self.task_argv_debug(message),
            'stdout': out,
            'stderr': err,
            'deps': paths,
        }
        return reply
Exemple #2
0
    def doCompile(self, message):
        task_folder = message['task_folder']
        task_data = message['task_data']
        tools_env = message['task_tools_env']
        cc_type = task_data['type']
        argv = task_data['argv']

        if 'deps' in task_data:
            dep_type, dep_info = task_data['deps']
        else:
            dep_type = cc_type
            dep_info = None

        env = None
        if tools_env is not None:
            if tools_env.env_cmds is not None:
                env = util.BuildEnv(tools_env.env_cmds)
            if 'cl' in tools_env.tools:
                argv[0] = tools_env.tools['cl']

        with util.FolderChanger(task_folder):
            p, out, err = util.Execute(argv, env=env)
            out, err, paths = self.parseDependencies(tools_env, out, err,
                                                     dep_type, dep_info)

        reply = {
            'ok': p.returncode == 0,
            'cmdline': self.task_argv_debug(message),
            'stdout': out,
            'stderr': err,
            'deps': paths,
        }
        return reply
Exemple #3
0
    def doCommand(self, message):
        task_folder = message['task_folder']
        tools_env = message['task_tools_env']
        argv = message['task_data']

        env = None
        if tools_env is not None:
            if tools_env.env_cmds is not None:
                env = util.BuildEnv(tools_env.env_cmds)
            if argv[0] in tools_env.tools:
                argv[0] = tools_env.tools[argv[0]]

        with util.FolderChanger(task_folder):
            try:
                p, stdout, stderr = util.Execute(argv, env=env)
                status = p.returncode == 0
            except Exception as exn:
                status = False
                stdout = ''
                stderr = '{0}'.format(exn)

        reply = {
            'ok': status,
            'cmdline': self.task_argv_debug(message),
            'stdout': stdout,
            'stderr': stderr,
        }
        return reply
Exemple #4
0
    def try_msvc_install(self, install):
        bat_file = install.vcvars[self.target_.arch]
        try:
            env_cmds = msvc_utils.DeduceEnv(bat_file, [])
            env = util.BuildEnv(env_cmds)
        except:
            util.con_err(util.ConsoleRed,
                         "Could not run or analyze {}".format(bat_file),
                         util.ConsoleNormal)
            return None

        necessary_tools = ['cl.exe', 'rc.exe', 'lib.exe']
        tools, _ = FindToolsInEnv(env, necessary_tools)
        for tool in necessary_tools:
            if tool not in tools:
                util.con_err(util.ConsoleRed,
                             "Could not find {} for {}".format(tool, bat_file))
                return None

        cc, _ = self.run_compiler(env,
                                  'CC',
                                  'cl',
                                  'msvc',
                                  abs_path=tools['cl.exe'])
        if not cc:
            return None
        cxx, _ = self.run_compiler(env,
                                   'CXX',
                                   'cl',
                                   'msvc',
                                   abs_path=tools['cl.exe'])
        if not cxx:
            return None

        # We use tuples here so the data is hashable without going through Pickle.
        tool_list = (
            ('cl', tools['cl.exe']),
            ('rc', tools['rc.exe']),
            ('lib', tools['lib.exe']),
        )
        env_data = (
            ('env_cmds', env_cmds),
            ('tools', tool_list),
        )
        return compiler.CliCompiler(cxx.vendor,
                                    cc.argv,
                                    cxx.argv,
                                    options=self.gen_options_,
                                    env_data=env_data)
Exemple #5
0
    def try_msvc_bat(self, bat_file, pass_arch=False):
        argv = []
        if pass_arch:
            argv.append(msvc_utils.MakeArchParam(self.host_, self.target_))

        try:
            env_cmds = msvc_utils.DeduceEnv(bat_file, argv)
            env = util.BuildEnv(env_cmds)
        except:
            util.con_err(util.ConsoleRed,
                         "Could not run or analyze {}".format(bat_file),
                         util.ConsoleNormal)
            return None

        necessary_tools = ['cl.exe', 'rc.exe', 'lib.exe']
        tools, _ = FindToolsInEnv(env, necessary_tools)
        for tool in necessary_tools:
            if tool not in tools:
                util.con_err(util.ConsoleRed,
                             "Could not find {} for {}".format(tool, bat_file))
                return None

        cc, _ = self.run_compiler('CC',
                                  'cl',
                                  'msvc',
                                  env,
                                  abs_path=tools['cl.exe'])
        if not cc:
            return None
        cxx, _ = self.run_compiler('CXX',
                                   'cl',
                                   'msvc',
                                   env,
                                   abs_path=tools['cl.exe'])
        if not cxx:
            return None

        # We use tuples here so the data is hashable without going through Pickle.
        tool_list = (
            ('cl', tools['cl.exe']),
            ('rc', tools['rc.exe']),
            ('lib', tools['lib.exe']),
        )
        env_data = {
            'env_cmds': env_cmds,
            'tools': tool_list,
        }
        return self.create_cli(cc, cxx, env_data)
Exemple #6
0
    def doCompile(self, message):
        task_folder = message['task_folder']
        task_data = message['task_data']
        tools_env = message['task_tools_env']
        cc_type = task_data['type']
        argv = task_data['argv']

        env = None
        if tools_env is not None:
            if tools_env.env_cmds is not None:
                env = util.BuildEnv(tools_env.env_cmds)
            if 'cl' in tools_env.tools:
                argv[0] = tools_env.tools['cl']

        with util.FolderChanger(task_folder):
            p, out, err = util.Execute(argv, env=env)
            if cc_type == 'gcc':
                err, deps = util.ParseGCCDeps(err)
            elif cc_type == 'msvc':
                inclusion_pattern = GetMsvcInclusionPattern(
                    self.vars, tools_env)
                out, deps = util.ParseMSVCDeps(out, inclusion_pattern)
            elif cc_type == 'sun':
                err, deps = util.ParseSunDeps(err)
            elif cc_type == 'fxc':
                out, deps = util.ParseFXCDeps(out)
            else:
                raise Exception('unknown compiler type')

            paths = self.rewriteDeps(deps)

        reply = {
            'ok': p.returncode == 0,
            'cmdline': self.task_argv_debug(message),
            'stdout': out,
            'stderr': err,
            'deps': paths,
        }
        return reply