-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* jeaiii-itoa: add recipe * fix wrong placefolder
- Loading branch information
Showing
8 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"cci.20220602": | ||
url: "https://github.com/jeaiii/itoa/archive/84f25b835c8bbcf69eb97802216f8095bf94ef13.tar.gz" | ||
sha256: "a116159f9b49922124b1c87f9989a7a8592f582904d98a3d6398e9013eca3f0f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.files import get, copy | ||
import os | ||
|
||
|
||
required_conan_version = ">=1.50.0" | ||
|
||
|
||
class ItoaConan(ConanFile): | ||
name = "jeaiii-itoa" | ||
description = "Fast integer to ascii / integer to string conversion" | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/jeaiii/itoa/" | ||
topics = ("string-conversion", "itona", "integer-conversion",) | ||
settings = "os", "arch", "compiler", "build_type" | ||
no_copy_source = True | ||
|
||
@property | ||
def _minimum_cpp_standard(self): | ||
return 17 | ||
|
||
def export_sources(self): | ||
for p in self.conan_data.get("patches", {}).get(self.version, []): | ||
copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, self._minimum_cpp_standard) | ||
|
||
def package_id(self): | ||
self.info.clear() | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], | ||
destination=self.source_folder, strip_root=True) | ||
|
||
def build(self): | ||
pass | ||
|
||
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, "include")) | ||
|
||
def package_info(self): | ||
self.cpp_info.bindirs = [] | ||
self.cpp_info.frameworkdirs = [] | ||
self.cpp_info.libdirs = [] | ||
self.cpp_info.resdirs = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(test_package CXX) | ||
|
||
find_package(jeaiii-itoa REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE jeaiii-itoa::jeaiii-itoa) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <iostream> | ||
|
||
#include "itoa/jeaiii_to_text.h" | ||
|
||
template <typename T> | ||
void itoa(T n, char* b) { | ||
*jeaiii::to_text_from_integer(b, n) = '\0'; | ||
} | ||
|
||
template <typename T> | ||
void show(T n) { | ||
char text[32]; | ||
itoa(n, text); | ||
std::cout << text << "\n"; | ||
} | ||
|
||
int main(void) { | ||
show(-1); | ||
show(1 << 31); | ||
show(0x7fffffff); | ||
show(-0x7fffffff - 1); | ||
show(17999999999999999999ULL); | ||
show(-5999999999999999999LL); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(test_package CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(jeaiii-itoa REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE jeaiii-itoa::jeaiii-itoa) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from conans import ConanFile, CMake | ||
from conan.tools.build import cross_building | ||
import os | ||
|
||
|
||
class TestPackageV1Conan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"cci.20220602": | ||
folder: all |