From 194a629fd0c72e496fb124cc6b5f552ca6e9c3f3 Mon Sep 17 00:00:00 2001 From: Vertexwahn Date: Mon, 14 Aug 2023 00:36:23 +0200 Subject: [PATCH] Bazel support: Remove Bazel specific example and use same examples as CMake build Signed-off-by: Vertexwahn --- .github/workflows/bazel_build.yml | 13 ++++--- bazel/example/BUILD.bazel | 8 ---- bazel/example/main.cpp | 61 ------------------------------- src/examples/BUILD.bazel | 28 ++++++++++++++ 4 files changed, 36 insertions(+), 74 deletions(-) delete mode 100644 bazel/example/BUILD.bazel delete mode 100644 bazel/example/main.cpp create mode 100644 src/examples/BUILD.bazel diff --git a/.github/workflows/bazel_build.yml b/.github/workflows/bazel_build.yml index 2df83e0a25..2627e61aee 100644 --- a/.github/workflows/bazel_build.yml +++ b/.github/workflows/bazel_build.yml @@ -31,8 +31,8 @@ permissions: jobs: build_and_test_ubuntu: - name: Linux Ubuntu 20.04 Bazel build - runs-on: ubuntu-20.04 + name: Linux Ubuntu 22.04 Bazel build + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 @@ -41,11 +41,12 @@ jobs: uses: actions/cache@v3 with: path: "/home/runner/.cache/bazel" - key: bazel-ubuntu + key: bazel-ubuntu-22 - name: Build run: | bazelisk build //... + bazelisk test //... build_and_test_windows: name: Windows Server 2022 build @@ -58,11 +59,12 @@ jobs: uses: actions/cache@v3 with: path: "/home/runner/.cache/bazel" - key: bazel-windows + key: bazel-windows-2022 - name: Build run: | bazelisk build //... + bazelisk test //... build_and_test_macos: name: macOS 13 Bazel build @@ -75,8 +77,9 @@ jobs: uses: actions/cache@v3 with: path: "/home/runner/.cache/bazel" - key: bazel-macos + key: bazel-macos-13 - name: Build run: | bazelisk build //... + bazelisk test //... diff --git a/bazel/example/BUILD.bazel b/bazel/example/BUILD.bazel deleted file mode 100644 index 9e6c49ce55..0000000000 --- a/bazel/example/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) Contributors to the OpenEXR Project. - -cc_binary( - name = "Demo", - srcs = ["main.cpp"], - deps = ["//:OpenEXR"], -) diff --git a/bazel/example/main.cpp b/bazel/example/main.cpp deleted file mode 100644 index 3cd081cddc..0000000000 --- a/bazel/example/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include - -#include - -// 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]; - for (int i = 0; i < xRes * yRes; ++i) - 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"); - } - - 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; - } - - WriteImageEXR ("test.exr", data, 100, 100, 100, 100, 0, 0); - - return 0; -} \ No newline at end of file diff --git a/src/examples/BUILD.bazel b/src/examples/BUILD.bazel new file mode 100644 index 0000000000..4db5623735 --- /dev/null +++ b/src/examples/BUILD.bazel @@ -0,0 +1,28 @@ +cc_test( + name = "OpenEXRExamples", + srcs = [ + "deepExamples.cpp", + "deepExamples.h", + "deepTiledExamples.cpp", + "deepTiledExamples.h", + "drawImage.cpp", + "drawImage.h", + "generalInterfaceExamples.cpp", + "generalInterfaceExamples.h", + "generalInterfaceTiledExamples.cpp", + "generalInterfaceTiledExamples.h", + "lowLevelIoExamples.cpp", + "lowLevelIoExamples.h", + "main.cpp", + "multipartExamples.cpp", + "multipartExamples.h", + "namespaceAlias.h", + "previewImageExamples.cpp", + "previewImageExamples.h", + "rgbaInterfaceExamples.cpp", + "rgbaInterfaceExamples.h", + "rgbaInterfaceTiledExamples.cpp", + "rgbaInterfaceTiledExamples.h", + ], + deps = ["//:OpenEXR"], +)