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

samarium: migrate to Conan v2, drop old version #25396

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
28 changes: 2 additions & 26 deletions recipes/samarium/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
sources:
"1.0.0":
sha256: 943de75803f492f78c5d55fe43be298fbb66156cc22946a3c6cc6b0634efc2e2
url: https://github.com/strangeQuark1041/samarium/archive/refs/tags/v1.0.0.tar.gz
"1.0.1":
sha256: 3748ad1095805338d0d54ca7b60a155520188970946b247d56cc9b5eeb397358
url: https://github.com/strangeQuark1041/samarium/archive/refs/tags/v1.0.1.tar.gz
patches:
"1.0.0":
- patch_file: "patches/1.0.0-updated-cmake.patch"
patch_description: "Use find_package for CMakeDeps"
patch_type: "conan"
sha256: "2be2eadc468fe676f547793fc7ec48bc38ce6f1daa47a497cd2535aaa493fa9a"

- patch_file: "patches/1.0.0-Grid.hpp-include-vector.patch"
patch_description: "add missing #include <vector>"
patch_type: "portability"
sha256: "0326eb790fc55630efe138bc9b359754d2de23c4aa37179faa04821f83efa9c3"

- patch_file: "patches/1.0.0-RandomGenerator.hpp-link.patch"
patch_description: "Fix static function linking"
patch_type: "portability"
sha256: "218318c017500ab4c6360dafaf0523736295ddac323c04aaad5fc8a31867b4f0"

- patch_file: "patches/1.0.0-RandomGenerator.cpp-link.patch"
patch_description: "Fix static function linking"
patch_type: "portability"
sha256: "f5d0cc6a108bb3f5f22a88c29f5eda1ddf73c25720e894e7ac3c67396e687087"
url: "https://github.com/jjbel/samarium/archive/refs/tags/v1.0.1.tar.gz"
sha256: "3748ad1095805338d0d54ca7b60a155520188970946b247d56cc9b5eeb397358"
102 changes: 57 additions & 45 deletions recipes/samarium/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,84 +1,96 @@
from os import path
import os

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.files import patch, copy, get
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain, CMakeDeps
from conan.tools.files import copy, get
from conan.tools.scm import Version

required_conan_version = ">=1.47.0"


class SamariumConan(ConanFile):
name = "samarium"
description = "2-D physics simulation library"
homepage = "https://strangequark1041.github.io/samarium/"
homepage = "https://jjbel.github.io/samarium/"
url = "https://github.com/conan-io/conan-center-index/"
license = "MIT"
topics = ("cpp20", "physics", "2d", "simulation")
generators = "CMakeDeps", "CMakeToolchain"
requires = "fmt/9.0.0", "sfml/2.5.1", "range-v3/0.12.0", "stb/cci.20210910", "tl-expected/20190710"

settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [
True, False]}
default_options = {"shared": False, "fPIC": True}
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

@property
def _min_cppstd(self):
return 20

@property
def _compilers_minimum_version(self):
return {
"gcc": "11.0",
"Visual Studio": "16",
"gcc": "11",
"clang": "13",
"apple-clang": "13",
"msvc": "192",
"Visual Studio": "16",
}

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

def configure(self):
if self.options.shared:
del self.options.fPIC

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def validate(self):
if self.version == "1.0.0" and self.settings.os == "Macos":
raise ConanInvalidConfiguration("Macos not supported for v1.0.0")

compiler = str(self.settings.compiler)
if compiler not in self._compilers_minimum_version:
self.output.warn(
"Unknown compiler, assuming it supports at least C++20")
return

version = Version(self.settings.compiler.version)
if version < self._compilers_minimum_version[compiler]:
raise ConanInvalidConfiguration(
f"{self.name} requires a compiler that supports at least C++20")
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

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

def export_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])
def requirements(self):
self.requires("fmt/10.2.1", transitive_headers=True, transitive_libs=True)
self.requires("sfml/2.6.1", transitive_headers=True, transitive_libs=True)
self.requires("range-v3/cci.20240905", transitive_headers=True, transitive_libs=True)
self.requires("stb/cci.20230920")
self.requires("tl-expected/20190710", transitive_headers=True, transitive_libs=True)

def build(self):
for patch_ in self.conan_data.get("patches", {}).get(self.version, []):
patch(self, **patch_)
def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

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

def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["RUN_CONAN"] = False
tc.cache_variables["BUILD_UNIT_TESTS"] = False
tc.cache_variables["BUILD_EXAMPLES"] = False
tc.cache_variables["BUILD_DOCS"] = False
tc.cache_variables["BUILD_DOCS_TARGET"] = False
tc.generate()
deps = CMakeDeps(self)
deps.generate()

def build(self):
cmake = CMake(self)
cmake.configure(build_script_folder="src")
cmake.configure()
cmake.build()

def package(self):
copy(self, "LICENSE.md", src=self.folders.source_folder,
dst=path.join(self.package_folder, "licenses"))

copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()

Expand Down
12 changes: 0 additions & 12 deletions recipes/samarium/all/patches/1.0.0-Grid.hpp-include-vector.patch

This file was deleted.

22 changes: 0 additions & 22 deletions recipes/samarium/all/patches/1.0.0-RandomGenerator.cpp-link.patch

This file was deleted.

34 changes: 0 additions & 34 deletions recipes/samarium/all/patches/1.0.0-RandomGenerator.hpp-link.patch

This file was deleted.

39 changes: 0 additions & 39 deletions recipes/samarium/all/patches/1.0.0-updated-cmake.patch

This file was deleted.

4 changes: 2 additions & 2 deletions recipes/samarium/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ def build(self):

def test(self):
if not cross_building(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, run_environment=True)
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
2 changes: 0 additions & 2 deletions recipes/samarium/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
versions:
"1.0.0":
folder: all
"1.0.1":
folder: all
Loading