Skip to content

Commit

Permalink
Build and Nuke plugins revamp
Browse files Browse the repository at this point in the history
The whole build system is now using CMake
Additional work to build with Conan and Docker to provide a as-binary-compatible-as-possible-on-Linux plugin suite
Check the INSTALL notes on Linux to find out how to build with Docker

Big clean up of the Nuke plugins
The plugin generate hashes of the input metadata to reduce the whole depacking/decoding overhead as much as possible
The input patterns (names AND lpes) are also hashed to prevent rebuilding the automating all the time, and eventually
the active names/lpes are also hashed to cache the result of all regexes/lpes evaluation which can be long when
dealing with massive scenes. All multithread safe.
The downside is we've switched to c++11, which prevents us from compiling plugins for Nuke9 (since gcc4.1 and vs2010
won't compile this.) Porting back to old c++ is not really considered at this point.
  • Loading branch information
BenMercenaries committed Dec 1, 2019
1 parent 0be21ee commit 732912e
Show file tree
Hide file tree
Showing 54 changed files with 22,854 additions and 2,002 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
x64
Debug
debug
*.filters
*.sdf
.vs
*.opensdf
*.user
release
*.zip
*.tar.gz
*.tar.gz
95 changes: 91 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,93 @@
cmake_minimum_required (VERSION 2.6)
project (openexrid)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
PROJECT(openexrid)

SET(NDK_105_PATH /usr/local/Nuke10.5)
SET(NDK_112_PATH /usr/local/Nuke11.2)
SET(NDK_113_PATH /usr/local/Nuke11.3)
SET(NDK_120_PATH /usr/local/Nuke12.0)
SET(OFX_PATH /usr/local/openfx)

SET(OPENEXRID_ROOT "${CMAKE_CURRENT_LIST_DIR}")

INCLUDE(cmake/compile_definitions.cmake)
INCLUDE(cmake/output_folders.cmake)
INCLUDE(cmake/precompiled_headers.cmake)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")


IF(USE_CONAN)
# Note: All the conan stuff happens here
# Replace all this with more classic FIND_LIBRARY and such if you don't build with conan

IF(WIN32)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/Conan/conanbuildinfo_multi.cmake)
ELSEIF(UNIX)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/Conan/conanbuildinfo.cmake)
ENDIF(WIN32)
CONAN_BASIC_SETUP(TARGETS)

SET(LIBOPENEXRID_LIBS CONAN_PKG::IlmBase CONAN_PKG::OpenEXR CONAN_PKG::zlib)
SET(NUKE_PLUGIN_LIBS CONAN_PKG::OpenImageIO CONAN_PKG::re2 CONAN_PKG::IlmBase CONAN_PKG::OpenEXR CONAN_PKG::zlib)

# End of the conan stuff
ELSE()

# Not using conan?
# Well, then, let CMake find the packages ..
FIND_PACKAGE ( OpenEXR REQUIRED )
FIND_PACKAGE ( IlmBase REQUIRED )
FIND_PACKAGE ( ZLIB REQUIRED )
FIND_PACKAGE ( OpenImageIO REQUIRED )
FIND_PACKAGE ( re2 REQUIRED )

# ... And add them to the set of libs to build with
# These defs are used by the nuke plugins CMakeLists.txt and the openfx CMakeLists.txt
SET(LIBOPENEXRID_LIBS IlmBase OpenEXR zlib)
SET(NUKE_PLUGIN_LIBS OpenImageIO re2 IlmBase OpenEXR zlib)

ENDIF(USE_CONAN)


SET(CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug")
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)


#Use solution folders.
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)

# Compilation flags
IF(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /MP")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG /Zi")
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /Ob0")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
ADD_COMPILE_DEFINITIONS(OPENEXRID_CONFIG=$(Configuration))
ELSEIF(UNIX)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -MD -msse2 -fno-strict-aliasing -fno-omit-frame-pointer -Wno-deprecated")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG -ggdb")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -DNDEBUG -ggdb")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -D_DEBUG -ggdb")
ADD_COMPILE_DEFINITIONS(OPENEXRID_CONFIG=${CMAKE_BUILD_TYPE})
ADD_COMPILE_DEFINITIONS(_FILE_OFFSET_BITS=64)
ADD_COMPILE_DEFINITIONS(_LARGE_FILES)
SET(CMAKE_SKIP_RPATH TRUE)
ENDIF(WIN32)

# Third parties dependencies
#FIND_PACKAGE(OpenGL REQUIRED)

#####################
# Projects to compile

ADD_SUBDIRECTORY (openexrid)
ADD_SUBDIRECTORY (openfx)
ADD_SUBDIRECTORY (nuke10.5)
ADD_SUBDIRECTORY (nuke11.2)
ADD_SUBDIRECTORY (nuke11.3)
ADD_SUBDIRECTORY (nuke12.0)

add_subdirectory (openexrid)
52 changes: 43 additions & 9 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,51 @@
* Compilation under linux *
***************************

