forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wil recipe added * fix test_package * added _min_cpp to the recipe * fixed layot * fixes * removed camke_module_file_name/cmake_module_target_name * added patch for type conversion * Update 1.0.230202.1-0001-fix-type-conversion.patch * Update recipes/wil/all/conanfile.py Co-authored-by: Chris Mc <[email protected]> * Update recipes/wil/all/test_package/CMakeLists.txt Co-authored-by: Chris Mc <[email protected]> * Update conanfile.py * fix patch type and added source * removed gcc and clang from _compilers_min_version * fixed test_package.cpp * changed type of patch to bugfix * fixup: patch type should be portability since it adds support for vs 2017 --------- Co-authored-by: Chris Mc <[email protected]>
- Loading branch information
1 parent
5e2ffb4
commit ec22cbb
Showing
9 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
sources: | ||
"1.0.230202.1": | ||
url: "https://github.com/microsoft/wil/archive/refs/tags/v1.0.230202.1.tar.gz" | ||
sha256: "7bf01e9d93fb93f0fe2614492fac4a423b3a97b435015db74f5ac4a0270ebc8a" | ||
patches: | ||
"1.0.230202.1": | ||
- patch_file: "patches/1.0.230202.1-0001-fix-type-conversion.patch" | ||
patch_description: "Explicitly writing the type instead of using decltype" | ||
patch_source: | | ||
https://github.com/microsoft/wil/issues/302#issuecomment-1482117200 | ||
https://github.com/microsoft/wil/pull/316 | ||
patch_type: portability |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.scm import Version | ||
import os | ||
|
||
|
||
required_conan_version = ">=1.52.0" | ||
|
||
|
||
class WilConan(ConanFile): | ||
name = "wil" | ||
description = ( | ||
"The Windows Implementation Libraries (WIL) is a header-only C++ library" | ||
"created to make life easier for developers on Windows through readable" | ||
"type-safe C++ interfaces for common Windows coding patterns." | ||
) | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/microsoft/wil" | ||
topics = ("win", "wil", "header-only") | ||
package_type = "header-library" | ||
# only arch is aplicable, windows library | ||
settings = "os", "arch", "compiler", "build_type" | ||
|
||
no_copy_source = True | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 11 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"Visual Studio": "15", | ||
"msvc": "14.1" | ||
} | ||
|
||
# About compiler version: https://github.com/microsoft/wil/issues/207#issuecomment-991722592 | ||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
# same package ID for any package | ||
def package_id(self): | ||
self.info.clear() | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
# Validate the minimum cpp standard supported when installing the package. For C++ projects only | ||
check_min_cppstd(self, self._min_cppstd) | ||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version and Version(self.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration( | ||
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." | ||
) | ||
|
||
if self.settings.os != "Windows": | ||
raise ConanInvalidConfiguration(f"{self.ref} can be used only on Windows.") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
|
||
def package(self): | ||
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
copy( | ||
self, | ||
pattern="*.h", | ||
dst=os.path.join(self.package_folder, "include"), | ||
src=os.path.join(self.source_folder, "include"), | ||
) | ||
|
||
def package_info(self): | ||
# Folders not used for header-only | ||
self.cpp_info.bindirs = [] | ||
self.cpp_info.libdirs = [] | ||
|
||
# https://github.com/microsoft/wil/blob/56e3e5aa79234f8de3ceeeaf05b715b823bc2cca/CMakeLists.txt#L53 | ||
self.cpp_info.set_property("cmake_file_name", "WIL") | ||
self.cpp_info.set_property("cmake_target_name", "WIL::WIL") | ||
|
||
# TODO: to remove in conan v2 once cmake_find_package_* generators removed | ||
self.cpp_info.filenames["cmake_find_package"] = "WIL" | ||
self.cpp_info.filenames["cmake_find_package_multi"] = "WIL" | ||
self.cpp_info.names["cmake_find_package"] = "WIL" | ||
self.cpp_info.names["cmake_find_package_multi"] = "WIL" |
11 changes: 11 additions & 0 deletions
11
recipes/wil/all/patches/1.0.230202.1-0001-fix-type-conversion.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- a/include/wil/resource.h | ||
+++ b/include/wil/resource.h | ||
@@ -2547,7 +2547,7 @@ namespace wil | ||
} | ||
|
||
template <ULONG flags = 0> | ||
- using unique_private_namespace = unique_any_handle_null_only<decltype(details::ClosePrivateNamespaceHelper<flags>), &details::ClosePrivateNamespaceHelper<flags>>; | ||
+ using unique_private_namespace = unique_any_handle_null_only<void(__stdcall*)(HANDLE) WI_PFN_NOEXCEPT, &details::ClosePrivateNamespaceHelper<flags>>; | ||
|
||
using unique_private_namespace_close = unique_private_namespace<>; | ||
using unique_private_namespace_destroy = unique_private_namespace<PRIVATE_NAMESPACE_FLAG_DESTROY>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package LANGUAGES CXX) | ||
|
||
find_package(WIL REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE WIL::WIL) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
# It will become the standard on Conan 2.x | ||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <cstdlib> | ||
#include <iostream> | ||
#include "wil/resource.h" | ||
|
||
|
||
int main(void) { | ||
SetLastError(42); | ||
// check for simple function call: | ||
auto error42 = wil::last_error_context(); | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package LANGUAGES CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from conans import ConanFile, CMake | ||
from conan.tools.build import cross_building | ||
import os | ||
|
||
|
||
# legacy validation with Conan 1.x | ||
class TestPackageV1Conan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"1.0.230202.1": | ||
folder: "all" |