Skip to content

Commit

Permalink
Bazel Support: Use Imath and libdeflate live at head (#1882)
Browse files Browse the repository at this point in the history
Signed-off-by: Vertexwahn <[email protected]>
  • Loading branch information
Vertexwahn authored Oct 13, 2024
1 parent 48e99c8 commit 74a0f59
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.3.1
7.3.2
24 changes: 22 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "imath", version = "3.1.12")
bazel_dep(name = "libdeflate", version = "1.21")
bazel_dep(name = "imath")
bazel_dep(name = "libdeflate")
bazel_dep(name = "platforms", version = "0.0.10")

archive_override(
module_name = "imath",
patches = [
"//bazel:imath_add_build_file.patch",
"//bazel:imath_module_dot_bazel.patch",
],
strip_prefix = "Imath-main",
urls = ["https://github.com/AcademySoftwareFoundation/Imath/archive/refs/heads/main.zip"],
)

archive_override(
module_name = "libdeflate",
patches = [
"//bazel:libdeflate_add_build_file.patch",
"//bazel:libdeflate_module_dot_bazel.patch",
],
strip_prefix = "libdeflate-master",
urls = ["https://github.com/ebiggers/libdeflate/archive/refs/heads/master.zip"],
)
1 change: 1 addition & 0 deletions bazel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Empty by intend
86 changes: 86 additions & 0 deletions bazel/imath_add_build_file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
--- /dev/null
+++ BUILD.bazel
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) Contributors to the OpenEXR Project.
+
+load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
+
+expand_template(
+ name = "ImathConfig",
+ out = "src/Imath/ImathConfig.h",
+ substitutions = {
+ "@IMATH_INTERNAL_NAMESPACE@": "Imath_3_1",
+ "@IMATH_LIB_VERSION@": "3.1.12",
+ "@IMATH_NAMESPACE_CUSTOM@": "0",
+ "@IMATH_NAMESPACE@": "Imath",
+ "@IMATH_PACKAGE_NAME@": "Imath 3.1.12",
+ "@Imath_VERSION_MAJOR@": "3",
+ "@Imath_VERSION_MINOR@": "1",
+ "@Imath_VERSION_PATCH@": "12",
+ "@IMATH_VERSION@": "3.1.12",
+ "#cmakedefine IMATH_HALF_USE_LOOKUP_TABLE": "#define IMATH_HALF_USE_LOOKUP_TABLE",
+ "#cmakedefine IMATH_ENABLE_API_VISIBILITY": "#define IMATH_ENABLE_API_VISIBILITY",
+ "#cmakedefine IMATH_HAVE_LARGE_STACK": "/* #undef IMATH_HAVE_LARGE_STACK */",
+ "#cmakedefine01 IMATH_USE_NOEXCEPT": "#define IMATH_USE_NOEXCEPT 1",
+ },
+ template = "config/ImathConfig.h.in",
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
+ name = "Imath",
+ srcs = [
+ "src/Imath/ImathColorAlgo.cpp",
+ "src/Imath/ImathFun.cpp",
+ "src/Imath/ImathMatrixAlgo.cpp",
+ "src/Imath/ImathRandom.cpp",
+ "src/Imath/half.cpp",
+ "src/Imath/toFloat.h",
+ ],
+ hdrs = [
+ "src/Imath/ImathBox.h",
+ "src/Imath/ImathBoxAlgo.h",
+ "src/Imath/ImathColor.h",
+ "src/Imath/ImathColorAlgo.h",
+ "src/Imath/ImathConfig.h",
+ "src/Imath/ImathEuler.h",
+ "src/Imath/ImathExport.h",
+ "src/Imath/ImathForward.h",
+ "src/Imath/ImathFrame.h",
+ "src/Imath/ImathFrustum.h",
+ "src/Imath/ImathFrustumTest.h",
+ "src/Imath/ImathFun.h",
+ "src/Imath/ImathGL.h",
+ "src/Imath/ImathGLU.h",
+ "src/Imath/ImathInt64.h",
+ "src/Imath/ImathInterval.h",
+ "src/Imath/ImathLine.h",
+ "src/Imath/ImathLineAlgo.h",
+ "src/Imath/ImathMath.h",
+ "src/Imath/ImathMatrix.h",
+ "src/Imath/ImathMatrixAlgo.h",
+ "src/Imath/ImathNamespace.h",
+ "src/Imath/ImathPlane.h",
+ "src/Imath/ImathPlatform.h",
+ "src/Imath/ImathQuat.h",
+ "src/Imath/ImathRandom.h",
+ "src/Imath/ImathRoots.h",
+ "src/Imath/ImathShear.h",
+ "src/Imath/ImathSphere.h",
+ "src/Imath/ImathTypeTraits.h",
+ "src/Imath/ImathVec.h",
+ "src/Imath/ImathVecAlgo.h",
+ "src/Imath/half.h",
+ "src/Imath/halfFunction.h",
+ "src/Imath/halfLimits.h",
+ ],
+ includes = ["src/Imath"],
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "imath",
+ actual = ":Imath",
+ visibility = ["//visibility:public"],
+)
9 changes: 9 additions & 0 deletions bazel/imath_module_dot_bazel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- MODULE.bazel
+++ MODULE.bazel
@@ -0,0 +1,6 @@
+module(
+ name = "imath",
+ compatibility_level = 1,
+)
+
+bazel_dep(name = "bazel_skylib", version = "1.7.1")
55 changes: 55 additions & 0 deletions bazel/libdeflate_add_build_file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--- /dev/null
+++ BUILD.bazel
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) Contributors to the OpenEXR Project.
+
+cc_library(
+ name = "deflate",
+ srcs = [
+ "common_defs.h",
+ "lib/adler32.c",
+ "lib/arm/adler32_impl.h",
+ "lib/arm/cpu_features.c",
+ "lib/arm/cpu_features.h",
+ "lib/arm/crc32_impl.h",
+ "lib/arm/crc32_pmull_helpers.h",
+ "lib/arm/crc32_pmull_wide.h",
+ "lib/arm/matchfinder_impl.h",
+ "lib/bt_matchfinder.h",
+ "lib/cpu_features_common.h",
+ "lib/crc32_multipliers.h",
+ "lib/crc32_tables.h",
+ "lib/decompress_template.h",
+ "lib/deflate_compress.c",
+ "lib/deflate_compress.h",
+ "lib/deflate_constants.h",
+ "lib/deflate_decompress.c",
+ "lib/gzip_constants.h",
+ "lib/hc_matchfinder.h",
+ "lib/ht_matchfinder.h",
+ "lib/lib_common.h",
+ "lib/matchfinder_common.h",
+ "lib/utils.c",
+ "lib/x86/adler32_impl.h",
+ "lib/x86/adler32_template.h",
+ "lib/x86/cpu_features.c",
+ "lib/x86/cpu_features.h",
+ "lib/x86/crc32_impl.h",
+ "lib/x86/crc32_pclmul_template.h",
+ "lib/x86/decompress_impl.h",
+ "lib/x86/matchfinder_impl.h",
+ "lib/zlib_compress.c",
+ "lib/zlib_constants.h",
+ "lib/zlib_decompress.c",
+ ],
+ hdrs = ["libdeflate.h"],
+ includes = ["."],
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "libdeflate",
+ actual = ":deflate",
+ visibility = ["//visibility:public"],
+)
7 changes: 7 additions & 0 deletions bazel/libdeflate_module_dot_bazel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--- MODULE.bazel
+++ MODULE.bazel
@@ -0,0 +1,4 @@
+module(
+ name = "libdeflate",
+ compatibility_level = 1,
+)

0 comments on commit 74a0f59

Please sign in to comment.