1) Install the following libraries :
OpenEXR 2.x
re2
OFX
Nuke9, 10 or 10.5
Compile with gcc 4.1.2 for the Nuke plug-in
Prerequisites:
--------------

- CMake 3.10
We provide a CMake solution to build the lib and plugins for Nuke and OFX.
You can work your way out of CMake, though ...

- gcc 4.8.2
Although you can use any c++11 capable compiler to build the OpenEXRId lib,
compiling the Nuke plugins might not be pratical.

- OpenEXR and IlmBase 2.2.0

- re2
We use the 2019-06-01 release, but we may have success with earlier versions

- OpenImageIO 1.6.18

- zlib 1.2.11


Building with CMake:
--------------------

From the openexrid root:

$ mkdir -p build/release
$ cd build/release
$ cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=gcc-4.8 -D CMAKE_CXX_COMPILER=g++-4.8 ../../
$ make


Alternatively:
--------------

Our build system is base on Conan and CMake inside Docker (to help generate as binary compatible binaries as possible.)

Once you have a Docker ready, just run ./linux-docker-build.sh, which:
- builds the docker image based on Centos6.6 (and also compiles gcc-4.8 and fetches all necessary dependencies)
- updates the dependencies using Conan
- and build all libs and plugins

2) Edit the makefile.conf file and set the correct location of those libraries
or define the different variables in the environment.
Note that we've fixed the path to the NDK in the linux-docker-build.sh file. Feel free to suit your own installation.

3) make install
The resulting files are located in build/release.

*****************************
* Compilation under Windows *
Expand Down
21 changes: 21 additions & 0 deletions build-conan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e

echo "Installing conan dependencies ..."
conan remote add pierousseau https://api.bintray.com/conan/pierousseau/libs
conan install --update --build=outdated --build=cascade -g cmake ./conanfile.py --install-folder ./Conan/ -s build_type=Release

CC_VER=`conan profile get env.CC default`
CXX_VER=`conan profile get env.CXX default`

mkdir -p build/release
cd build/release

# CMake generate all makefiles
echo "Building makefiles ..."
cmake -G "Unix Makefiles" -D USE_CONAN=1 -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=$CC_VER -D CMAKE_CXX_COMPILER=$CXX_VER ../../

# And make
echo "Make ..."
make -j`nproc` VERBOSE=1
5 changes: 5 additions & 0 deletions cmake/compile_definitions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
IF (CMAKE_VERSION VERSION_LESS 3.12)
MACRO(ADD_COMPILE_DEFINITIONS Def)
ADD_DEFINITIONS(-D${Def})
ENDMACRO(ADD_COMPILE_DEFINITIONS)
ENDIF()
4 changes: 4 additions & 0 deletions cmake/output_folders.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

MACRO(SET_VS_FOLDER folder)
SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY FOLDER ${folder})
ENDMACRO(SET_VS_FOLDER)
25 changes: 25 additions & 0 deletions cmake/precompiled_headers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
MACRO(ADD_MSVC_PRECOMPILED_HEADER_IN_FOLDER SourcesVar Folder)
IF(MSVC)
SET(PrecompiledBasename "stdafx")
SET(PrecompiledHeader "${PrecompiledBasename}.h")
SET(PrecompiledSource "${Folder}/${PrecompiledBasename}.cpp")
SET(PrecompiledBinary "$(IntDir)${PROJECT_NAME}.pch")
FOREACH(_source ${SourcesVar})
SET_SOURCE_FILES_PROPERTIES(${_source} PROPERTIES COMPILE_FLAGS "/Yu\"${PrecompiledHeader}\" /FI\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\"" OBJECT_DEPENDS "${PrecompiledBinary}")
ENDFOREACH()
SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource} PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\"" OBJECT_OUTPUTS "${PrecompiledBinary}")
ENDIF(MSVC)
ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER_IN_FOLDER)

MACRO(ADD_MSVC_PRECOMPILED_HEADER SourcesVar)
IF(MSVC)
SET(PrecompiledBasename "stdafx")
SET(PrecompiledHeader "${PrecompiledBasename}.h")
SET(PrecompiledSource "${CMAKE_CURRENT_LIST_DIR}/${PrecompiledBasename}.cpp")
SET(PrecompiledBinary "$(IntDir)${PROJECT_NAME}.pch")
FOREACH(_source ${SourcesVar})
SET_SOURCE_FILES_PROPERTIES(${_source} PROPERTIES COMPILE_FLAGS "/Yu\"${PrecompiledHeader}\" /FI\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\"" OBJECT_DEPENDS "${PrecompiledBinary}")
ENDFOREACH()
SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource} PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\"" OBJECT_OUTPUTS "${PrecompiledBinary}")
ENDIF(MSVC)
ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER)
28 changes: 28 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from conans import ConanFile, CMake
import os

#conan remote add conan-transit https://api.bintray.com/conan/conan/conan-transit
#conan remote add hulud https://api.bintray.com/conan/hulud/libs
#conan remote add pierousseau https://api.bintray.com/conan/pierousseau/libs

class OpenEXRIdConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
default_options = "*:shared=False"

def requirements(self):
# From our recipes :
self.requires("zlib/1.2.11@pierousseau/stable")
self.requires("IlmBase/2.2.0@pierousseau/stable")
self.requires("OpenEXR/2.2.0@pierousseau/stable")
self.requires("OpenImageIO/1.6.18@pierousseau/stable")
self.requires("re2/2019-06-01@pierousseau/stable")

def configure(self):
if self.settings.os == "Linux":
# fPIC option exists only on linux
self.options["boost"].fPIC=True
self.options["IlmBase"].fPIC=True
self.options["OpenEXR"].fPIC=True
self.options["OpenImageIO"].fPIC=True
self.options["re2"].fPIC=True
self.options["zlib"].fPIC=True
23 changes: 23 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM centos:6.6

# Initial bootstrapping
COPY bootstrap.sh /build/
RUN /build/bootstrap.sh

ENV CONAN_USER_HOME=/conan
COPY conan_profile_linux ${CONAN_USER_HOME}/.conan/profiles/default
COPY get-pip.py /build/
COPY extra-bootstrap.sh /build/
RUN /build/extra-bootstrap.sh

ENV CMAKE_ROOT=/usr/local/cmake-3.10.2
ENV CMAKE_MODULE_PATH=${CMAKE_ROOT}/share/cmake-3.10/Modules
ENV PATH=${CMAKE_ROOT}/bin:${PATH}
ENV PATH=/usr/local/patch-2.7.6/bin:${PATH}
ENV PATH=/usr/local/binutils-2.30/bin:${PATH}

COPY extra-bootstrap.2.sh /build/
RUN /build/extra-bootstrap.2.sh

COPY entrypoint.sh /build/
ENTRYPOINT [ "/build/entrypoint.sh" ]
67 changes: 67 additions & 0 deletions docker/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh
this_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

set -e

# load keys to avoid annoying messages
rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
# grant access to EPEL
yum -y install http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
# make sure we do not use https for EPEL since it is not correctly handled
sed -i 's/mirrorlist=https/mirrorlist=http/' /etc/yum.repos.d/epel.repo
# update trusted root certificates
yum -y update ca-certificates --disablerepo=epel
# install vim
yum -y install vim centos-release-scl kernel-headers
# install new glibc (this is the first release that works for every dependences)
#rpm -Uvh $sources_dir/glibc-2.17-55.el6.x86_64.rpm $sources_dir/glibc-common-2.17-55.el6.x86_64.rpm $sources_dir/glibc-devel-2.17-55.el6.x86_64.rpm $sources_dir/glibc-headers-2.17-55.el6.x86_64.rpm &&
# install any required tool from repositories
yum -y install cmake3 bison flex tar bzip2 file wget patch

yum -y install gcc-c++.x86_64
g++ --version

# Download gcc 4.1.2 and 4.8.2
mkdir -p /build
cd /build

wget ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/releases/gcc-4.1.2/gcc-4.1.2.tar.gz
tar zxf gcc-4.1.2.tar.gz

# build custom gcc-4.8.2
wget ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.gz
tar zxf gcc-4.8.2.tar.gz

wget ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/infrastructure/gmp-4.3.2.tar.bz2
tar jxf gmp-4.3.2.tar.bz2
mv gmp-4.3.2 gcc-4.8.2/gmp

wget ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/infrastructure/mpc-0.8.1.tar.gz
tar zxf mpc-0.8.1.tar.gz
mv mpc-0.8.1 gcc-4.8.2/mpc

wget ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/infrastructure/mpfr-2.4.2.tar.bz2
tar jxf mpfr-2.4.2.tar.bz2
mv mpfr-2.4.2 gcc-4.8.2/mpfr

export CC=gcc
export CXX=g++

# build custom gcc-4.8.2
mkdir -p /build/gcc-4.8.2-build
cd /build/gcc-4.8.2-build
../gcc-4.8.2/configure --prefix=/usr/local/gcc-4.8.2 --enable-languages=c,c++ --disable-multilib
make -j`nproc`
make install

# build custom gcc-4.1.2 (nuke9)
mkdir -p /build/gcc-4.1.2-build
cd /build/gcc-4.1.2-build
../gcc-4.1.2/configure --prefix=/usr/local/gcc-4.1.2 --enable-languages=c,c++ --disable-multilib
make -j`nproc`
make install

# clean up
cd /build
rm -rf gcc-4.8.2 gcc-4.1.2 gcc-4.8.2-build gcc-4.1.2-build
15 changes: 15 additions & 0 deletions docker/conan_profile_linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=4.8
compiler.libcxx=libstdc++11
compiler.cppstd=11
build_type=Release
[options]
[build_requires]
[env]
CC=gcc-4.8
CXX=g++-4.8
4 changes: 4 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh

cd /openexrid
scl enable rh-python35 "exec $@"
4 changes: 4 additions & 0 deletions docker/extra-bootstrap.2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
this_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

set -e
Loading

0 comments on commit 732912e

Please sign in to comment.