Skip to content

Commit

Permalink
Stash Bazel build contributions for 3.1.7
Browse files Browse the repository at this point in the history
Signed-off-by: Vertexwahn <[email protected]>
  • Loading branch information
Vertexwahn authored and cary-ilm committed Mar 28, 2023
1 parent f374e6a commit e40fb05
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.0
6.0.0
47 changes: 37 additions & 10 deletions .github/workflows/bazel_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,53 @@ on:
- '**.md'

jobs:
build:
build_and_test_ubuntu:
name: Linux Ubuntu 20.04 Bazel build <GCC 9.3.0>
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

- name: Install bazelisk
- name: Build
run: |
bazelisk build //...
build_and_test_windows:
name: Windows Server 2022 build <Visual Studio 2022>
runs-on: windows-2022

steps:
- uses: actions/checkout@v3

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

- name: Build
run: |
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.11.0/bazelisk-linux-amd64"
mkdir -p "${GITHUB_WORKSPACE}/bin/"
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
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: |
"${GITHUB_WORKSPACE}/bin/bazel" build //...
bazelisk build //...
72 changes: 38 additions & 34 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# 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_0",
"@IEX_INTERNAL_NAMESPACE@": "Iex_3_1",
"@IEX_NAMESPACE_CUSTOM@": "0",
"@IEX_NAMESPACE@": "Iex",
},
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,10 +30,11 @@ 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_0",
"@ILMTHREAD_INTERNAL_NAMESPACE@": "IlmThread_3_1",
"@ILMTHREAD_NAMESPACE_CUSTOM@": "0",
"@ILMTHREAD_NAMESPACE@": "IlmThread",
"#cmakedefine01 ILMTHREAD_HAVE_POSIX_SEMAPHORES": "#define ILMTHREAD_HAVE_POSIX_SEMAPHORES 0",
Expand All @@ -40,27 +43,29 @@ 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_0",
"@OPENEXR_LIB_VERSION@": "3.0.4",
"@OPENEXR_NAMESPACE_CUSTOM@": "0",
"@OPENEXR_PACKAGE_NAME@": "OpenEXR 3.0.4",
"@OPENEXR_INTERNAL_IMF_NAMESPACE@": "Imf_3_1",
"@OPENEXR_LIB_VERSION@": "3.1.7",
"@OPENEXR_NAMESPACE_CUSTOM@": "3.1.7",
"@OPENEXR_PACKAGE_NAME@": "OpenEXR 3.1.7",
"@OPENEXR_VERSION_EXTRA@": "",
"@OPENEXR_VERSION_MAJOR@": "3",
"@OPENEXR_VERSION_MINOR@": "0",
"@OPENEXR_VERSION_PATCH@": "4",
"@OPENEXR_VERSION@": "3.0.4",
"@OPENEXR_VERSION_MINOR@": "1",
"@OPENEXR_VERSION_PATCH@": "7",
"@OPENEXR_VERSION@": "3.1.7",
"#cmakedefine OPENEXR_ENABLE_API_VISIBILITY": "#define OPENEXR_ENABLE_API_VISIBILITY",
"#cmakedefine OPENEXR_HAVE_LARGE_STACK 1": "/* #undef OPENEXR_HAVE_LARGE_STACK */",
},
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 @@ -83,6 +88,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 @@ -93,16 +100,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 @@ -119,6 +125,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 @@ -131,10 +138,7 @@ cc_library(
"//conditions:default": [],
}),
includes = ["src/lib/IlmThread"],
deps = [
":Iex",
":IlmThreadConfig.h",
],
deps = [":Iex"],
)

cc_library(
Expand Down Expand Up @@ -235,6 +239,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 @@ -347,6 +354,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 @@ -368,12 +377,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()
66 changes: 40 additions & 26 deletions bazel/example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,59 @@

#include <string>

// Function copied (with minior modifications) from pbrt-v3 (https://github.com/mmp/pbrt-v3) which is under BSD-2-Clause License
static void WriteImageEXR(const std::string &name, const float *pixels,
int xRes, int yRes, int totalXRes, int totalYRes,
int xOffset, int yOffset) {
// 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,
const float* pixels,
int xRes,
int yRes,
int totalXRes,
int totalYRes,
int xOffset,
int yOffset)
{
using namespace Imf;
using namespace Imath;

Rgba *hrgba = new Rgba[xRes * yRes];
Rgba* hrgba = new Rgba[xRes * yRes];
for (int i = 0; i < xRes * yRes; ++i)
hrgba[i] = Rgba(pixels[3 * i], pixels[3 * i + 1], pixels[3 * i + 2]);
hrgba[i] = Rgba (pixels[3 * i], pixels[3 * i + 1], pixels[3 * i + 2]);

// OpenEXR uses inclusive pixel bounds.
Box2i displayWindow(V2i(0, 0), V2i(totalXRes - 1, totalYRes - 1));
Box2i dataWindow(V2i(xOffset, yOffset),
V2i(xOffset + xRes - 1, yOffset + yRes - 1));

try {
RgbaOutputFile file(name.c_str(), displayWindow, dataWindow,
WRITE_RGB);
file.setFrameBuffer(hrgba - xOffset - yOffset * xRes, 1, xRes);
file.writePixels(yRes);
} catch (const std::exception &exc) {
throw std::runtime_error("Error writing");
Box2i displayWindow (V2i (0, 0), V2i (totalXRes - 1, totalYRes - 1));
Box2i dataWindow (
V2i (xOffset, yOffset), V2i (xOffset + xRes - 1, yOffset + yRes - 1));

try
{
RgbaOutputFile file (
name.c_str (), displayWindow, dataWindow, WRITE_RGB);
file.setFrameBuffer (hrgba - xOffset - yOffset * xRes, 1, xRes);
file.writePixels (yRes);
}
catch (const std::exception& exc)
{
throw std::runtime_error ("Error writing");
}

delete[] hrgba;
}

int main() {
float data [3*100*100];

for(int y = 0; y < 100; ++y)
for(int x = 0; x < 100; ++x) {
data[(y*100+x)*3+0] = 0.f;
data[(y*100+x)*3+1] = 1.f;
data[(y*100+x)*3+2] = 0.f;
int
main ()
{
float data[3 * 100 * 100];

for (int y = 0; y < 100; ++y)
for (int x = 0; x < 100; ++x)
{
data[(y * 100 + x) * 3 + 0] = 0.f;
data[(y * 100 + x) * 3 + 1] = 1.f;
data[(y * 100 + x) * 3 + 2] = 0.f;
}

WriteImageEXR("test.exr", data, 100, 100, 100, 100, 0, 0);
WriteImageEXR ("test.exr", data, 100, 100, 100, 100, 0, 0);

return 0;
}
19 changes: 9 additions & 10 deletions bazel/third_party/Imath.BUILD
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# 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.4",
"@IMATH_LIB_VERSION@": "3.1.7",
"@IMATH_NAMESPACE_CUSTOM@": "0",
"@IMATH_NAMESPACE@": "Imath",
"@IMATH_PACKAGE_NAME@": "Imath 3.1.4",
"@IMATH_PACKAGE_NAME@": "Imath 3.1.7",
"@IMATH_VERSION_MAJOR@": "3",
"@IMATH_VERSION_MINOR@": "1",
"@IMATH_VERSION_PATCH@": "4",
"@IMATH_VERSION@": "3.1.4",
"@IMATH_VERSION_PATCH@": "7",
"@IMATH_VERSION@": "3.1.7",
"#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 */",
Expand All @@ -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",
],
)
Loading

0 comments on commit e40fb05

Please sign in to comment.