From c7fd504ee6e96ff5068cc5d5846a4e6426520ba8 Mon Sep 17 00:00:00 2001 From: theirix Date: Sun, 19 Jan 2020 19:06:37 +0300 Subject: [PATCH 01/14] Add simdjson/0.2.1 --- recipes/simdjson/all/CMakeLists.txt | 8 +++ recipes/simdjson/all/conandata.yml | 4 ++ recipes/simdjson/all/conanfile.py | 58 +++++++++++++++++++ .../simdjson/all/test_package/CMakeLists.txt | 9 +++ .../simdjson/all/test_package/conanfile.py | 17 ++++++ .../all/test_package/test_package.cpp | 14 +++++ recipes/simdjson/config.yml | 3 + 7 files changed, 113 insertions(+) create mode 100644 recipes/simdjson/all/CMakeLists.txt create mode 100644 recipes/simdjson/all/conandata.yml create mode 100644 recipes/simdjson/all/conanfile.py create mode 100644 recipes/simdjson/all/test_package/CMakeLists.txt create mode 100644 recipes/simdjson/all/test_package/conanfile.py create mode 100644 recipes/simdjson/all/test_package/test_package.cpp create mode 100644 recipes/simdjson/config.yml diff --git a/recipes/simdjson/all/CMakeLists.txt b/recipes/simdjson/all/CMakeLists.txt new file mode 100644 index 0000000000000..f28fc0e9af6c8 --- /dev/null +++ b/recipes/simdjson/all/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.7) + +project(cmake_wrapper) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/simdjson/all/conandata.yml b/recipes/simdjson/all/conandata.yml new file mode 100644 index 0000000000000..dd6b740f099f6 --- /dev/null +++ b/recipes/simdjson/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.2.1": + url: "https://github.com/lemire/simdjson/archive/v0.2.1.tar.gz" + sha256: "361ad30048005421073b284e6e0c1dcfe46daeecca32e6b5a5a5e7e31df1fdb5" diff --git a/recipes/simdjson/all/conanfile.py b/recipes/simdjson/all/conanfile.py new file mode 100644 index 0000000000000..2ae5841d7a86b --- /dev/null +++ b/recipes/simdjson/all/conanfile.py @@ -0,0 +1,58 @@ +import os +from conans import ConanFile, CMake, tools + + +class SimdjsonConan(ConanFile): + name = "simdjson" + description = "Parsing gigabytes of JSON per second" + topics = ("conan", "json", "parser", "simd", "format") + url = "https://github.com/conan-io/conan-center-index" + homepage = "Ahttps://github.com/lemire/simdjson" + license = "Apache-2.0" + exports_sources = ["CMakeLists.txt"] + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [True, False], + "fPIC": [True, False], + "threads": [True, False], + "avx": [True, False]} + default_options = {'shared': False, + 'fPIC': True, + 'threads': True, + 'avx': True} + _source_subfolder = "source_subfolder" + + def configure(self): + if self.settings.compiler == "Visual Studio": + self.options.remove("fPIC") + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = self.name + "-" + self.version + os.rename(extracted_dir, self._source_subfolder) + + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions['SIMDJSON_BUILD_STATIC'] = not self.options.shared + cmake.definitions['SIMDJSON_ENABLE_THREADS'] = self.options.threads + cmake.definitions['SIMDJSON_DISABLE_AVX'] = not self.options.avx + cmake.definitions['SIMDJSON_SANITIZE'] = False + cmake.definitions['ENABLE_FUZZING'] = False + cmake.configure() + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + # remove unneeded directories + tools.rmdir(os.path.join(self.package_folder, 'lib', 'cmake')) + tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) + + self.copy("license", src=self._source_subfolder, dst="licenses", ignore_case=True, keep_path=False) + + def package_info(self): + self.cpp_info.libs = ['simdjson'] diff --git a/recipes/simdjson/all/test_package/CMakeLists.txt b/recipes/simdjson/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..dc477a4ea5176 --- /dev/null +++ b/recipes/simdjson/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.8.11) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/simdjson/all/test_package/conanfile.py b/recipes/simdjson/all/test_package/conanfile.py new file mode 100644 index 0000000000000..682db689bc9c4 --- /dev/null +++ b/recipes/simdjson/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + img_name = os.path.join(self.source_folder, "testimg.jpg") + bin_path = os.path.join("bin", "test_package") + self.run('%s %s' % (bin_path, img_name), run_environment=True) diff --git a/recipes/simdjson/all/test_package/test_package.cpp b/recipes/simdjson/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..82d8627524468 --- /dev/null +++ b/recipes/simdjson/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include +#include +#include "simdjson/jsonparser.h" + +int main() { + std::string mystring = "{ \"hello\": \"simdjson\" }"; + simdjson::ParsedJson pj = simdjson::build_parsed_json(mystring); + if (!pj.is_valid()) { + // something went wrong + std::cout << pj.get_error_message() << std::endl; + return 1; + } + return 0; +} diff --git a/recipes/simdjson/config.yml b/recipes/simdjson/config.yml new file mode 100644 index 0000000000000..f975c1e3261f7 --- /dev/null +++ b/recipes/simdjson/config.yml @@ -0,0 +1,3 @@ +versions: + "0.2.1": + folder: all From 0bd0480d5101a23578127cfacab961b6573afa22 Mon Sep 17 00:00:00 2001 From: theirix Date: Sun, 19 Jan 2020 19:31:32 +0300 Subject: [PATCH 02/14] Check for c++17 for simdjson Copied code from libsigcpp --- recipes/simdjson/all/conanfile.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/recipes/simdjson/all/conanfile.py b/recipes/simdjson/all/conanfile.py index 2ae5841d7a86b..d810c05886b06 100644 --- a/recipes/simdjson/all/conanfile.py +++ b/recipes/simdjson/all/conanfile.py @@ -1,5 +1,7 @@ import os from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +from conans.tools import Version class SimdjsonConan(ConanFile): @@ -22,9 +24,28 @@ class SimdjsonConan(ConanFile): 'avx': True} _source_subfolder = "source_subfolder" + @property + def _supported_cppstd(self): + return ["17", "gnu17", "20", "gnu20"] + + def _has_support_for_cpp17(self): + supported_compilers = [("apple-clang", 10), ("clang", 6), ("gcc", 7), ("Visual Studio", 15.7)] + compiler, version = self.settings.compiler, Version(self.settings.compiler.version) + return any(compiler == sc[0] and version >= sc[1] for sc in supported_compilers) + def configure(self): if self.settings.compiler == "Visual Studio": self.options.remove("fPIC") + if self.settings.compiler.cppstd and \ + not self.settings.compiler.cppstd in self._supported_cppstd: + raise ConanInvalidConfiguration("This library requires c++17 standard or higher." + " {} required." + .format(self.settings.compiler.cppstd)) + + if not self._has_support_for_cpp17(): + raise ConanInvalidConfiguration("This library requires C++17 or higher support standard." + " {} {} is not supported." + .format(self.settings.compiler, self.settings.compiler.version)) def source(self): tools.get(**self.conan_data["sources"][self.version]) From bfc3f1fd696e3358d523fe9819b70507963041bb Mon Sep 17 00:00:00 2001 From: theirix Date: Sun, 19 Jan 2020 19:54:20 +0300 Subject: [PATCH 03/14] Improve test_package for simdjson --- recipes/simdjson/all/test_package/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/simdjson/all/test_package/conanfile.py b/recipes/simdjson/all/test_package/conanfile.py index 682db689bc9c4..24ad9b2d2ec5c 100644 --- a/recipes/simdjson/all/test_package/conanfile.py +++ b/recipes/simdjson/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - img_name = os.path.join(self.source_folder, "testimg.jpg") - bin_path = os.path.join("bin", "test_package") - self.run('%s %s' % (bin_path, img_name), run_environment=True) + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) From 6236b258a15f478ba022c97555fca775a1f9f1b7 Mon Sep 17 00:00:00 2001 From: theirix Date: Sun, 19 Jan 2020 20:03:45 +0300 Subject: [PATCH 04/14] Up cmake version for simdjson test_package --- recipes/simdjson/all/test_package/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/simdjson/all/test_package/CMakeLists.txt b/recipes/simdjson/all/test_package/CMakeLists.txt index dc477a4ea5176..d25439084b04a 100644 --- a/recipes/simdjson/all/test_package/CMakeLists.txt +++ b/recipes/simdjson/all/test_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.7) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) From a1cff07c8e779b68a153ad37df79e8736387d1bd Mon Sep 17 00:00:00 2001 From: theirix Date: Sun, 19 Jan 2020 20:46:21 +0300 Subject: [PATCH 05/14] Add missing import --- recipes/simdjson/all/test_package/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/simdjson/all/test_package/conanfile.py b/recipes/simdjson/all/test_package/conanfile.py index 24ad9b2d2ec5c..bd7165a553cf4 100644 --- a/recipes/simdjson/all/test_package/conanfile.py +++ b/recipes/simdjson/all/test_package/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile, CMake +from conans import ConanFile, CMake, tools import os From a6302cfc4d7c244d47d915fbde07281b90582f55 Mon Sep 17 00:00:00 2001 From: theirix Date: Sun, 19 Jan 2020 20:48:41 +0300 Subject: [PATCH 06/14] Add verbose to cmake --- recipes/simdjson/all/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/simdjson/all/CMakeLists.txt b/recipes/simdjson/all/CMakeLists.txt index f28fc0e9af6c8..25af3615785bf 100644 --- a/recipes/simdjson/all/CMakeLists.txt +++ b/recipes/simdjson/all/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.7) project(cmake_wrapper) +set(CMAKE_VERBOSE_MAKEFILE TRUE) + include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup() From 8dc73b15c0b25b2240b85138560b02eabae94523 Mon Sep 17 00:00:00 2001 From: theirix Date: Sun, 19 Jan 2020 22:05:51 +0300 Subject: [PATCH 07/14] Adjust verbosity for cmake --- recipes/simdjson/all/CMakeLists.txt | 4 +--- recipes/simdjson/all/test_package/CMakeLists.txt | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/simdjson/all/CMakeLists.txt b/recipes/simdjson/all/CMakeLists.txt index 25af3615785bf..a624d87489a8e 100644 --- a/recipes/simdjson/all/CMakeLists.txt +++ b/recipes/simdjson/all/CMakeLists.txt @@ -1,9 +1,7 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.9) project(cmake_wrapper) -set(CMAKE_VERBOSE_MAKEFILE TRUE) - include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup() diff --git a/recipes/simdjson/all/test_package/CMakeLists.txt b/recipes/simdjson/all/test_package/CMakeLists.txt index d25439084b04a..6a75e5a612467 100644 --- a/recipes/simdjson/all/test_package/CMakeLists.txt +++ b/recipes/simdjson/all/test_package/CMakeLists.txt @@ -1,6 +1,8 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.9) project(test_package) +set(CMAKE_VERBOSE_MAKEFILE TRUE) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() From e8157ff538bb0cb064141dc2210ed92a8c1482d3 Mon Sep 17 00:00:00 2001 From: theirix Date: Sun, 19 Jan 2020 22:06:06 +0300 Subject: [PATCH 08/14] Fix ignoring CMAKE_CXX_FLAGS in simdjson 0.2.1 Fixed in upstream commit 9442c9e1, not released yet --- recipes/simdjson/all/conanfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipes/simdjson/all/conanfile.py b/recipes/simdjson/all/conanfile.py index d810c05886b06..dcefebd450a9e 100644 --- a/recipes/simdjson/all/conanfile.py +++ b/recipes/simdjson/all/conanfile.py @@ -52,6 +52,12 @@ def source(self): extracted_dir = self.name + "-" + self.version os.rename(extracted_dir, self._source_subfolder) + # In version 0.2.1 CMAKE_CXX_FLAGS are ignored + tools.replace_in_file(os.path.join(self._source_subfolder, 'tools', 'cmake', 'FindOptions.cmake'), + 'set(CMAKE_CXX_FLAGS "${CXXSTD_FLAGS}', + 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXXSTD_FLAGS}', + strict=False) + def _configure_cmake(self): cmake = CMake(self) cmake.definitions['SIMDJSON_BUILD_STATIC'] = not self.options.shared From f7172e55f001d9a07b0b40193c2a34041696f020 Mon Sep 17 00:00:00 2001 From: theirix Date: Sun, 19 Jan 2020 23:11:12 +0300 Subject: [PATCH 09/14] Adjust verbosity for cmake --- recipes/simdjson/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/simdjson/all/conanfile.py b/recipes/simdjson/all/conanfile.py index dcefebd450a9e..31406cad283b0 100644 --- a/recipes/simdjson/all/conanfile.py +++ b/recipes/simdjson/all/conanfile.py @@ -65,6 +65,7 @@ def _configure_cmake(self): cmake.definitions['SIMDJSON_DISABLE_AVX'] = not self.options.avx cmake.definitions['SIMDJSON_SANITIZE'] = False cmake.definitions['ENABLE_FUZZING'] = False + cmake.verbose = True cmake.configure() return cmake From 8d32fed18c663207158a742638b6a5a64f5d80f2 Mon Sep 17 00:00:00 2001 From: theirix Date: Mon, 20 Jan 2020 10:32:28 +0300 Subject: [PATCH 10/14] Update recipes/simdjson/all/conanfile.py it's vim Co-Authored-By: SSE4 --- recipes/simdjson/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/simdjson/all/conanfile.py b/recipes/simdjson/all/conanfile.py index 31406cad283b0..c26e25a948ad6 100644 --- a/recipes/simdjson/all/conanfile.py +++ b/recipes/simdjson/all/conanfile.py @@ -9,7 +9,7 @@ class SimdjsonConan(ConanFile): description = "Parsing gigabytes of JSON per second" topics = ("conan", "json", "parser", "simd", "format") url = "https://github.com/conan-io/conan-center-index" - homepage = "Ahttps://github.com/lemire/simdjson" + homepage = "https://github.com/lemire/simdjson" license = "Apache-2.0" exports_sources = ["CMakeLists.txt"] generators = "cmake" From b9dd6f6039af286a3e8932f7e45583f8d60a10e2 Mon Sep 17 00:00:00 2001 From: theirix Date: Mon, 20 Jan 2020 15:27:09 +0300 Subject: [PATCH 11/14] Disable INTERPROCEDURAL_OPTIMIZATION for simdjson It prevents shared libraries to be built on Windows --- recipes/simdjson/all/conanfile.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/recipes/simdjson/all/conanfile.py b/recipes/simdjson/all/conanfile.py index c26e25a948ad6..588737af9bb67 100644 --- a/recipes/simdjson/all/conanfile.py +++ b/recipes/simdjson/all/conanfile.py @@ -58,6 +58,13 @@ def source(self): 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXXSTD_FLAGS}', strict=False) + # Generating export files by CMake via __export_def (enabled by property WINDOWS_EXPORT_ALL_SYMBOLS) + # does not work with whole program optimization. + # So disable INTERPROCEDURAL_OPTIMIZATION + tools.replace_in_file(os.path.join(self._source_subfolder, 'CMakeLists.txt'), + 'set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)', + 'set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)') + def _configure_cmake(self): cmake = CMake(self) cmake.definitions['SIMDJSON_BUILD_STATIC'] = not self.options.shared From 6b81e9959fb56a724381c8583f67bbe724b1a6d8 Mon Sep 17 00:00:00 2001 From: theirix Date: Mon, 20 Jan 2020 15:44:52 +0300 Subject: [PATCH 12/14] Disable LTO only for shared MSVC builds --- recipes/simdjson/all/conanfile.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/recipes/simdjson/all/conanfile.py b/recipes/simdjson/all/conanfile.py index 588737af9bb67..98b17388f3518 100644 --- a/recipes/simdjson/all/conanfile.py +++ b/recipes/simdjson/all/conanfile.py @@ -61,9 +61,10 @@ def source(self): # Generating export files by CMake via __export_def (enabled by property WINDOWS_EXPORT_ALL_SYMBOLS) # does not work with whole program optimization. # So disable INTERPROCEDURAL_OPTIMIZATION - tools.replace_in_file(os.path.join(self._source_subfolder, 'CMakeLists.txt'), - 'set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)', - 'set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)') + if self.settings.compiler == "Visual Studio" and self.options.shared: + tools.replace_in_file(os.path.join(self._source_subfolder, 'CMakeLists.txt'), + 'set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)', + 'set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)') def _configure_cmake(self): cmake = CMake(self) From ee999858dce4b0d63b7f962a845ff42eac73291f Mon Sep 17 00:00:00 2001 From: theirix Date: Mon, 20 Jan 2020 15:45:07 +0300 Subject: [PATCH 13/14] Disable verbose cmake --- recipes/simdjson/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/simdjson/all/conanfile.py b/recipes/simdjson/all/conanfile.py index 98b17388f3518..d17602234423a 100644 --- a/recipes/simdjson/all/conanfile.py +++ b/recipes/simdjson/all/conanfile.py @@ -73,7 +73,6 @@ def _configure_cmake(self): cmake.definitions['SIMDJSON_DISABLE_AVX'] = not self.options.avx cmake.definitions['SIMDJSON_SANITIZE'] = False cmake.definitions['ENABLE_FUZZING'] = False - cmake.verbose = True cmake.configure() return cmake From fe3c34ff95c84a23212eefa3aa213231d62d5266 Mon Sep 17 00:00:00 2001 From: theirix Date: Mon, 20 Jan 2020 16:17:25 +0300 Subject: [PATCH 14/14] Link libm for simdjson Co-Authored-By: Uilian Ries --- recipes/simdjson/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/simdjson/all/conanfile.py b/recipes/simdjson/all/conanfile.py index d17602234423a..6232bab87cf0a 100644 --- a/recipes/simdjson/all/conanfile.py +++ b/recipes/simdjson/all/conanfile.py @@ -91,3 +91,5 @@ def package(self): def package_info(self): self.cpp_info.libs = ['simdjson'] + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["m"]