diff --git a/recipes/stringzilla/all/conandata.yml b/recipes/stringzilla/all/conandata.yml index 182ba818238f7..9a0f2b597bc71 100644 --- a/recipes/stringzilla/all/conandata.yml +++ b/recipes/stringzilla/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.8.4": + url: "https://github.com/ashvardanian/StringZilla/archive/refs/tags/v3.8.4.tar.gz" + sha256: "4132957633d28ce2651e587f2ab736cdf174e61b8ab1bcef453b21d40a2d872e" "2.0.4": url: "https://github.com/ashvardanian/StringZilla/archive/refs/tags/v2.0.4.tar.gz" sha256: "440d3d586f8cfe96bc7648f01f2d3c514c4e2dc22446caeb50599383d1970ed2" diff --git a/recipes/stringzilla/all/conanfile.py b/recipes/stringzilla/all/conanfile.py index bded9fa3b6426..af7a34cd5d72b 100644 --- a/recipes/stringzilla/all/conanfile.py +++ b/recipes/stringzilla/all/conanfile.py @@ -2,6 +2,7 @@ from conan.tools.files import get, copy from conan.tools.layout import basic_layout from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version import os required_conan_version = ">=1.52.0" @@ -36,12 +37,26 @@ def source(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, "stringzilla"), - ) + if Version(self.version) < "3.0.0": + copy( + self, + pattern="*.h", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "stringzilla"), + ) + else: + copy( + self, + pattern="*.h", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + 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 = [] diff --git a/recipes/stringzilla/all/test_package/CMakeLists.txt b/recipes/stringzilla/all/test_package/CMakeLists.txt index 6769ff716eab8..5bcb77f146e86 100644 --- a/recipes/stringzilla/all/test_package/CMakeLists.txt +++ b/recipes/stringzilla/all/test_package/CMakeLists.txt @@ -3,9 +3,12 @@ project(test_package LANGUAGES CXX) find_package(stringzilla REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) +if (stringzilla_VERSION VERSION_LESS 2.0) + add_executable(${PROJECT_NAME} test_package.cpp) +elseif(stringzilla_VERSION VERSION_LESS 3.0) + add_executable(${PROJECT_NAME} test_package_2_0.cpp) +else() + add_executable(${PROJECT_NAME} test_package_3_0.cpp) +endif() target_link_libraries(${PROJECT_NAME} PRIVATE stringzilla::stringzilla) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) -if(stringzilla_VERSION VERSION_LESS 2.0) - target_compile_definitions(${PROJECT_NAME} PRIVATE STRINGZILLA_LESS_2_0) -endif() diff --git a/recipes/stringzilla/all/test_package/conanfile.py b/recipes/stringzilla/all/test_package/conanfile.py index 3a91c9439218e..dd09e74d7fe14 100644 --- a/recipes/stringzilla/all/test_package/conanfile.py +++ b/recipes/stringzilla/all/test_package/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.tools.build import can_run -from conan.tools.cmake import cmake_layout, CMake +from conan.tools.cmake import CMake, cmake_layout import os diff --git a/recipes/stringzilla/all/test_package/test_package.cpp b/recipes/stringzilla/all/test_package/test_package.cpp index c5ffe699dbc06..6829d24ab3783 100644 --- a/recipes/stringzilla/all/test_package/test_package.cpp +++ b/recipes/stringzilla/all/test_package/test_package.cpp @@ -1,8 +1,7 @@ #include #include -#include "stringzilla.h" -#ifdef STRINGZILLA_LESS_2_0 +#include "stringzilla.h" int main(void) { // Initialize your haystack and needle @@ -24,29 +23,3 @@ int main(void) { return EXIT_SUCCESS; } - -#else - -int main(void) { - // Initialize your haystack and needle - sz_string_view_t haystack = { - "Fastest string sort, search, split, " - "and shuffle for long strings and multi-gigabyte files in Python and C, " - "leveraging SIMD with Arm Neon and x86 AVX2 & AVX-512 intrinsics.", - 171}; - sz_string_view_t needle = {"SIMD", 4}; - - // Perform string-level operations - sz_size_t character_count = sz_count_char(haystack.start, haystack.length, "a"); - sz_string_start_t substring_position = sz_find_substring( - haystack.start, haystack.length, - needle.start, needle.length - ); - - // Hash strings - sz_u32_t crc32 = sz_hash_crc32(haystack.start, haystack.length); - - return EXIT_SUCCESS; -} - -#endif diff --git a/recipes/stringzilla/all/test_package/test_package_2_0.cpp b/recipes/stringzilla/all/test_package/test_package_2_0.cpp new file mode 100644 index 0000000000000..c165ef341d114 --- /dev/null +++ b/recipes/stringzilla/all/test_package/test_package_2_0.cpp @@ -0,0 +1,26 @@ +#include +#include + +#include "stringzilla.h" + +int main(void) { + // Initialize your haystack and needle + sz_string_view_t haystack = { + "Fastest string sort, search, split, " + "and shuffle for long strings and multi-gigabyte files in Python and C, " + "leveraging SIMD with Arm Neon and x86 AVX2 & AVX-512 intrinsics.", + 171}; + sz_string_view_t needle = {"SIMD", 4}; + + // Perform string-level operations + sz_size_t character_count = sz_count_char(haystack.start, haystack.length, "a"); + sz_string_start_t substring_position = sz_find_substring( + haystack.start, haystack.length, + needle.start, needle.length + ); + + // Hash strings + sz_u32_t crc32 = sz_hash_crc32(haystack.start, haystack.length); + + return EXIT_SUCCESS; +} diff --git a/recipes/stringzilla/all/test_package/test_package_3_0.cpp b/recipes/stringzilla/all/test_package/test_package_3_0.cpp new file mode 100644 index 0000000000000..9611c090a6122 --- /dev/null +++ b/recipes/stringzilla/all/test_package/test_package_3_0.cpp @@ -0,0 +1,20 @@ +#include +#include + +#include "stringzilla/stringzilla.hpp" + +namespace sz = ashvardanian::stringzilla; + +int main(void) { + sz::string haystack = "some string"; + sz::string_view needle = sz::string_view(haystack).substr(0, 4); + + auto substring_position = haystack.find(needle); // Or `rfind` + + haystack.end() - haystack.begin() == haystack.size(); // Or `rbegin`, `rend` + haystack.find_first_of(" \w\t") == 4; // Or `find_last_of`, `find_first_not_of`, `find_last_not_of` + haystack.starts_with(needle) == true; // Or `ends_with` + haystack.remove_prefix(needle.size()); // Why is this operation in-place?! + + return EXIT_SUCCESS; +} diff --git a/recipes/stringzilla/config.yml b/recipes/stringzilla/config.yml index c0ea771b63446..1873ea240511d 100644 --- a/recipes/stringzilla/config.yml +++ b/recipes/stringzilla/config.yml @@ -1,4 +1,6 @@ versions: + "3.8.4": + folder: all "2.0.4": folder: all "2.0.3":