Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rapidjson: Conan 2.0 migration #12935

Merged
merged 7 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions recipes/rapidjson/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ sources:
"1.1.0":
url: "https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz"
sha256: bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e
"cci.20200410":
url: "https://github.com/Tencent/rapidjson/archive/8f4c021fa2f1e001d2376095928fc0532adf2ae6.zip"
sha256: e6fc99c7df7f29995838a764dd68df87b71db360f7727ace467b21b82c85efda
# More recent unofficial releases based on commits
"cci.20220822":
url: "https://github.com/Tencent/rapidjson/archive/06d58b9e848c650114556a23294d0b6440078c61.tar.gz"
sha256: 30d28bbe0bfff9d8dc5d3cf62799b6ee550499cc1520e44bdece81e002480d19
"cci.20211112":
url: "https://github.com/Tencent/rapidjson/archive/0d4517f15a8d7167ba9ae67f3f22a559ca841e3b.tar.gz"
sha256: 3697fdcea30dc7c2b2bb68d2521a6b8793f4d3269de751eed2c5fd477ff329ce
"cci.20200410":
url: "https://github.com/Tencent/rapidjson/archive/8f4c021fa2f1e001d2376095928fc0532adf2ae6.zip"
sha256: e6fc99c7df7f29995838a764dd68df87b71db360f7727ace467b21b82c85efda
27 changes: 17 additions & 10 deletions recipes/rapidjson/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
from conans import ConanFile, tools
from conan import ConanFile
from conan.tools.files import get, copy
from conan.tools.layout import basic_layout
import os

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.50.0"


class RapidjsonConan(ConanFile):
name = "rapidjson"
description = "A fast JSON parser/generator for C++ with both SAX/DOM style API"
topics = ("conan", "rapidjson", "json", "parser", "generator")
topics = ("rapidjson", "json", "parser", "generator")
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://rapidjson.org"
license = "MIT"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved

@property
def _source_subfolder(self):
return "source_subfolder"
def layout(self):
basic_layout(self)

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
get(self, **self.conan_data["sources"][self.version], strip_root=True,
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
destination=self.source_folder)

def package(self):
self.copy(pattern="license.txt", dst="licenses", src=self._source_subfolder)
self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include"))
copy(self, pattern="license.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, pattern="*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include"))

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

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "RapidJSON")
self.cpp_info.set_property("cmake_target_name", "rapidjson")

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.names["cmake_find_package"] = "RapidJSON"
self.cpp_info.names["cmake_find_package_multi"] = "RapidJSON"
8 changes: 4 additions & 4 deletions recipes/rapidjson/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.8)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(RapidJSON CONFIG REQUIRED)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} PRIVATE rapidjson)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
19 changes: 14 additions & 5 deletions recipes/rapidjson/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conans import ConanFile, CMake, tools
import os
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout

required_conan_version = ">=1.50.0"

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

prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

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

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun")
11 changes: 11 additions & 0 deletions recipes/rapidjson/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.8)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(RapidJSON CONFIG REQUIRED)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE RapidJSON::RapidJSON)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
17 changes: 17 additions & 0 deletions recipes/rapidjson/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

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

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
4 changes: 3 additions & 1 deletion recipes/rapidjson/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
versions:
"1.1.0":
folder: "all"
"cci.20200410":
"cci.20220822":
folder: "all"
"cci.20211112":
folder: "all"
"cci.20200410":
folder: "all"