Skip to content

Commit

Permalink
vswhere: new recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Sep 10, 2024
1 parent abaca04 commit 31bbbd8
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
8 changes: 8 additions & 0 deletions recipes/vswhere/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"3.1.7":
exe:
url: "https://github.com/microsoft/vswhere/releases/download/3.1.7/vswhere.exe"
sha256: "c54f3b7c9164ea9a0db8641e81ecdda80c2664ef5a47c4191406f848cc07c662"
license:
url: "https://raw.githubusercontent.com/microsoft/vswhere/3.1.7/LICENSE.txt"
sha256: "a1e41a01dd80dbe3f8ad5edebfd746e64ccff9c2aae3d8f47922746cf83204ef"
51 changes: 51 additions & 0 deletions recipes/vswhere/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import copy, download
from conan.tools.microsoft import is_msvc

required_conan_version = ">=1.47.0"


class VswhereConan(ConanFile):
name = "vswhere"
description = "Locate Visual Studio 2017 and newer installations"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/microsoft/vswhere"
topics = ("visual-studio", "pre-built")
package_type = "application"
settings = "os", "arch", "compiler", "build_type"

def layout(self):
pass

def package_id(self):
del self.info.settings.compiler
del self.info.settings.build_type

def validate(self):
if not is_msvc(self):
raise ConanInvalidConfiguration("vswhere is only available for MSVC")

def source(self):
pass

def build(self):
download(self, **self.conan_data["sources"][self.version]["exe"], filename="vswhere.exe")
download(self, **self.conan_data["sources"][self.version]["license"], filename="LICENSE.txt")

def package(self):
copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "vswhere.exe", self.source_folder, os.path.join(self.package_folder, "bin"))

def package_info(self):
self.cpp_info.frameworkdirs = []
self.cpp_info.libdirs = []
self.cpp_info.resdirs = []
self.cpp_info.includedirs = []

# TODO: Legacy, to be removed on Conan 2.0
bin_folder = os.path.join(self.package_folder, "bin")
self.env_info.PATH.append(bin_folder)
13 changes: 13 additions & 0 deletions recipes/vswhere/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from conan import ConanFile


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "VirtualBuildEnv"
test_type = "explicit"

def build_requirements(self):
self.tool_requires(self.tested_reference_str)

def test(self):
self.run("vswhere -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath")
3 changes: 3 additions & 0 deletions recipes/vswhere/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"3.1.7":
folder: all

0 comments on commit 31bbbd8

Please sign in to comment.