diff --git a/.github/workflows/mac_release.yml b/.github/workflows/mac_release.yml index 8d05177b..865db163 100644 --- a/.github/workflows/mac_release.yml +++ b/.github/workflows/mac_release.yml @@ -28,6 +28,9 @@ jobs: - name: install openexr run: brew install openexr + - name: install aces_container + run: brew install aces_container + - uses: actions/checkout@v3 - name: Configure CMake @@ -203,6 +206,9 @@ jobs: - name: install openexr run: brew install openexr + - name: install aces_container + run: brew install aces_container + - uses: actions/checkout@v3 - name: Configure CMake diff --git a/.github/workflows/ubuntu_address_sanitizer.yml b/.github/workflows/ubuntu_address_sanitizer.yml index c1314e7a..14024c5b 100644 --- a/.github/workflows/ubuntu_address_sanitizer.yml +++ b/.github/workflows/ubuntu_address_sanitizer.yml @@ -99,6 +99,18 @@ jobs: - name: install libtiff run: sudo apt-get install libtiff-dev -y + - name: install aces_container + run: | + cd .. + git clone https://github.com/ampas/aces_container.git && + cmake -S aces_container -B aces_container/build -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing" && + cmake --build aces_container/build && + sudo cmake --install aces_container/build + + - name: install pkg-config to help find aces_container + run: | + sudo apt-get -y install pkg-config + - uses: actions/checkout@v3 - name: Configure CMake diff --git a/.github/workflows/ubuntu_debug.yml b/.github/workflows/ubuntu_debug.yml index 3bffc341..f769d006 100644 --- a/.github/workflows/ubuntu_debug.yml +++ b/.github/workflows/ubuntu_debug.yml @@ -69,6 +69,18 @@ jobs: make && sudo make install + - name: install aces_container + run: | + cd .. + git clone https://github.com/ampas/aces_container.git && + cmake -S aces_container -B aces_container/build -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing" && + cmake --build aces_container/build && + sudo cmake --install aces_container/build + + - name: install pkg-config to help find aces_container + run: | + sudo apt-get -y install pkg-config + - uses: actions/checkout@v3 - name: Configure CMake @@ -124,6 +136,18 @@ jobs: make && sudo make install + - name: install aces_container + run: | + cd .. + git clone https://github.com/ampas/aces_container.git && + cmake -S aces_container -B aces_container/build -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing" && + cmake --build aces_container/build && + sudo cmake --install aces_container/build + + - name: install pkg-config to help find aces_container + run: | + sudo apt-get -y install pkg-config + - uses: actions/checkout@v3 - name: Configure CMake @@ -171,6 +195,18 @@ jobs: make && sudo make install + - name: install aces_container + run: | + cd .. + git clone https://github.com/ampas/aces_container.git && + cmake -S aces_container -B aces_container/build -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing" && + cmake --build aces_container/build && + sudo cmake --install aces_container/build + + - name: install pkg-config to help find aces_container + run: | + sudo apt-get -y install pkg-config + - uses: actions/checkout@v3 - name: Configure CMake @@ -189,6 +225,11 @@ jobs: # Run valgrind using a bash script run: pwd && ls && bash ../resources/test/scripts/run_valgrind.sh + - name: Run Valgrind on aces container unit tests + working-directory: ${{github.workspace}}/build + # Run valgrind using a bash script + run: pwd && ls && bash ../resources/test/scripts/run_valgrind_aces_container.sh + valgrind-openexr3: # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. # You can convert this to a matrix build if you need cross-platform coverage. @@ -233,6 +274,18 @@ jobs: make && sudo make install + - name: install aces_container + run: | + cd .. + git clone https://github.com/ampas/aces_container.git && + cmake -S aces_container -B aces_container/build -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing" && + cmake --build aces_container/build && + sudo cmake --install aces_container/build + + - name: install pkg-config to help find aces_container + run: | + sudo apt-get -y install pkg-config + - uses: actions/checkout@v3 - name: Configure CMake @@ -246,13 +299,14 @@ jobs: cd ${{ github.workspace }} cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - #- name: Make unit tests - # working-directory: ${{github.workspace}}/build - # run: make check - - name: Run Valgrind on unit tests working-directory: ${{github.workspace}}/build # Run valgrind using a bash script run: pwd && ls && bash ../resources/test/scripts/run_valgrind.sh + - name: Run Valgrind on aces container unit tests + working-directory: ${{github.workspace}}/build + # Run valgrind using a bash script + run: pwd && ls && bash ../resources/test/scripts/run_valgrind_aces_container.sh + diff --git a/cmake/modules/FindAcesContainer.cmake b/cmake/modules/FindAcesContainer.cmake new file mode 100644 index 00000000..3a39b395 --- /dev/null +++ b/cmake/modules/FindAcesContainer.cmake @@ -0,0 +1,139 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindAcesContainer +------- + +Finds the AcesContainer library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``AcesContainer::AcesContainer`` + The AcesContainer library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``AcesContainer_FOUND`` + True if the system has the AcesContainer library. +``AcesContainer_VERSION`` + The version of the AcesContainer library which was found. +``AcesContainer_INCLUDE_DIRS`` + Include directories needed to use AcesContainer. +``AcesContainer_LIBRARIES`` + Libraries needed to link to AcesContainer. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``AcesContainer_INCLUDE_DIR`` + The directory containing ``AcesContainer.h``. +``AcesContainer_LIBRARY`` + The path to the AcesContainer library. + +#]=======================================================================] + +cmake_minimum_required(VERSION 3.12) +include(GNUInstallDirs) + +message(STATUS "running FindAcesContainer.cmake") + +# https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#find-modules + +find_package(PkgConfig) +pkg_check_modules(PC_AcesContainer QUIET AcesContainer) + +find_path(AcesContainer_INCLUDE_DIR + NAMES aces_Writer.h + #PATHS ${PC_AcesContainer_INCLUDE_DIRS} + PATHS /usr/local/include/ + PATH_SUFFIXES aces +) +find_library(AcesContainer_LIBRARY + NAMES AcesContainer + #PATHS ${PC_AcesContainer_LIBRARY_DIRS} + PATHS /usr/local/lib/ +) + +find_library(AcesContainer_LIBRARY_RELEASE + NAMES AcesContainer + PATHS ${PC_AcesContainer_LIBRARY_DIRS}/Release +) +find_library(AcesContainer_LIBRARY_DEBUG + NAMES AcesContainer + PATHS ${PC_AcesContainer_LIBRARY_DIRS}/Debug +) + +include(SelectLibraryConfigurations) +select_library_configurations(AcesContainer) + +set(AcesContainer_VERSION ${PC_AcesContainer_VERSION}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(AcesContainer + FOUND_VAR AcesContainer_FOUND + REQUIRED_VARS + AcesContainer_LIBRARY + AcesContainer_INCLUDE_DIR + VERSION_VAR AcesContainer_VERSION +) + +if(AcesContainer_FOUND) + set(AcesContainer_LIBRARIES ${AcesContainer_LIBRARY}) + set(AcesContainer_INCLUDE_DIRS ${AcesContainer_INCLUDE_DIR}) + set(AcesContainer_DEFINITIONS ${PC_AcesContainer_CFLAGS_OTHER}) +endif() + +if(AcesContainer_FOUND AND NOT TARGET AcesContainer::AcesContainer) + add_library(AcesContainer::AcesContainer UNKNOWN IMPORTED) + set_target_properties(AcesContainer::AcesContainer PROPERTIES + IMPORTED_LOCATION "${AcesContainer_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_AcesContainer_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${AcesContainer_INCLUDE_DIR}" + ) +endif() + +if(AcesContainer_FOUND) + if (NOT TARGET AcesContainer::AcesContainer) + add_library(AcesContainer::AcesContainer UNKNOWN IMPORTED) + endif() + if (AcesContainer_LIBRARY_RELEASE) + set_property(TARGET AcesContainer::AcesContainer APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE + ) + set_target_properties(AcesContainer::AcesContainer PROPERTIES + IMPORTED_LOCATION_RELEASE "${AcesContainer_LIBRARY_RELEASE}" + ) + endif() + if (AcesContainer_LIBRARY_DEBUG) + set_property(TARGET AcesContainer::AcesContainer APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG + ) + set_target_properties(AcesContainer::AcesContainer PROPERTIES + IMPORTED_LOCATION_DEBUG "${AcesContainer_LIBRARY_DEBUG}" + ) + endif() + set_target_properties(AcesContainer::AcesContainer PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_AcesContainer_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${AcesContainer_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced( + AcesContainer_INCLUDE_DIR + AcesContainer_LIBRARY +) + +# compatibility variables +set(AcesContainer_VERSION_STRING ${AcesContainer_VERSION}) + + + diff --git a/ctlrender/CMakeLists.txt b/ctlrender/CMakeLists.txt index 31a2e13c..f1878a51 100644 --- a/ctlrender/CMakeLists.txt +++ b/ctlrender/CMakeLists.txt @@ -51,7 +51,26 @@ else() endif() find_package(AcesContainer) +if( AcesContainer_FOUND ) + message( STATUS "find_package(AcesContainer) - AcesContainer_FOUND is true") +else() + message( STATUS "find_package(AcesContainer) - AcesContainer_FOUND is false") +endif() + if (TARGET AcesContainer::AcesContainer) + message( STATUS "find_package(AcesContainer) - TARGET AcesContainer::AcesContainer is true:" ) +else() + message( STATUS "find_package(AcesContainer) - TARGET AcesContainer::AcesContainer is false") +endif() + +if( AcesContainer_FOUND OR TARGET AcesContainer::AcesContainer) + + message( STATUS " AcesContainer_VERSION : ${AcesContainer_VERSION}" ) + message( STATUS " AcesContainer_INCLUDE_DIRS : ${AcesContainer_INCLUDE_DIRS}" ) + message( STATUS " AcesContainer_LIBRARIES : ${AcesContainer_LIBRARIES}" ) + message( STATUS " AcesContainer_INCLUDE_DIR : ${AcesContainer_INCLUDE_DIR}" ) + message( STATUS " AcesContainer_LIBRARY : ${AcesContainer_LIBRARY}" ) + target_compile_definitions(ctlrender PRIVATE -DHAVE_ACESFILE=1 @@ -60,6 +79,11 @@ if (TARGET AcesContainer::AcesContainer) PRIVATE AcesContainer::AcesContainer ) + message( STATUS "AcesContainer found") + message( STATUS " ctlrender will support writing AcesContainer files" ) +else() + message( STATUS "AcesContainer not found - TARGET AcesContainer::AcesContainer is false and AcesContainer_FOUND is false") + message( STATUS " ctlrender will not support writing AcesContainer files" ) endif() install(TARGETS ctlrender DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/docker/Dockerfile_ubuntu_22.04_acescontainer b/docker/Dockerfile_ubuntu_22.04_acescontainer new file mode 100644 index 00000000..27249152 --- /dev/null +++ b/docker/Dockerfile_ubuntu_22.04_acescontainer @@ -0,0 +1,55 @@ +FROM ubuntu:22.04 + +RUN apt-get update + +# disable interactive install +ENV DEBIAN_FRONTEND noninteractive + +# install developement tools +RUN apt-get -y install cmake +RUN apt-get -y install g++ +RUN apt-get -y install git + +RUN apt-get -y install valgrind + +# install CTL dependencies +RUN apt-get -y install libopenexr-dev +RUN apt-get -y install libtiff-dev + +# install aces_container +WORKDIR /usr/src/ +RUN git clone https://github.com/ampas/aces_container.git +#WORKDIR /usr/src/aces_container/build +#RUN cmake .. +#RUN make +#RUN make install +RUN cmake -S aces_container -B aces_container/build -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing" +RUN cmake --build aces_container/build +RUN cmake --install aces_container/build + +RUN apt-get -y install pkg-config + +# Make sudo dummy replacement, so we don't weaken docker security +#RUN echo "#!/bin/bash\n\$@" > /usr/bin/sudo +#RUN chmod +x /usr/bin/sudo + +# copy CTL repo into docker +WORKDIR /usr/src/CTL +COPY . . + +# install ACES AcesContainer using install script +#WORKDIR /usr/src/ +#RUN bash ./CTL/resources/scripts/install_aces_container.bash + +# build CTL +WORKDIR /usr/src/CTL/build +#RUN cmake -D CMAKE_PREFIX_PATH=/usr/local/lib/CMake/AcesContainer .. +RUN cmake .. +RUN make +RUN make install + + + +# finalize docker environment +WORKDIR /usr/src/CTL + diff --git a/resources/scripts/install_aces_container.bash b/resources/scripts/install_aces_container.bash new file mode 100644 index 00000000..69e6e050 --- /dev/null +++ b/resources/scripts/install_aces_container.bash @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -ex + +git clone https://github.com/ampas/aces_container.git aces_container + +if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then + cmake \ + -S aces_container \ + -B aces_container/build \ + -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing" + cmake --build aces_container/build + sudo cmake --install aces_container/build +else + cmake \ + -S aces_container \ + -B aces_container/build \ + -DCMAKE_INSTALL_PREFIX="." \ + -DBUILD_SHARED_LIBS=OFF + cmake --build aces_container/build --config Release + cmake --install aces_container/build --config Release +fi + +cd ../.. diff --git a/resources/test/scripts/run_valgrind_aces_container.sh b/resources/test/scripts/run_valgrind_aces_container.sh new file mode 100644 index 00000000..79831841 --- /dev/null +++ b/resources/test/scripts/run_valgrind_aces_container.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -x +set -u + +# get initial path before changing it +SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +cd ./unittest/ctlrender + +valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ../../ctlrender/ctlrender -force -format aces -ctl ../../../unittest/ctlrender/unity.ctl ../../../unittest/ctlrender/colorbars_nuke_rgb_exr16.exr out.aces +test_18b_status=$? +test_18b_label="ctlrender-rgb-exr16-to-aces" + +# go back to initial path +cd $SCRIPTPATH + +# return valgrind exit codes +if [ $test_18b_status -eq 0 ] +then + echo "Success: valgrind detected no errors" + exit 0 +else + echo "Failure: valgrind detected errors" + + if [ $test_18b_status -ne 0 ] + then + echo "$test_18b_label: valgrind detected errors" + fi + + exit 1 +fi diff --git a/unittest/ctlrender/CMakeLists.txt b/unittest/ctlrender/CMakeLists.txt index e16000ff..1c05f708 100644 --- a/unittest/ctlrender/CMakeLists.txt +++ b/unittest/ctlrender/CMakeLists.txt @@ -14,6 +14,12 @@ elseif( NOT TARGET TIFF::TIFF AND NOT OpenEXR_FOUND ) message(WARNING "LibTIFF not found, OpenEXR not found, not including TIF or EXR files in ctlrender unit tests") endif() +find_package(AcesContainer) +if( AcesContainer_FOUND ) + message( STATUS "DEBUG: find_package(AcesContainer) AcesContainer_FOUND is true") + message( STATUS "DEBUG: including ACES ctlrender unit tests") +endif() + set(CTLRENDER_OUTPUT_FOLDER "${CMAKE_BINARY_DIR}/unittest/ctlrender/output") message("ctlrender test output folder will be created at: ${CTLRENDER_OUTPUT_FOLDER}") add_custom_target(ctlrender-build-time-make-directory ALL @@ -66,6 +72,11 @@ if(OpenEXR_FOUND) add_test(NAME "ctlrender-EXR_RGBA32->EXR_RGBA_32" COMMAND ${CTLRENDER_PATH} -ctl "${TEST_FILES}/unity_with_alpha.ctl" -format exr32 -force "${TEST_FILES}/colorbars_nuke_rgba_exr32.exr" "${CTLRENDER_OUTPUT_FOLDER}/bars_rgba_exr32_to_exr32.exr") endif() +#ACES tests +if (OpenEXR_FOUND AND AcesContainer_FOUND) + add_test(NAME "ctlrender-EXR16->ACES" COMMAND ${CTLRENDER_PATH} -ctl "${TEST_FILES}/unity.ctl" -format aces -force "${TEST_FILES}/colorbars_nuke_rgb_exr16.exr" "${CTLRENDER_OUTPUT_FOLDER}/bars_rgb_exr16_to_aces.aces") +endif() + # test TIFF32 to EXR and EXR to TIFF32 support if (OpenEXR_FOUND AND TARGET TIFF::TIFF) foreach(J exr exr16 exr32 tiff32)