Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
(conan-io#12185) (conan-io#12184): Adds zmarok-semver/1.1.0
Browse files Browse the repository at this point in the history
* (conan-io#12184): Adds semver200/1.1.0

* Fix linter errors for v2.

* Add compiler check for C++14 standard.

* Fix macro invocation.

* Import check_min_cppstd

* Fix macro invocation in testpackage.

* Updates from review comments.

* Adjust dll directory.

* v2.0 Migrations.

* Remove fPIC option from Windows builds.

* Remove support for shared object on Windows.

* Adjust import.

* Prepare for Conan 2.0

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Prepare for Conan 2.0

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Fix line

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* not used

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/semver200/all/test_package/conanfile.py

* Update recipes/semver200/all/conandata.yml

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/semver200/all/conandata.yml

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/semver200/all/conandata.yml

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Rename package, adjust include path.

* Add libm to system library dependency list.

* No libm in Windows.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
  • Loading branch information
3 people authored and ericLemanissier committed Sep 26, 2022
1 parent e1e03a0 commit a7d8aec
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 0 deletions.
15 changes: 15 additions & 0 deletions recipes/zmarok-semver/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sources:
"1.1.0":
url: "https://github.com/zmarko/semver/archive/refs/tags/1.1.0.tar.gz"
sha256: bbea7e679684331b1059b773786559d790dd7aaa1e5ca24c0de12c9d5a4f2aed
patches:
"1.1.0":
- patch_file: "patches/0001-unused-var-fix.patch"
patch_description: "Avoids: error: unused parameter 's' [-Werror,-Wunused-parameter]"
patch_source: "https://github.com/zmarko/semver/pull/4"
patch_type: "portability"
sha256: "ea7b241e8f37295e7943977fc66eaa6fa85d647b73c8cc1f4b566fd8078b0897"
- patch_file: "patches/0002-macro-invocation-fix.patch"
patch_description: "Fix minor() and major() macros invocation"
patch_type: "portability"
sha256: "ae12e00b4e1710b105491283ea10fa9c8e8015c623ce6784645f709b3a00efd7"
81 changes: 81 additions & 0 deletions recipes/zmarok-semver/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import apply_conandata_patches, copy, get
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
import os


required_conan_version = ">=1.50.0"


class ZmarokSemverConan(ConanFile):
name = "zmarok-semver"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/zmarko/semver"
description = "Semantic versioning for cpp14"
topics = ("versioning", "semver", "semantic")
settings = "os", "compiler", "arch", "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:
del self.options.fPIC

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 validate(self):
if self.info.settings.os == "Windows" and self.info.options.shared:
raise ConanInvalidConfiguration("Shared library on Windows is not supported.")
if self.info.settings.compiler.cppstd:
check_min_cppstd(self, 14)

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self.source_folder)

def layout(self):
cmake_layout(self, src_folder="src")

def generate(self):
gt = CMakeToolchain(self)
gt.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
# Parent Build system does not support installation; so we must manually package
hdr_src = os.path.join(self.source_folder, "include")
hdr_dst = os.path.join(self.package_folder, "include")
copy(self, "*.h", hdr_src, hdr_dst)
copy(self, "*.inl", hdr_src, hdr_dst)

lib_dir = os.path.join(self.package_folder, "lib")
copy(self, "*.a", self.build_folder, lib_dir, keep_path=False)
copy(self, "*.lib", self.build_folder, lib_dir, keep_path=False)
copy(self, "*.so", self.build_folder, lib_dir, keep_path=False)
copy(self, "*.dylib", self.build_folder, lib_dir, keep_path=False)
copy(self, "*.dll*", self.build_folder, os.path.join(self.package_folder, "bin"), keep_path=False)

def package_info(self):
self.cpp_info.libs = ["semver"]
if not self.settings.os in ["Windows"]:
self.cpp_info.system_libs = ["m"]
19 changes: 19 additions & 0 deletions recipes/zmarok-semver/all/patches/0001-unused-var-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff -Naur a/src/Semver200_modifier.cpp b/src/Semver200_modifier.cpp
--- a/src/Semver200_modifier.cpp 2021-04-06 19:10:15.986509743 +0000
+++ b/src/Semver200_modifier.cpp 2021-04-06 19:10:49.807335550 +0000
@@ -50,7 +50,7 @@
return Version_data{ s.major, s.minor, s.patch, s.prerelease_ids, b };
}

- Version_data Semver200_modifier::reset_major(const Version_data& s, const int m) const {
+ Version_data Semver200_modifier::reset_major(const Version_data&, const int m) const {
if (m < 0) throw Modification_error("major version cannot be less than 0");
return Version_data{ m, 0, 0, Prerelease_identifiers{}, Build_identifiers{} };
}
@@ -72,4 +72,4 @@
Version_data Semver200_modifier::reset_build(const Version_data& s, const Build_identifiers& b) const {
return Version_data{ s.major, s.minor, s.patch, s.prerelease_ids, b };
}
-}
\ No newline at end of file
+}
32 changes: 32 additions & 0 deletions recipes/zmarok-semver/all/patches/0002-macro-invocation-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff -Naur a/include/version.h b/include/version.h
--- a/include/version.h 2019-03-27 02:47:58.000000000 -0700
+++ b/include/version.h 2022-08-18 09:01:59.633528129 -0700
@@ -148,8 +148,8 @@
/// Copy version data from another Basic_version to this one.
Basic_version& operator=(const Basic_version&);

- int major() const; ///< Get major version.
- int minor() const; ///< Get minor version.
+ int (major)() const; ///< Get major version.
+ int (minor)() const; ///< Get minor version.
int patch() const; ///< Get patch version.
const std::string prerelease() const; ///< Get prerelease version string.
const std::string build() const; ///< Get build version string.
diff -Naur a/include/version.inl b/include/version.inl
--- a/include/version.inl 2019-03-27 02:47:58.000000000 -0700
+++ b/include/version.inl 2022-08-18 09:01:30.821575915 -0700
@@ -65,12 +65,12 @@
const Basic_version<Parser, Comparator, Modifier>&) = default;

template<typename Parser, typename Comparator, typename Modifier>
- int Basic_version<Parser, Comparator, Modifier>::major() const {
+ int (Basic_version<Parser, Comparator, Modifier>::major)() const {
return ver_.major;
}

template<typename Parser, typename Comparator, typename Modifier>
- int Basic_version<Parser, Comparator, Modifier>::minor() const {
+ int (Basic_version<Parser, Comparator, Modifier>::minor)() const {
return ver_.minor;
}

8 changes: 8 additions & 0 deletions recipes/zmarok-semver/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

find_package(zmarok-semver CONFIG REQUIRED)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE zmarok-semver::zmarok-semver)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)
25 changes: 25 additions & 0 deletions recipes/zmarok-semver/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run
import os


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

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")
8 changes: 8 additions & 0 deletions recipes/zmarok-semver/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <iostream>
#include <semver200.h>

int main(void) {
auto ver{version::Semver200_version("1.0.1+22910")};
std::cout << "Parsed Major: " << (ver.major)() << std::endl;
return 0;
}
11 changes: 11 additions & 0 deletions recipes/zmarok-semver/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.11)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(zmarok-semver CONFIG REQUIRED)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE zmarok-semver::zmarok-semver)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)
19 changes: 19 additions & 0 deletions recipes/zmarok-semver/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from conans import ConanFile
from conans import CMake
from conan.tools.build import cross_building
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
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)
3 changes: 3 additions & 0 deletions recipes/zmarok-semver/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.1.0":
folder: all

0 comments on commit a7d8aec

Please sign in to comment.