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)
def create_cli(self, cc, cxx): # Ensure that the two compilers have the same vendor. if not cxx.vendor.equals(cc.vendor): message = 'C and C++ compiler are different: CC={0}, CXX={1}' message = message.format(cc.vendor, cxx.vendor) util.con_err(util.ConsoleRed, message, util.ConsoleNormal) raise Exception(message) if cxx.arch != cc.arch: message = "C architecture {0} does not match C++ architecture {1}".format( cc.arch, cxx.arch) util.con_err(util.ConsoleRed, message, util.ConsoleNormal) raise Exception(message) return compiler.CliCompiler(cxx.vendor, cc.argv, cxx.argv, self.gen_options_)
def DetectCxx(target, env, options): cc = DetectCxxCompiler(env, 'CC') cxx = DetectCxxCompiler(env, 'CXX') # Ensure that the two compilers have the same vendor. if not cxx.vendor.equals(cc.vendor): message = 'C and C++ compiler are different: CC={0}, CXX={1}' message = message.format(cc.vendor, cxx.vendor) util.con_err(util.ConsoleRed, message, util.ConsoleNormal) raise Exception(message) if cxx.arch != cc.arch: message = "C architecture {0} does not match C++ architecture {1}".format( cc.arch, cxx.arch) util.con_err(util.ConsoleRed, message, util.ConsoleNormal) raise Exception(message) # :TODO: Check that the arch is == to target. We don't do this yet since # on Windows we can't use platform.architecture(). return compiler.CliCompiler(cxx.vendor, cc.argv, cxx.argv, options)