def write_conanvcvars(conanfile): """ write a conanvcvars.bat file with the good args from settings """ os_ = conanfile.settings.get_safe("os") if os_ != "Windows": return compiler = conanfile.settings.get_safe("compiler") cvars = None if compiler == "intel": cvars = intel_compilervars_command(conanfile) elif compiler == "Visual Studio" or compiler == "msvc": vs_version = vs_ide_version(conanfile) vcvarsarch = vcvars_arch(conanfile) cvars = vcvars_command(vs_version, architecture=vcvarsarch, platform_type=None, winsdk_version=None, vcvars_ver=None) if cvars: content = textwrap.dedent("""\ @echo off {} """.format(cvars)) save(CONAN_VCVARS_FILE, content)
def command(self, sln): if self.compiler == "intel": cvars = intel_compilervars_command(self._conanfile) else: cvars = vcvars_command(self.version, architecture=self.vcvars_arch, platform_type=None, winsdk_version=None, vcvars_ver=None) cmd = ('%s && msbuild "%s" /p:Configuration=%s /p:Platform=%s ' % (cvars, sln, self.build_type, self.platform)) return cmd
def _write_vcvars(self): if self.compiler == "intel": cvars = intel_compilervars_command(self._conanfile) else: cvars = vcvars_command(self.visual_version, architecture=self.vcvars_arch, platform_type=None, winsdk_version=None, vcvars_ver=None) content = textwrap.dedent("""\ @echo off {} """.format(cvars)) save("conanvcvars.bat", content)
def _write_conanvcvars(conanfile, group): """ write a conanvcvars.bat file with the good args from settings """ os_ = conanfile.settings.get_safe("os") if os_ != "Windows": return compiler = conanfile.settings.get_safe("compiler") cvars = None if compiler == "intel": cvars = intel_compilervars_command(conanfile) elif compiler == "Visual Studio" or compiler == "msvc": vs_version = vs_ide_version(conanfile) vcvarsarch = vcvars_arch(conanfile) vcvars_ver = None if compiler == "Visual Studio": toolset = conanfile.settings.get_safe("compiler.toolset") if toolset is not None: vcvars_ver = { "v140": "14.0", "v141": "14.1", "v142": "14.2", "v143": "14.3" }.get(toolset) else: # Code similar to CMakeToolchain toolset one compiler_version = str(conanfile.settings.compiler.version) version_components = compiler_version.split(".") assert len(version_components) >= 2 # there is a 19.XX minor = version_components[1] # The equivalent of compiler 19.26 is toolset 14.26 vcvars_ver = "14.{}".format(minor) cvars = vcvars_command(vs_version, architecture=vcvarsarch, platform_type=None, winsdk_version=None, vcvars_ver=vcvars_ver) if cvars: content = textwrap.dedent("""\ @echo off {} """.format(cvars)) path = os.path.join(conanfile.generators_folder, CONAN_VCVARS_FILE) save(path, content) if group: register_env_script(conanfile, path, group)