Skip to content

Commit

Permalink
winreg: add winreg 6.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xyz1001 committed Mar 11, 2024
1 parent 7fe8cb8 commit f6c0bc0
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/winreg/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"6.2.0":
url: "https://github.com/GiovanniDicanio/WinReg/archive/refs/tags/v6.2.0.tar.gz"
sha256: "9dc1b287fb8c765a35791bf0deea0da81e52a969827bc2d8777f54f26ade588d"
52 changes: 52 additions & 0 deletions recipes/winreg/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout
import os

required_conan_version = ">=1.50.0"


class WinregConan(ConanFile):
name = "winreg"
homepage = "https://github.com/GiovanniDicanio/WinReg"
description = "Convenient high-level C++ wrapper around the Windows Registry API."
topics = "registry", "header-only"
url = "https://github.com/conan-io/conan-center-index"
license = "MIT"
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _minimum_cpp_standard(self):
return 17

def layout(self):
basic_layout(self, src_folder="src")

def package_id(self):
self.info.clear()

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._minimum_cpp_standard)
if self.settings.os != "Windows":
raise ConanInvalidConfiguration("WinReg is only supported on Windows")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
pass

def build(self):
pass

def package(self):
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "*", os.path.join(self.source_folder, "WinReg"), os.path.join(self.package_folder, "include/WinReg"))

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
8 changes: 8 additions & 0 deletions recipes/winreg/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(winreg REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE winreg::winreg)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
29 changes: 29 additions & 0 deletions recipes/winreg/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from conan import ConanFile
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os


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

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str, run=can_run(self))

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
cnf_file = os.path.join(self.source_folder, "graph.cnf")
self.run(f"bliss {cnf_file}", env="conanrun")
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
12 changes: 12 additions & 0 deletions recipes/winreg/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
#include <string>

#include "WinReg/WinReg.hpp"

int main() {
auto subkey = L"Environment";
winreg::RegKey key{HKEY_CURRENT_USER, subkey};
auto value = key.GetStringValue(L"Path");
std::wcout << value << std::endl;
return 0;
}

0 comments on commit f6c0bc0

Please sign in to comment.