def vs_installation_path_test(self): # Default behaviour install_path = tools.vs_installation_path("15") self.assertIn("Community", install_path) install_path = tools.vs_installation_path("14") self.assertIn("Microsoft Visual Studio 14.0", install_path) # only BuildTools detection install_path = tools.vs_installation_path("15", preference=["BuildTools"]) self.assertIn("BuildTools", install_path) install_path = tools.vs_installation_path("14", preference=["BuildTools"]) self.assertIn("Microsoft Visual Studio 14.0", install_path) # Ask for not installed versions install_path = tools.vs_installation_path("15", preference=["Enterprise"]) self.assertIsNone(install_path) install_path = tools.vs_installation_path("15", preference=["Professional"]) self.assertIsNone(install_path) # Change preference order install_path = tools.vs_installation_path("15", preference=[ "BuildTools", "Community", "Professional", "Enterprise" ]) self.assertIn("BuildTools", install_path) install_path = tools.vs_installation_path( "15", preference=["Professional", "Enterprise", "Community"]) self.assertIn("Community", install_path) # Preference order by env var with (tools.environment_append({ "CONAN_VS_INSTALLATION_PREFERENCE": "BuildTools, Community,Professional, Enterprise" })): install_path = tools.vs_installation_path("15") self.assertIn("BuildTools", install_path) with (tools.environment_append({ "CONAN_VS_INSTALLATION_PREFERENCE": "Professional, Enterprise,Community" })): install_path = tools.vs_installation_path("15") self.assertIn("Community", install_path)
def win_cl_exe(self): vs_root = tools.vs_installation_path(str(self.settings.compiler.version)) if vs_root: cl_exe = \ glob.glob(os.path.join(vs_root,"VC","Tools","MSVC","*","bin","*","*","cl.exe")) + \ glob.glob(os.path.join(vs_root,"VC","bin","cl.exe")) if cl_exe: return cl_exe[0].replace("\\","/")
def _visual_compiler(output, version): 'version have to be 8.0, or 9.0 or... anything .0' if platform.system().startswith("CYGWIN"): return _visual_compiler_cygwin(output, version) if version == "15": vs_path = os.getenv('vs150comntools') path = vs_path or vs_installation_path("15") if path: compiler = "Visual Studio" output.success("Found %s %s" % (compiler, "15")) return compiler, "15" return None version = "%s.0" % version from six.moves import winreg # @UnresolvedImport try: hKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion") winreg.QueryValueEx(hKey, "ProgramFilesDir (x86)") is_64bits = True except EnvironmentError: is_64bits = False finally: winreg.CloseKey(hKey) if is_64bits: key_name = r'SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7' else: key_name = r'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' try: key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_name) winreg.QueryValueEx(key, version) installed_version = Version(version).major(fill=False) compiler = "Visual Studio" output.success("Found %s %s" % (compiler, installed_version)) return compiler, installed_version except EnvironmentError: return None