Skip to content

Commit

Permalink
Use Skylib expand_template instead of own implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Vertexwahn <[email protected]>
  • Loading branch information
Vertexwahn authored and meshula committed Oct 19, 2022
1 parent ed7fc74 commit 08c9e76
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 58 deletions.
54 changes: 29 additions & 25 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) Contributors to the OpenEXR Project.

load("//:bazel/third_party/generate_header.bzl", "generate_header")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")

config_setting(
name = "windows",
constraint_values = ["@platforms//os:windows"],
)

generate_header(
name = "IexConfig.h",
expand_template(
name = "IexConfig",
out = "src/lib/Iex/IexConfig.h",
substitutions = {
"@IEX_INTERNAL_NAMESPACE@": "Iex_3_2",
"@IEX_NAMESPACE_CUSTOM@": "0",
Expand All @@ -18,8 +19,9 @@ generate_header(
template = "cmake/IexConfig.h.in",
)

generate_header(
name = "IexConfigInternal.h",
expand_template(
name = "IexConfigInternal",
out = "src/lib/Iex/IexConfigInternal.h",
substitutions = {
"#cmakedefine HAVE_UCONTEXT_H 1": "/* #undef HAVE_UCONTEXT_H */",
"#cmakedefine IEX_HAVE_CONTROL_REGISTER_SUPPORT 1": "/* #undef IEX_HAVE_CONTROL_REGISTER_SUPPORT */",
Expand All @@ -28,8 +30,9 @@ generate_header(
template = "cmake/IexConfigInternal.h.in",
)

generate_header(
name = "IlmThreadConfig.h",
expand_template(
name = "IlmThreadConfig",
out = "src/lib/IlmThread/IlmThreadConfig.h",
substitutions = {
"@ILMTHREAD_INTERNAL_NAMESPACE@": "IlmThread_3_2",
"@ILMTHREAD_NAMESPACE_CUSTOM@": "0",
Expand All @@ -40,8 +43,9 @@ generate_header(
template = "cmake/IlmThreadConfig.h.in",
)

generate_header(
name = "OpenEXRConfig.h",
expand_template(
name = "OpenEXRConfig",
out = "src/lib/OpenEXR/OpenEXRConfig.h",
substitutions = {
"@OPENEXR_IMF_NAMESPACE@": "Imf",
"@OPENEXR_INTERNAL_IMF_NAMESPACE@": "Imf_3_2",
Expand All @@ -59,8 +63,9 @@ generate_header(
template = "cmake/OpenEXRConfig.h.in",
)

generate_header(
name = "OpenEXRConfigInternal.h",
expand_template(
name = "OpenEXRConfigInternal",
out = "src/lib/OpenEXR/OpenEXRConfigInternal.h",
substitutions = {
"#cmakedefine OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1": "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1",
"#cmakedefine OPENEXR_IMF_HAVE_DARWIN 1": "/* #undef OPENEXR_IMF_HAVE_DARWIN */",
Expand All @@ -82,6 +87,8 @@ cc_library(
hdrs = [
"src/lib/Iex/Iex.h",
"src/lib/Iex/IexBaseExc.h",
"src/lib/Iex/IexConfig.h",
"src/lib/Iex/IexConfigInternal.h",
"src/lib/Iex/IexErrnoExc.h",
"src/lib/Iex/IexExport.h",
"src/lib/Iex/IexForward.h",
Expand All @@ -92,16 +99,15 @@ cc_library(
"src/lib/Iex/IexMathIeeeExc.h",
"src/lib/Iex/IexNamespace.h",
"src/lib/Iex/IexThrowErrnoExc.h",
"src/lib/OpenEXR/OpenEXRConfig.h",
],
features = select({
":windows": ["windows_export_all_symbols"],
"//conditions:default": [],
}),
includes = ["src/lib/Iex"],
deps = [
":IexConfig.h",
":IexConfigInternal.h",
":OpenEXRConfig.h",
includes = [
"src/lib/Iex",
"src/lib/OpenEXR",
],
)

Expand All @@ -118,6 +124,7 @@ cc_library(
],
hdrs = [
"src/lib/IlmThread/IlmThread.h",
"src/lib/IlmThread/IlmThreadConfig.h",
"src/lib/IlmThread/IlmThreadExport.h",
"src/lib/IlmThread/IlmThreadForward.h",
"src/lib/IlmThread/IlmThreadMutex.h",
Expand All @@ -130,10 +137,7 @@ cc_library(
"//conditions:default": [],
}),
includes = ["src/lib/IlmThread"],
deps = [
":Iex",
":IlmThreadConfig.h",
],
deps = [":Iex"],
)

cc_library(
Expand Down Expand Up @@ -234,6 +238,9 @@ cc_library(
"src/lib/OpenEXR/dwaLookups.h",
],
hdrs = [
"src/lib/Iex/IexConfig.h",
"src/lib/Iex/IexConfigInternal.h",
"src/lib/IlmThread/IlmThreadConfig.h",
"src/lib/OpenEXR/ImfAcesFile.h",
"src/lib/OpenEXR/ImfArray.h",
"src/lib/OpenEXR/ImfAttribute.h",
Expand Down Expand Up @@ -346,6 +353,8 @@ cc_library(
"src/lib/OpenEXR/ImfXdr.h",
"src/lib/OpenEXR/ImfZip.h",
"src/lib/OpenEXR/ImfZipCompressor.h",
"src/lib/OpenEXR/OpenEXRConfig.h",
"src/lib/OpenEXR/OpenEXRConfigInternal.h",
],
copts = select({
":windows": [],
Expand All @@ -367,12 +376,7 @@ cc_library(
}),
visibility = ["//visibility:public"],
deps = [
":IexConfig.h",
":IexConfigInternal.h",
":IlmThread",
":IlmThreadConfig.h",
":OpenEXRConfig.h",
":OpenEXRConfigInternal.h",
"@Imath",
"@net_zlib_zlib//:zlib",
],
Expand Down
3 changes: 3 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ workspace(name = "openexr")
load("//:bazel/third_party/openexr_deps.bzl", "openexr_deps")

openexr_deps()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
7 changes: 4 additions & 3 deletions bazel/third_party/Imath.BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) Contributors to the OpenEXR Project.

load("@openexr//:bazel/third_party/generate_header.bzl", "generate_header")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")

generate_header(
name = "ImathConfig.h",
expand_template(
name = "ImathConfig",
out = "ImathConfig.h",
substitutions = {
"@IMATH_INTERNAL_NAMESPACE@": "Imath_3_1",
"@IMATH_LIB_VERSION@": "3.1.5",
Expand Down
29 changes: 0 additions & 29 deletions bazel/third_party/generate_header.bzl

This file was deleted.

12 changes: 11 additions & 1 deletion bazel/third_party/openexr_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

def openexr_deps():
"""Fetches dependencies (zlib and Imath) of OpenEXR."""
"""Fetches dependencies (zlib and Imath) of OpenEXR and Skylib for header generation."""

maybe(
http_archive,
Expand All @@ -33,3 +33,13 @@ def openexr_deps():
sha256 = "1e9c7c94797cf7b7e61908aed1f80a331088cc7d8873318f70376e4aed5f25fb",
urls = ["https://github.com/AcademySoftwareFoundation/Imath/archive/refs/tags/v3.1.5.tar.gz"],
)

maybe(
http_archive,
name = "bazel_skylib",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
],
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
)

0 comments on commit 08c9e76

Please sign in to comment.