-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#13924) valijson: add version 1.0, support conan v2, remove version 0.3
- Loading branch information
Showing
8 changed files
with
120 additions
and
77 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 |
---|---|---|
@@ -1,14 +1,10 @@ | ||
sources: | ||
"1.0": | ||
url: "https://github.com/tristanpenman/valijson/archive/v1.0.tar.gz" | ||
sha256: "6b9f0bc89880feb3fe09aa469cd81f6168897d2fbb4e715853da3b94afd3779a" | ||
"0.7": | ||
url: "https://github.com/tristanpenman/valijson/archive/v0.7.tar.gz" | ||
sha256: "bc24736709acfb252a5fdcb5145f1f2670c7aecaba3356f6f8ba54903800fa5c" | ||
"0.6": | ||
url: "https://github.com/tristanpenman/valijson/archive/v0.6.zip" | ||
sha256: d655dd7ca502978238e72a4febcd064cb1ffaece18cd5d78c7f17df420387b59 | ||
"0.3": | ||
url: "https://github.com/tristanpenman/valijson/archive/v0.3.zip" | ||
sha256: 76f1ad4800fb730b258a6272dfe738b0695101cbbb4e72f9ab75e33b2a90262e | ||
patches: | ||
"0.3": | ||
- patch_file: "patches/nlohmann_json.patch" | ||
base_path: "source_subfolder" | ||
url: "https://github.com/tristanpenman/valijson/archive/v0.6.tar.gz" | ||
sha256: "e06bf78fc1d26d4956fabc182408ebbbc47e3a6699778cda4aa439c2a6110b09" |
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 |
---|---|---|
@@ -1,43 +1,61 @@ | ||
from conans import ConanFile, tools | ||
from conan import ConanFile | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.files import get, copy | ||
from conan.tools.layout import basic_layout | ||
import os | ||
import glob | ||
|
||
required_conan_version = ">=1.52.0" | ||
|
||
class ValijsonConan(ConanFile): | ||
name = "valijson" | ||
description = "Valijson is a header-only JSON Schema Validation library for C++11." | ||
topics = ("conan", "valijson", "json", "validator") | ||
license = "BSD-2-Clause" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/tristanpenman/valijson" | ||
license = "BSD-2-Clause" | ||
exports_sources = ["patches/**"] | ||
topics = ("json", "validator", "header-only") | ||
settings = "os", "arch", "compiler", "build_type" | ||
no_copy_source = True | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
def _min_cppstd(self): | ||
return 11 | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def package_id(self): | ||
self.info.clear() | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
extracted_dir = glob.glob(self.name + "-*/")[0] | ||
os.rename(extracted_dir, self._source_subfolder) | ||
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
pass | ||
|
||
def package(self): | ||
include_folder = os.path.join(self._source_subfolder, "include") | ||
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) | ||
self.copy(pattern="*", dst="include", src=include_folder) | ||
|
||
def package_id(self): | ||
self.info.header_only() | ||
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
copy( | ||
self, | ||
pattern="*.hpp", | ||
dst=os.path.join(self.package_folder, "include"), | ||
src=os.path.join(self.source_folder, "include"), | ||
) | ||
|
||
def package_info(self): | ||
self.cpp_info.bindirs = [] | ||
self.cpp_info.libdirs = [] | ||
|
||
self.cpp_info.set_property("cmake_target_name", "ValiJSON::valijson") | ||
self.cpp_info.components["libvalijson"].set_property("cmake_target_name", "ValiJSON::valijson") | ||
|
||
# TODO: to remove in conan v2 once cmake_find_package_* generators removed | ||
# self.cpp_info.filenames["cmake_find_package"] = "valijson" # TBA: There's no installed config file | ||
# self.cpp_info.filenames["cmake_find_package_multi"] = "valijson" # TBA: There's no installed config file | ||
self.cpp_info.names["cmake_find_package"] = "ValiJSON" | ||
self.cpp_info.names["cmake_find_package_multi"] = "ValiJSON" | ||
|
||
self.cpp_info.components["libvalijson"].names["cmake_find_package"] = "valijson" | ||
self.cpp_info.components["libvalijson"].names["cmake_find_package_multi"] = "valijson" |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,17 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
set(CMAKE_CXX_STANDARD 11) | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package LANGUAGES CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(ValiJSON REQUIRED) | ||
find_package(ValiJSON REQUIRED CONFIG) | ||
find_package(nlohmann_json REQUIRED CONFIG) | ||
find_package(picojson REQUIRED CONFIG) | ||
find_package(RapidJSON REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
ValiJSON::valijson | ||
CONAN_PKG::nlohmann_json | ||
CONAN_PKG::picojson | ||
CONAN_PKG::rapidjson | ||
nlohmann_json::nlohmann_json | ||
picojson::picojson | ||
rapidjson | ||
) | ||
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
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,20 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package LANGUAGES CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(ValiJSON REQUIRED CONFIG) | ||
find_package(nlohmann_json REQUIRED CONFIG) | ||
find_package(picojson REQUIRED CONFIG) | ||
find_package(RapidJSON REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) | ||
target_link_libraries( | ||
${PROJECT_NAME} | ||
ValiJSON::valijson | ||
nlohmann_json::nlohmann_json | ||
picojson::picojson | ||
RapidJSON::RapidJSON | ||
) | ||
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,28 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def requirements(self): | ||
self.requires("nlohmann_json/3.9.1") | ||
self.requires("rapidjson/cci.20200410") | ||
self.requires("picojson/1.3.0") | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
schema_file = os.path.abspath(os.path.join(self.source_folder, os.pardir, "test_package", "schema.json")) | ||
valid_file = os.path.abspath(os.path.join(self.source_folder, os.pardir, "test_package", "valid.json")) | ||
invalid_file = os.path.abspath(os.path.join(self.source_folder, os.pardir, "test_package", "invalid.json")) | ||
self.run( | ||
"{} {} {} {}".format(bin_path, schema_file, valid_file, invalid_file), | ||
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
versions: | ||
"0.3": | ||
folder: "all" | ||
"0.6": | ||
"1.0": | ||
folder: "all" | ||
"0.7": | ||
folder: "all" | ||
"0.6": | ||
folder: "all" |