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 16 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.7.0":
url: "https://github.com/ashvardanian/StringZilla/archive/refs/tags/v3.7.0.tar.gz"
sha256: "214d926fc827e5975fabe63f112cbd4d676d5ceb1c37fc4d6d83785a50c518e0"
"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
32 changes: 29 additions & 3 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,9 @@
#include <cstdlib>
#include <iostream>
#include "stringzilla.h"

#ifdef STRINGZILLA_LESS_2_0
#if STRINGZILLA_API == 1

#include "stringzilla.h"

int main(void) {
// Initialize your haystack and needle
Expand All @@ -25,7 +26,9 @@ int main(void) {
return EXIT_SUCCESS;
}

#else
#elif STRINGZILLA_API == 2

#include "stringzilla.h"

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

#else

#include <array>
#include <cstdint>
#include <vector>
#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;
}

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