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

[CI] Set up CI runners, fix build issues on different platforms #130

Merged
merged 1 commit into from
Nov 12, 2023
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
157 changes: 157 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CI

on:
push:
#branches: [ "master" ]
pull_request:
#branches: [ "master" ]

jobs:
aswf:
name: "VFX${{matrix.vfxyear}} ${{matrix.desc}}"
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.container }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

matrix:
include:
- desc: gcc11 # /C++17 boost1.8 exr3.1
nametag: linux-vfx2023
os: ubuntu-latest
container: aswf/ci-osl:2023-clang15
vfxyear: 2023
cxx_std: 17
- desc: clang15 # /C++17 boost1.8 exr3.1
nametag: linux-vfx2022-clang13
os: ubuntu-latest
container: aswf/ci-osl:2023-clang15
vfxyear: 2023
cc_compiler: clang
cxx_compiler: clang++
cxx_std: 17
env:
CXX: ${{matrix.cxx_compiler}}
CC: ${{matrix.cc_compiler}}
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
OPENEXR_VERSION: ${{matrix.openexr_ver}}
steps:
- uses: actions/checkout@v3

- name: Print
shell: bash
run: |
echo "CXX=${CXX}"
echo "matrix.cxx_compiler=${{matrix.cxx_compiler}}"
yum search ceres-solver

- name: Dependencies
shell: bash
run: |
build_scripts/install_aces_container.bash
sudo yum install -y eigen3-devel ceres-solver-devel LibRaw-devel

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B build -S .
# -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
# -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
# -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: sudo cmake --build build

- name: Test
working-directory: build
run: ctest --rerun-failed --output-on-failure

##################################

build:
runs-on: ${{ matrix.os }}
name: "${{matrix.os}} ${{matrix.c_compiler}}"

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

matrix:
os: [ubuntu-latest, macos-latest]
# os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
# - os: windows-latest
# c_compiler: cl
# cpp_compiler: cl
# install_deps: install_deps_windows
# toolchain_file: "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
# aces_container_dir: "C:/Program Files (x86)/AcesContainer"
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
install_deps: install_deps_linux
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
install_deps: install_deps_linux
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
install_deps: install_deps_mac
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: macos-latest
c_compiler: cl
- os: macos-latest
c_compiler: gcc

steps:
- uses: actions/checkout@v3

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Dependencies
shell: bash
run: |
build_scripts/install_aces_container.bash
build_scripts/${{ matrix.install_deps }}.bash


- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake
-B ${{ steps.strings.outputs.build-output-dir }}
-S ${{ github.workspace }}
-DCXX_STANDARD=C++14
# -DCMAKE_TOOLCHAIN_FILE="${{ matrix.toolchain_file }}"
# -DAcesContainer_DIR="${{ matrix.aces_container_dir }}"

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }} --rerun-failed --output-on-failure
142 changes: 24 additions & 118 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)
project( RAWTOACES )

