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

Add recipe for partio #23732

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions recipes/partio/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.17.3":
url: "https://github.com/wdas/partio/archive/refs/tags/v1.17.3.tar.gz"
sha256: "08a571ca75cf133f373415dfd50b7d0e33a0dd1811dfb63409f0ae46652033c1"
101 changes: 101 additions & 0 deletions recipes/partio/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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"))

9 changes: 9 additions & 0 deletions recipes/partio/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
25 changes: 25 additions & 0 deletions recipes/partio/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.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")
42 changes: 42 additions & 0 deletions recipes/partio/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <cstdlib>
#include <Partio.h>
#ifdef PARTIO_WIN32
#define M_PI (3.14159265359893238)
#endif

#include <cmath>

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;i<n;i++){
int particle=p->addParticle();
float* pos=p->dataWrite<float>(positionAttr,particle);
float* norm=p->dataWrite<float>(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;
}
3 changes: 3 additions & 0 deletions recipes/partio/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.17.3":
folder: all
Loading