-
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.
iso8601lib: add new recipe, version cci.20230123
- Loading branch information
Showing
8 changed files
with
171 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.20230123": | ||
url: "https://github.com/TimSC/iso8601lib/archive/7a0cd0ff1bffd3f7a436e25860f5b461f4c35dc6.zip" | ||
sha256: "2d6363eda2ec958bd7da735ca9520d658df11666326e96f20f278db565b9af73" |
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,78 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanException | ||
from conan.tools.files import get, copy, collect_libs | ||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout | ||
import os | ||
|
||
required_conan_version = ">=1.50.0" | ||
|
||
|
||
class Iso8601LibConan(ConanFile): | ||
name = "iso8601lib" | ||
description = "Parsing a subset of ISO 8601 datetimes, dates and times in C." | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/TimSC/iso8601lib" | ||
topics = ("iso8601", "date", "time", "timezone") | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
try: | ||
del self.options.fPIC | ||
except ConanException: | ||
pass | ||
try: | ||
del self.settings.compiler.libcxx | ||
except ConanException: | ||
pass | ||
try: | ||
del self.settings.compiler.cppstd | ||
except ConanException: | ||
pass | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
# To install relocatable shared libs on Macos | ||
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" | ||
# Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) | ||
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" | ||
tc.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = collect_libs(self) | ||
|
||
self.cpp_info.filenames["cmake_find_package"] = self.name | ||
self.cpp_info.filenames["cmake_find_package_multi"] = self.name | ||
self.cpp_info.names["cmake_find_package"] = self.name | ||
self.cpp_info.names["cmake_find_package_multi"] = self.name | ||
|
||
self.cpp_info.defines.append("ISO8601LIB_EXPORT") |
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,7 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(test_package CXX) | ||
|
||
find_package(iso8601lib REQUIRED CONFIG) | ||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE iso8601lib::iso8601lib) |
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,27 @@ | ||
#include <cstdlib> | ||
#include <iostream> | ||
#include <time.h> | ||
#include "iso8601.h" | ||
|
||
int main(void) | ||
{ | ||
const char* dateTime = "1997-07-16T19:20:30.45+01:00"; | ||
|
||
struct tm isoDateTime; | ||
int timezoneOffsetMin; | ||
if (ParseIso8601Datetime(dateTime, &isoDateTime, &timezoneOffsetMin)) | ||
{ | ||
std::cout << "Year: " << isoDateTime.tm_year + 1900 << "\n"; | ||
std::cout << "Month: " << isoDateTime.tm_mon + 1 << "\n"; | ||
std::cout << "Day: " << isoDateTime.tm_mday << "\n"; | ||
std::cout << "Hour: " << isoDateTime.tm_hour << "\n"; | ||
std::cout << "Minute: " << isoDateTime.tm_min << "\n"; | ||
std::cout << "Second: " << isoDateTime.tm_sec << "\n"; | ||
std::cout << "Timezone offset: " << timezoneOffsetMin << "\n"; | ||
} | ||
else | ||
{ | ||
std::cout << "Could not parse datetime " << dateTime << "\n"; | ||
} | ||
return EXIT_SUCCESS; | ||
} |
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,8 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
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.20230123": | ||
folder: all |