set( RAWTOACES_MAJOR_VERSION 1 )
Expand All @@ -20,10 +20,6 @@ if (NOT CONFIGURED_ONCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${warnings}")
endif()

if ( UNIX AND NOT APPLE )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
endif()

## Make install directories overridable
set( INSTALL_LIB_DIR lib CACHE PATH "Install directory for libraries" )
set( INSTALL_BIN_DIR bin CACHE PATH "Install directory for executable binaries" )
Expand Down Expand Up @@ -66,116 +62,9 @@ else()
set( DO_SHARED STATIC )
endif()

# Find packages and set up global settings
if ( APPLE OR UNIX )
include( configure.cmake )
endif()

include(ExternalProject)
if ( NOT OpenEXR_FOUND )
set (openexr_EXTERNAL_BUILD "${CMAKE_CURRENT_BINARY_DIR}/lib/openexr")
set (ilmbase_EXTERNAL_BUILD "${CMAKE_CURRENT_BINARY_DIR}/lib/openexr/IlmBase")
set (ilmbase_EXTERNAL_MAKE_BUILD "${CMAKE_CURRENT_BINARY_DIR}/lib/openexr/IlmBase/build")

if (WIN32)
STRING(REGEX REPLACE "\\\\" "/" openexr_EXTERNAL_BUILD ${openexr_EXTERNAL_BUILD})
STRING(REGEX REPLACE "\\\\" "/" ilmbase_EXTERNAL_BUILD ${ilmbase_EXTERNAL_BUILD})
STRING(REGEX REPLACE "\\\\" "/" ilmbase_EXTERNAL_MAKE_BUILD ${ilmbase_EXTERNAL_MAKE_BUILD})
message (STATUS ${ilmbase_EXTERNAL_MAKE_BUILD})

ExternalProject_Add( project_ilmbase
GIT_REPOSITORY https://github.com/openexr/openexr.git
GIT_TAG "origin/master"

SOURCE_DIR ${openexr_EXTERNAL_BUILD}
CONFIGURE_COMMAND cd ${ilmbase_EXTERNAL_BUILD}
CMAKE_ARGS -DBuildShared=OFF -DBuildExamples=OFF -DCMAKE_INSTALL_PREFIX=${GLOBAL_OUTPUT_PATH}/project_ilmbase
BUILD_COMMAND cmake ${ilmbase_EXTERNAL_BUILD} -G "Visual Studio 14 2015"
# BUILD_COMMAND cmake ${ilmbase_EXTERNAL_BUILD}
)
set (IlmBase_LIBRARY_DIRS "${CMAKE_CURRENT_BINARY_DIR}/project_ilmbase-prefix/src/project_ilmbase-build/Half")
set (IlmBase_INCLUDE_DIRS "${ilmbase_EXTERNAL_BUILD}/IlmBase/Half")
else ()
ExternalProject_Add( project_ilmbase
GIT_REPOSITORY https://github.com/openexr/openexr.git
GIT_TAG "master"

SOURCE_DIR "${openexr_EXTERNAL_BUILD}"
CONFIGURE_COMMAND mkdir "${ilmbase_EXTERNAL_BUILD}/build" && cd "${ilmbase_EXTERNAL_BUILD}/build"
CMAKE_ARGS -DBuildShared=ON -DBuildExamples=OFF -DCMAKE_INSTALL_PREFIX=${GLOBAL_OUTPUT_PATH}/project_ilmbase
BUILD_COMMAND cmake "${ilmbase_EXTERNAL_BUILD}" && make -s "${ilmbase_EXTERNAL_BUILD}/build"
)

endif ()

set (IlmBase_FOUND TRUE)
endif()

if ( NOT AcesContainer_FOUND )
set (ACES_EXTERNAL_BUILD "${CMAKE_CURRENT_BINARY_DIR}/lib/aces_container")
if (WIN32)
STRING(REGEX REPLACE "\\\\" "/" ACES_EXTERNAL_BUILD ${ACES_EXTERNAL_BUILD})

ExternalProject_Add( project_aces_container
GIT_REPOSITORY https://github.com/ampas/aces_container.git
# GIT_TAG "origin/windowBuildSupport"

SOURCE_DIR ${ACES_EXTERNAL_BUILD}
CMAKE_ARGS -DBuildShared=OFF -DBuildExamples=OFF -DCMAKE_INSTALL_PREFIX=${GLOBAL_OUTPUT_PATH}/project_aces_container
CMAKE_GENERATOR "Visual Studio 14 2015"

)
set (AcesContainer_LIBRARY_DIRS "${CMAKE_CURRENT_BINARY_DIR}/project_aces_container-prefix/src/project_aces_container-build")
set (AcesContainer_INCLUDE_DIRS "${ACES_EXTERNAL_BUILD}")
else ()
ExternalProject_Add( project_aces_container
GIT_REPOSITORY https://github.com/ampas/aces_container.git
# GIT_TAG "windowBuildSupport"

SOURCE_DIR ${ACES_EXTERNAL_BUILD}
CONFIGURE_COMMAND mkdir ${ACES_EXTERNAL_BUILD}/build && cd ${ACES_EXTERNAL_BUILD}/build
CMAKE_ARGS -DBuildShared=ON -DBuildExamples=OFF -DCMAKE_INSTALL_PREFIX=${GLOBAL_OUTPUT_PATH}/project_aces_container
BUILD_COMMAND cmake "${ACES_EXTERNAL_BUILD}" && make -s "${ACES_EXTERNAL_BUILD}/build"
)

endif ()
set (AcesContainer_FOUND TRUE)
endif()

if ( NOT libraw_FOUND )
include(ExternalProject)
set (libraw_EXTERNAL_BUILD "${CMAKE_CURRENT_BINARY_DIR}/lib/libraw")

if (WIN32)
STRING(REGEX REPLACE "\\\\" "/" libraw_EXTERNAL_BUILD ${libraw_EXTERNAL_BUILD})
ExternalProject_Add( project_libraw
GIT_REPOSITORY https://github.com/LibRaw/LibRaw.git
GIT_TAG "origin/0.17-stable"

SOURCE_DIR "${libraw_EXTERNAL_BUILD}"
)
set (libraw_LIBRARY_DIRS "${CMAKE_CURRENT_BINARY_DIR}/project_libraw-prefix/src/project_libraw-build/lib/.libs")
set (libraw_INCLUDE_DIRS "${libraw_EXTERNAL_BUILD}")
else ()
ExternalProject_Add( project_libraw
GIT_REPOSITORY https://github.com/LibRaw/LibRaw.git
GIT_TAG "0.17-stable"

SOURCE_DIR "${libraw_EXTERNAL_BUILD}"
CONFIGURE_COMMAND cd "${libraw_EXTERNAL_BUILD}" && "${libraw_EXTERNAL_BUILD}/mkdist.sh"
BUILD_COMMAND "${libraw_EXTERNAL_BUILD}/configure" && make -s "${libraw_EXTERNAL_BUILD}"
)

endif()

set (libraw_FOUND TRUE)
include ( configure.cmake )

endif()

#if ( NOT Ceres_FOUND )
# set (Ceres_EXTERNAL_BUILD "${CMAKE_CURRENT_BINARY_DIR}/lib/ceres")
# set (Ceres_FOUND TRUE)
#endif()

# generated config files end up in binary dir so to find them, need
# to add to include path
Expand All @@ -185,8 +74,7 @@ add_definitions( -DPACKAGE="RAWTOACES" -DVERSION="${RAWTOACES_VERSION}" )
add_subdirectory("src/${RAWTOACESIDTLIB}")
add_subdirectory("src/${RAWTOACESLIB}")

enable_testing()
add_subdirectory(unittest)


# Create a RAWTOACESBuildTreeSettings.cmake file for the use from the build tree
file(RELATIVE_PATH CONF_REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}")
Expand Down Expand Up @@ -214,14 +102,32 @@ if ( APPLE OR UNIX )
endif()

### to build rawtoaces ###
link_directories( ${AcesContainer_LIBRARY_DIRS} )
include_directories( ${CERES_INCLUDE_DIRS} )

add_executable( rawtoaces
main.cpp
)

target_link_libraries(rawtoaces ${RAWTOACESLIB} ${libraw_LIBRARIES} ${libraw_LDFLAGS_OTHER} )
target_include_directories( rawtoaces
PUBLIC
${AcesContainer_INCLUDE_DIRS}
)

target_link_libraries ( rawtoaces
PUBLIC
${RAWTOACESLIB}
INTERFACE
Boost::headers
)

if ( LIBRAW_CONFIG_FOUND )
target_link_libraries ( rawtoaces PUBLIC libraw::raw )
else ()
target_link_directories(rawtoaces PUBLIC ${libraw_LIBRARY_DIRS} )
target_link_libraries(rawtoaces PUBLIC ${libraw_LIBRARIES} ${libraw_LDFLAGS_OTHER} )
endif ()

enable_testing()
add_subdirectory(unittest)

install( TARGETS rawtoaces DESTINATION bin )

Expand Down
17 changes: 17 additions & 0 deletions build_scripts/install_aces_container.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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 --config Release
sudo cmake --install aces_container/build
else
cmake -S aces_container -B aces_container/build
cmake --build aces_container/build --config Release
cmake --install aces_container/build --config Release
fi

cd ../..
13 changes: 13 additions & 0 deletions build_scripts/install_deps.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -ex

time sudo apt-get update

#time sudo apt-get -q -f install -y libunwind-dev

time sudo apt-get -q -f install -y \
libunwind-dev libilmbase-dev libopenexr-dev \
libboost-dev libboost-thread-dev libboost-filesystem-dev \
libboost-test-dev \
libraw-dev libceres-dev
11 changes: 11 additions & 0 deletions build_scripts/install_deps_linux.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -ex

time sudo apt-get update

time sudo apt-get -q -f install -y \
libunwind-dev libimath-dev \
libboost-dev libboost-filesystem-dev \
libboost-test-dev \
libraw-dev libceres-dev
5 changes: 5 additions & 0 deletions build_scripts/install_deps_mac.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -ex

brew install ceres-solver imath openexr libraw boost
Loading