From 1cea6ed42d828f19c1307fe9ce27312ccf2a6c50 Mon Sep 17 00:00:00 2001 From: Esteban DUGUEPEROUX Date: Mon, 22 Apr 2024 21:38:23 +0200 Subject: [PATCH] Add recipe for partio --- recipes/partio/all/conandata.yml | 4 + recipes/partio/all/conanfile.py | 101 ++++++++++++++++++ .../partio/all/test_package/CMakeLists.txt | 9 ++ recipes/partio/all/test_package/conanfile.py | 25 +++++ .../partio/all/test_package/test_package.cpp | 42 ++++++++ recipes/partio/config.yml | 3 + 6 files changed, 184 insertions(+) create mode 100644 recipes/partio/all/conandata.yml create mode 100644 recipes/partio/all/conanfile.py create mode 100644 recipes/partio/all/test_package/CMakeLists.txt create mode 100644 recipes/partio/all/test_package/conanfile.py create mode 100644 recipes/partio/all/test_package/test_package.cpp create mode 100644 recipes/partio/config.yml diff --git a/recipes/partio/all/conandata.yml b/recipes/partio/all/conandata.yml new file mode 100644 index 0000000000000..f15291914ccdb --- /dev/null +++ b/recipes/partio/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.17.3": + url: "https://github.com/wdas/partio/archive/refs/tags/v1.17.3.tar.gz" + sha256: "08a571ca75cf133f373415dfd50b7d0e33a0dd1811dfb63409f0ae46652033c1" diff --git a/recipes/partio/all/conanfile.py b/recipes/partio/all/conanfile.py new file mode 100644 index 0000000000000..2cf28dfd526e6 --- /dev/null +++ b/recipes/partio/all/conanfile.py @@ -0,0 +1,101 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.53.0" + +class PartioConan(ConanFile): + name = "partio" + description = "Library for easily reading/writing/manipulating common animation particle formats such as PDB, BGEO, PTC." + license = "LicenseRef-LICENSE" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/wdas/partio" + topics = ("point-cloud", "particles", "houdini") + 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 14 + + @property + def _compilers_minimum_version(self): + return { + "apple-clang": "10", + "clang": "7", + "gcc": "7", + "msvc": "191", + "Visual Studio": "15", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("zlib/[>=1.2.11 <2]") + self.requires("freeglut/3.4.0") + self.requires("opengl/system") + + 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"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["PARTIO_BUILD_SHARED_LIBS"] = self.options.shared + tc.generate() + + tc = CMakeDeps(self) + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "add_subdirectory(src/doc)", "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "python3.12")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + diff --git a/recipes/partio/all/test_package/CMakeLists.txt b/recipes/partio/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..89ee4d4d29670 --- /dev/null +++ b/recipes/partio/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) + +project(test_package LANGUAGES CXX) + +find_package(partio REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE partio::partio) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/partio/all/test_package/conanfile.py b/recipes/partio/all/test_package/conanfile.py new file mode 100644 index 0000000000000..71e5c41339861 --- /dev/null +++ b/recipes/partio/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPartioConan(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.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/partio/all/test_package/test_package.cpp b/recipes/partio/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..a5f0890d4a9e6 --- /dev/null +++ b/recipes/partio/all/test_package/test_package.cpp @@ -0,0 +1,42 @@ +#include +#include +#ifdef PARTIO_WIN32 +#define M_PI (3.14159265359893238) +#endif + +#include + +using namespace Partio; +int main(void) { + ParticlesDataMutable* p=create(); + ParticleAttribute positionAttr=p->addAttribute("position",VECTOR,3); + ParticleAttribute normalAttr=p->addAttribute("normal",VECTOR,3); + int n=30; + for(int i=0;iaddParticle(); + float* pos=p->dataWrite(positionAttr,particle); + float* norm=p->dataWrite(normalAttr,particle); + float theta=i*2*M_PI/(float)n; + pos[2]=cos(theta); + pos[0]=sin(theta); + pos[1]=0; + norm[0]=cos(theta); + norm[2]=-sin(theta); + norm[1]=0; + + } + write("circle.00001.bgeo",*p); + write("circle.00001.geo",*p); + write("circle.00001.bin",*p); + write("circle.00001.pdc",*p); + write("circle.00001.pdb",*p); + write("circle.00001.pda",*p); + write("circle.00001.ptc",*p); + write("circle.00001.rib",*p); + write("circle.00001.mc",*p); + + + p->release(); + + return EXIT_SUCCESS; +} diff --git a/recipes/partio/config.yml b/recipes/partio/config.yml new file mode 100644 index 0000000000000..a138b582eaf2e --- /dev/null +++ b/recipes/partio/config.yml @@ -0,0 +1,3 @@ +versions: + "1.17.3": + folder: all