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 7 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.1.1":
url: "https://github.com/ashvardanian/StringZilla/archive/refs/tags/v3.1.1.tar.gz"
sha256: "6f7905ee481fda0230a55075f9f4704284f2c18bd53d9e1c6ef78e3eaf29cea9"
"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
3 changes: 0 additions & 3 deletions recipes/stringzilla/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ find_package(stringzilla REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
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()
14 changes: 12 additions & 2 deletions recipes/stringzilla/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.scm import Version
import os


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

def layout(self):
Expand All @@ -15,6 +16,15 @@ def layout(self):
def requirements(self):
self.requires(self.tested_reference_str)

def generate(self):
tc = CMakeToolchain(self)
tc.preprocessor_definitions["STRINGZILLA_API"] = Version(self.dependencies["stringzilla"].ref.version).major
tc.generate()
deps = CMakeDeps(self)
deps.generate()
env = VirtualBuildEnv(self)
env.generate(scope="build")

def build(self):
cmake = CMake(self)
cmake.configure()
Expand Down
59 changes: 41 additions & 18 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,31 +1,31 @@
#include <cstdlib>
#include <iostream>
#if STRINGZILLA_API >= 3
#include <array>
#include <cstdint>
#include <vector>
#include "stringzilla/stringzilla.hpp"
#else
#include "stringzilla.h"
#endif

#ifdef STRINGZILLA_LESS_2_0

int main(void) {
// Initialize your haystack and needle
strzl_haystack_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};
strzl_needle_t needle = {"SIMD", 4};
#if STRINGZILLA_API >= 3

// Count occurrences of a character like a boss 😎
size_t count = strzl_naive_count_char(haystack, 'a');
namespace sz = ashvardanian::stringzilla;

// Find a character like you're searching for treasure 🏴‍☠️
size_t position = strzl_naive_find_char(haystack, 'a');
int main(void) {
sz::string haystack = "some string";
sz::string_view needle = sz::string_view(haystack).substr(0, 4);

// Find a substring like it's Waldo 🕵️‍♂️
size_t substring_position = strzl_naive_find_substr(haystack, needle);
auto substring_position = haystack.find(needle); // Or `rfind`

return EXIT_SUCCESS;
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?!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, for consistency add return EXIT_SUCCESS;.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

}

#else
#elif STRINGZILLA_API == 2

int main(void) {
// Initialize your haystack and needle
Expand All @@ -49,4 +49,27 @@ int main(void) {
return EXIT_SUCCESS;
}

#else

int main(void) {
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
// Initialize your haystack and needle
strzl_haystack_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};
strzl_needle_t needle = {"SIMD", 4};

// Count occurrences of a character like a boss 😎
size_t count = strzl_naive_count_char(haystack, 'a');

// Find a character like you're searching for treasure 🏴‍☠️
size_t position = strzl_naive_find_char(haystack, 'a');

// Find a substring like it's Waldo 🕵️‍♂️
size_t substring_position = strzl_naive_find_substr(haystack, needle);

return EXIT_SUCCESS;
}

#endif
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.1.1":
folder: all
"2.0.4":
folder: all
"2.0.3":
Expand Down
Loading