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

stringzilla: add version 3.8.4 #22708

Merged
merged 29 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions recipes/stringzilla/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
27 changes: 21 additions & 6 deletions recipes/stringzilla/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = []
Expand Down
11 changes: 7 additions & 4 deletions recipes/stringzilla/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion recipes/stringzilla/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
29 changes: 1 addition & 28 deletions recipes/stringzilla/all/test_package/test_package.cpp
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <cstdlib>
#include <iostream>
#include "stringzilla.h"

#ifdef STRINGZILLA_LESS_2_0
#include "stringzilla.h"

int main(void) {
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
// Initialize your haystack and needle
Expand All @@ -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
26 changes: 26 additions & 0 deletions recipes/stringzilla/all/test_package/test_package_2_0.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <cstdlib>
#include <iostream>

#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;
}
20 changes: 20 additions & 0 deletions recipes/stringzilla/all/test_package/test_package_3_0.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <cstdlib>
#include <iostream>

#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;
}
2 changes: 2 additions & 0 deletions recipes/stringzilla/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"3.8.4":
folder: all
"2.0.4":
folder: all
"2.0.3":
Expand Down
Loading