Skip to content

Commit

Permalink
conan-io#7646 make draco build latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
lederernc committed Oct 25, 2021
1 parent 5cb3fc9 commit 84eed5e
Showing 1 changed file with 80 additions and 38 deletions.
118 changes: 80 additions & 38 deletions recipes/draco/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DracoConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"target": ["encode_and_decode", "encode_only", "decode_only"],
"target": ["draco", "draco_static", "encode_and_decode", "encode_only", "decode_only"],
"enable_point_cloud_compression": [True, False],
"enable_mesh_compression": [True, False],
"enable_standard_edgebreaker": [True, False],
Expand Down Expand Up @@ -70,50 +70,92 @@ def build(self):
cmake = self._configure_cmake()
cmake.build(target=self._get_target())

def _version_conversion(self):
return list(map(int, self.version.split('.')))

def _configure_cmake(self):
# use different cmake definitions based on package version
print("DEBUG: self.version: {}", self.version)

major_version, minor_version, sub_version = self._version_conversion()

cmake = CMake(self)
cmake.definitions["ENABLE_POINT_CLOUD_COMPRESSION"] = self.options.enable_point_cloud_compression
cmake.definitions["ENABLE_MESH_COMPRESSION"] = self.options.enable_mesh_compression
if self.options.enable_mesh_compression:
cmake.definitions["ENABLE_STANDARD_EDGEBREAKER"] = self.options.enable_standard_edgebreaker
cmake.definitions["ENABLE_PREDICTIVE_EDGEBREAKER"] = self.options.enable_predictive_edgebreaker
cmake.definitions["ENABLE_BACKWARDS_COMPATIBILITY"] = self.options.enable_backwards_compatibility

# BUILD_FOR_GLTF is not needed, it is equivalent to:
# - enable_point_cloud_compression=False
# - enable_mesh_compression=True
# - enable_standard_edgebreaker=True
# - enable_predictive_edgebreaker=False
# - enable_backwards_compatibility=False
cmake.definitions["BUILD_FOR_GLTF"] = False

cmake.definitions["BUILD_UNITY_PLUGIN"] = False
cmake.definitions["BUILD_MAYA_PLUGIN"] = False
cmake.definitions["BUILD_USD_PLUGIN"] = False

cmake.definitions["ENABLE_CCACHE"] = False
cmake.definitions["ENABLE_DISTCC"] = False
cmake.definitions["ENABLE_EXTRA_SPEED"] = False
cmake.definitions["ENABLE_EXTRA_WARNINGS"] = False
cmake.definitions["ENABLE_GOMA"] = False
cmake.definitions["ENABLE_JS_GLUE"] = False
cmake.definitions["ENABLE_DECODER_ATTRIBUTE_DEDUPLICATION"] = False
cmake.definitions["ENABLE_TESTS"] = False
cmake.definitions["ENABLE_WASM"] = False
cmake.definitions["ENABLE_WERROR"] = False
cmake.definitions["ENABLE_WEXTRA"] = False
cmake.definitions["IGNORE_EMPTY_BUILD_TYPE"] = False
cmake.definitions["BUILD_ANIMATION_ENCODING"] = False

if major_version <= 1 and minor_version < 4:
cmake.definitions["ENABLE_POINT_CLOUD_COMPRESSION"] = self.options.enable_point_cloud_compression
cmake.definitions["ENABLE_MESH_COMPRESSION"] = self.options.enable_mesh_compression
if self.options.enable_mesh_compression:
cmake.definitions["ENABLE_STANDARD_EDGEBREAKER"] = self.options.enable_standard_edgebreaker
cmake.definitions["ENABLE_PREDICTIVE_EDGEBREAKER"] = self.options.enable_predictive_edgebreaker
cmake.definitions["ENABLE_BACKWARDS_COMPATIBILITY"] = self.options.enable_backwards_compatibility

# BUILD_FOR_GLTF is not needed, it is equivalent to:
# - enable_point_cloud_compression=False
# - enable_mesh_compression=True
# - enable_standard_edgebreaker=True
# - enable_predictive_edgebreaker=False
# - enable_backwards_compatibility=False
cmake.definitions["BUILD_FOR_GLTF"] = False

cmake.definitions["BUILD_UNITY_PLUGIN"] = False
cmake.definitions["BUILD_MAYA_PLUGIN"] = False
cmake.definitions["BUILD_USD_PLUGIN"] = False

cmake.definitions["ENABLE_CCACHE"] = False
cmake.definitions["ENABLE_DISTCC"] = False
cmake.definitions["ENABLE_EXTRA_SPEED"] = False
cmake.definitions["ENABLE_EXTRA_WARNINGS"] = False
cmake.definitions["ENABLE_GOMA"] = False
cmake.definitions["ENABLE_JS_GLUE"] = False
cmake.definitions["ENABLE_DECODER_ATTRIBUTE_DEDUPLICATION"] = False
cmake.definitions["ENABLE_TESTS"] = False
cmake.definitions["ENABLE_WASM"] = False
cmake.definitions["ENABLE_WERROR"] = False
cmake.definitions["ENABLE_WEXTRA"] = False
cmake.definitions["IGNORE_EMPTY_BUILD_TYPE"] = False
cmake.definitions["BUILD_ANIMATION_ENCODING"] = False
else:
cmake.definitions["DRACO_POINT_CLOUD_COMPRESSION"] = self.options.enable_point_cloud_compression
cmake.definitions["DRACO_MESH_COMPRESSION"] = self.options.enable_mesh_compression
if self.options.enable_mesh_compression:
cmake.definitions["DRACO_STANDARD_EDGEBREAKER"] = self.options.enable_standard_edgebreaker
cmake.definitions["DRACO_PREDICTIVE_EDGEBREAKER"] = self.options.enable_predictive_edgebreaker
cmake.definitions["DRACO_BACKWARDS_COMPATIBILITY"] = self.options.enable_backwards_compatibility

# DRACO_GLTF is not needed, it is equivalent to:
# - enable_point_cloud_compression=False
# - enable_mesh_compression=True
# - enable_standard_edgebreaker=True
# - enable_predictive_edgebreaker=False
# - enable_backwards_compatibility=False
cmake.definitions["DRACO_GLTF"] = False

cmake.definitions["DRACO_UNITY_PLUGIN"] = False
cmake.definitions["DRACO_MAYA_PLUGIN"] = False
cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared

cmake.definitions["DRACO_FAST"] = False
cmake.definitions["DRACO_JS_GLUE"] = False
cmake.definitions["DRACO_DECODER_ATTRIBUTE_DEDUPLICATION"] = False
cmake.definitions["DRACO_TESTS"] = False
cmake.definitions["DRACO_WASM"] = False
cmake.definitions["DRACO_ANIMATION_ENCODING"] = False

cmake.configure(build_folder=self._build_subfolder)
return cmake

def _get_target(self):
return {
"encode_and_decode": "draco",
"encode_only": "dracoenc",
"decode_only": "dracodec"
}.get(str(self.options.target))
major_version, minor_version, sub_version = self._version_conversion()

if major_version <=1 and minor_version < 4:
return {
"encode_and_decode": "draco",
"encode_only": "dracoenc",
"decode_only": "dracodec"
}.get(str(self.options.target))
if self.options.shared:
return "draco_shared"
return "draco_static"

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
Expand Down

0 comments on commit 84eed5e

Please sign in to comment.