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

Update bazel build #1288

Merged
merged 5 commits into from
Oct 19, 2022
Merged
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
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.1
5.3.1
21 changes: 19 additions & 2 deletions .github/workflows/bazel_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: actions/cache@v2
with:
path: "/home/runner/.cache/bazel"
key: bazel
key: bazel-ubuntu

- name: Build
run: |
Expand All @@ -55,7 +55,24 @@ jobs:
uses: actions/cache@v2
with:
path: "/home/runner/.cache/bazel"
key: bazel
key: bazel-windows

- name: Build
run: |
bazelisk build //...

build_and_test_macos:
name: macOS 12 Bazel build <Apple Clang14>
runs-on: macos-12

steps:
- uses: actions/checkout@v3

- name: Mount Bazel cache
uses: actions/cache@v2
with:
path: "/home/runner/.cache/bazel"
key: bazel-macos

- name: Build
run: |
Expand Down
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
6 changes: 5 additions & 1 deletion WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
workspace(name = "openexr")
workspace(name = "com_openexr")

load("//:bazel/third_party/openexr_deps.bzl", "openexr_deps")

openexr_deps()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()
2 changes: 1 addition & 1 deletion bazel/example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <string>

// Function copied (with minior modifications) from pbrt-v3 (https://github.com/mmp/pbrt-v3) which is under BSD-2-Clause License
// Function copied (with minor modifications) from pbrt-v3 (https://github.com/mmp/pbrt-v3) which is under BSD-2-Clause License
static void
WriteImageEXR (
const std::string& name,
Expand Down
11 changes: 5 additions & 6 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 = "src/Imath/ImathConfig.h",
substitutions = {
"@IMATH_INTERNAL_NAMESPACE@": "Imath_3_1",
"@IMATH_LIB_VERSION@": "3.1.5",
Expand Down Expand Up @@ -38,6 +39,7 @@ cc_library(
"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",
Expand Down Expand Up @@ -71,7 +73,4 @@ cc_library(
],
includes = ["src/Imath"],
visibility = ["//visibility:public"],
deps = [
":ImathConfig.h",
],
)
29 changes: 0 additions & 29 deletions bazel/third_party/generate_header.bzl

This file was deleted.

24 changes: 17 additions & 7 deletions bazel/third_party/openexr_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ 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,
name = "net_zlib_zlib",
build_file = "@openexr//:bazel/third_party/zlib.BUILD",
sha256 = "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9",
strip_prefix = "zlib-1.2.12",
build_file = "@com_openexr//:bazel/third_party/zlib.BUILD",
sha256 = "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30",
strip_prefix = "zlib-1.2.13",
urls = [
"https://zlib.net/zlib-1.2.12.tar.gz",
"https://mirror.bazel.build/zlib.net/zlib-1.2.12.tar.gz",
"https://mirror.bazel.build/zlib.net/zlib-1.2.13.tar.gz",
"https://zlib.net/zlib-1.2.13.tar.gz",
],
)

Expand All @@ -28,8 +28,18 @@ def openexr_deps():
maybe(
http_archive,
name = "Imath",
build_file = "@openexr//:bazel/third_party/Imath.BUILD",
build_file = "@com_openexr//:bazel/third_party/Imath.BUILD",
strip_prefix = "Imath-3.1.5",
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",
)