Skip to content

Commit

Permalink
build: Add support for pip install OpenImageIO
Browse files Browse the repository at this point in the history
- Add build scripts for wheel dependencies.
- Fix OpenColorIO.
- Working wheel build.

Signed-off-by: Alex Clark <[email protected]>
  • Loading branch information
JeanChristopheMorinPerso authored and aclark4life committed Oct 13, 2023
1 parent b98d61d commit 8ff082f
Show file tree
Hide file tree
Showing 18 changed files with 371 additions and 53 deletions.
24 changes: 13 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ if (CMAKE_VERSION VERSION_LESS 3.21)
endif ()
endif ()

# If the user wants to use Conan to build dependencies, they will have done
# this prior to the cmake config:
# cd <build area>
# conan install <source area>
# and that will leave a conanbuildinfo.cmake in the build area for us.
if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include (${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
message (STATUS "Using Conan for dependencies")
conan_basic_setup()
endif()

if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif ()
Expand Down Expand Up @@ -144,6 +133,7 @@ message(STATUS "Setting Namespace to: ${PROJ_NAMESPACE_V}")
add_definitions (-DOIIO_INTERNAL=1)

list (APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/build"
"${PROJECT_SOURCE_DIR}/src/cmake/modules"
"${PROJECT_SOURCE_DIR}/src/cmake")

Expand All @@ -159,6 +149,18 @@ include (add_oiio_plugin)
# All the C++ and compiler related options and adjustments
include (compiler)

# If the user wants to use Conan to build dependencies, they will have done
# this prior to the cmake config:
# cd <build area>
# conan install <source area>
# and that will leave a conanbuildinfo.cmake in the build area for us.
if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include (${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
message (STATUS "Using Conan for dependencies")
conan_basic_setup()
endif()


# Utilities and options related to finding python and making python bindings
include (pythonutils)

Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Additionally, a few helpful modifiers alter some build-time options:
| make STOP_ON_WARNING=0 | Do not stop building if compiler warns |
| make EMBEDPLUGINS=0 ... | Don't compile the plugins into libOpenImageIO |
| make USE_OPENGL=0 ... | Skip anything that needs OpenGL |
| make USE_QT=0 ... | Skip anything that needs Qt |
| make USE_QT5=0 ... | Skip anything that needs Qt |
| make MYCC=xx MYCXX=yy ... | Use custom compilers |
| make USE_PYTHON=0 ... | Don't build the Python binding |
| make BUILD_SHARED_LIBS=0 | Build static library instead of shared |
Expand Down
38 changes: 24 additions & 14 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
[requires]
zlib/1.2.11
libtiff/4.0.9
boost/1.79.0
zlib/1.2.12
libtiff/4.3.0
libpng/1.6.37
openexr/2.4.0
boost/1.70.0
libjpeg/9c
libjpeg-turbo/2.0.2
giflib/5.1.4
freetype/2.10.0
#opencv/4.1.1@conan/stable
openjpeg/2.3.1
libwebp/1.0.3
tsl-robin-map/0.6.1@tessil/stable
giflib/5.2.1
freetype/2.12.1
#opencv/4.5.5
libjpeg/9d
openjpeg/2.5.0
libwebp/1.2.3
#tsl-robin-map/0.6.1@tessil/stable
tbb/2020.0
ffmpeg/5.0
libheif/1.12.0
lcms/2.13.1
libraw/0.20.2
ptex/2.4.0
yaml-cpp/0.6.3
pystring/1.1.3
expat/2.4.8
# To do:
# opencolorio? not on conan?
# pybind11/2.4.3 - conan doesn't have this minimum version
Expand All @@ -26,7 +32,11 @@ tbb/2020.0


[generators]
cmake
cmake_find_package

[options]
#libpng:shared=False
*:shared=False
*:fPIC=True
ffmpeg:with_vulkan=False
ffmpeg:with_asm=False
libx265:assembly=False
58 changes: 58 additions & 0 deletions src/build-scripts/build_libaom.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash

# Utility script to download and build libaom

# Exit the whole script if any command fails.
set -ex

# Repo and branch/tag/commit of LIBAOM to download if we don't have it yet
LIBAOM_REPO=${LIBAOM_REPO:=https://aomedia.googlesource.com/aom}
LIBAOM_VERSION=${LIBAOM_VERSION:=v3.4.0}

# Where to put libaom repo source (default to the ext area)
LIBAOM_SRC_DIR=${LIBAOM_SRC_DIR:=${PWD}/ext/libaom}
# Temp build area (default to a build/ subdir under source)
LIBAOM_BUILD_DIR=${LIBAOM_BUILD_DIR:=${LIBAOM_SRC_DIR}/build}
# Install area for libaom (default to ext/dist)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
LIBAOM_INSTALL_DIR=${LIBAOM_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
LIBAOM_BUILD_OPTS=${LIBAOM_BUILD_OPTS:=}

pwd
echo "libaom install dir will be: ${LIBAOM_INSTALL_DIR}"

mkdir -p ./ext
pushd ./ext

# Clone libaom project from GitHub and build
if [[ ! -e ${LIBAOM_SRC_DIR} ]] ; then
echo "git clone ${LIBAOM_REPO} ${LIBAOM_SRC_DIR}"
git clone ${LIBAOM_REPO} ${LIBAOM_SRC_DIR}
fi
cd ${LIBAOM_SRC_DIR}

echo "git checkout ${LIBAOM_VERSION} --force"
git checkout ${LIBAOM_VERSION} --force

mkdir -p ${LIBAOM_BUILD_DIR}
cd ${LIBAOM_BUILD_DIR}

if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${LIBAOM_INSTALL_DIR} \
-DENABLE_DOCS=0 \
-DAOM_TARGET_CPU=generic \
${LIBAOM_BUILD_OPTS} ..
time cmake --build . --config Release --target install
fi

# ls -R ${LIBAOM_INSTALL_DIR}
popd

#echo "listing .."
#ls ..

# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export LibAom_ROOT=$LIBAOM_INSTALL_DIR

63 changes: 63 additions & 0 deletions src/build-scripts/build_libde265.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

# Utility script to download and build libaom

# Exit the whole script if any command fails.
set -ex

# Repo and branch/tag/commit of LIBDE265 to download if we don't have it yet
LIBDE265_REPO=${LIBDE265_REPO:=https://github.com/strukturag/libde265.git}
LIBDE265_VERSION=${LIBDE265_VERSION:=v1.0.8}

# Where to put libaom repo source (default to the ext area)
LIBDE265_SRC_DIR=${LIBDE265_SRC_DIR:=${PWD}/ext/libde265}
# Temp build area (default to a build/ subdir under source)
LIBDE265_BUILD_DIR=${LIBDE265_BUILD_DIR:=${LIBDE265_SRC_DIR}/build}
# Install area for libaom (default to ext/dist)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
LIBDE265_INSTALL_DIR=${LIBDE265_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
LIBDE265_BUILD_OPTS=${LIBDE265_BUILD_OPTS:=}

pwd
echo "libaom install dir will be: ${LIBDE265_INSTALL_DIR}"

mkdir -p ./ext
pushd ./ext

# Clone libaom project from GitHub and build
if [[ ! -e ${LIBDE265_SRC_DIR} ]] ; then
echo "git clone ${LIBDE265_REPO} ${LIBDE265_SRC_DIR}"
git clone ${LIBDE265_REPO} ${LIBDE265_SRC_DIR}
fi
cd ${LIBDE265_SRC_DIR}

echo "git checkout ${LIBDE265_VERSION} --force"
git checkout ${LIBDE265_VERSION} --force

if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time ./autogen.sh

time ./configure --prefix=${LIBDE265_INSTALL_DIR} --disable-dec265 --disable-sherlock265
time make -j 16

# mkdir -p ${LIBDE265_BUILD_DIR}
# cd ${LIBDE265_BUILD_DIR}

# time cmake -DCMAKE_BUILD_TYPE=Release \
# -DCMAKE_INSTALL_PREFIX=${LIBDE265_INSTALL_DIR} \
# -DENABLE_SDL=OFF \
# ${LIBDE265_BUILD_OPTS} ..
# time
# time cmake --build . --config Release --target install
fi

# ls -R ${LIBDE265_INSTALL_DIR}
popd

#echo "listing .."
#ls ..

# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export LibDe265_ROOT=$LIBDE265_INSTALL_DIR

59 changes: 59 additions & 0 deletions src/build-scripts/build_libheif.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

# Utility script to download and build libaom

# Exit the whole script if any command fails.
set -ex

# Repo and branch/tag/commit of LIBHEIF to download if we don't have it yet
LIBHEIF_REPO=${LIBHEIF_REPO:=https://github.com/strukturag/libheif.git}
LIBHEIF_VERSION=${LIBHEIF_VERSION:=v1.12.0}

# Where to put libaom repo source (default to the ext area)
LIBHEIF_SRC_DIR=${LIBHEIF_SRC_DIR:=${PWD}/ext/libheif}
# Temp build area (default to a build/ subdir under source)
LIBHEIF_BUILD_DIR=${LIBHEIF_BUILD_DIR:=${LIBHEIF_SRC_DIR}/build}
# Install area for libaom (default to ext/dist)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
LIBHEIF_INSTALL_DIR=${LIBHEIF_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
LIBHEIF_BUILD_OPTS=${LIBHEIF_BUILD_OPTS:=}

pwd
echo "libaom install dir will be: ${LIBHEIF_INSTALL_DIR}"

mkdir -p ./ext
pushd ./ext

# Clone libaom project from GitHub and build
if [[ ! -e ${LIBHEIF_SRC_DIR} ]] ; then
echo "git clone ${LIBHEIF_REPO} ${LIBHEIF_SRC_DIR}"
git clone ${LIBHEIF_REPO} ${LIBHEIF_SRC_DIR}
fi
cd ${LIBHEIF_SRC_DIR}

echo "git checkout ${LIBHEIF_VERSION} --force"
git checkout ${LIBHEIF_VERSION} --force

mkdir -p ${LIBHEIF_BUILD_DIR}
cd ${LIBHEIF_BUILD_DIR}

if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${LIBHEIF_INSTALL_DIR} \
-DWITH_RAV1E=OFF \
-WITH_DAV1D=OFF \
-DCMAKE_FIND_LIBRARY_SUFFIXES=.a \
${LIBHEIF_BUILD_OPTS} ..
time cmake --build . --config Release --target install
fi

# ls -R ${LIBHEIF_INSTALL_DIR}
popd

#echo "listing .."
#ls ..

# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export Libheif_ROOT=$LIBHEIF_INSTALL_DIR

1 change: 1 addition & 0 deletions src/build-scripts/build_opencolorio.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ OPENCOLORIO_BUILDOPTS="-DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF \
-DOCIO_BUILD_GPU_TESTS=OFF \
-DOCIO_BUILD_PYTHON=OFF -DOCIO_BUILD_PYGLUE=OFF \
-DOCIO_BUILD_JAVA=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_SHARED_LIBS=${OPENCOLORIO_BUILD_SHARED_LIBS:=ON}"
BASEDIR=`pwd`
pwd
Expand Down
17 changes: 16 additions & 1 deletion src/build-scripts/ci-build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,22 @@ if [[ ${GITHUB_ACTIONS} == true ]] ; then
OIIO_CMAKE_FLAGS+=" -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:=ON} -DCMAKE_UNITY_BUILD_MODE=${CMAKE_UNITY_BUILD_MODE:=BATCH}"
fi

cmake -S . -B build -G "$CMAKE_GENERATOR" \
pushd build

if [[ $(conan profile list | grep default) == '' ]]; then
conan profile new default --detect
fi
conan profile update settings.compiler=gcc default
conan profile update settings.compiler.version=8 default
conan profile update settings.compiler.libcxx=libstdc++11 default
echo -e '[conf]\ntools.system.package_manager:mode=install' >> ~/.conan/profiles/default
if [[ "$USE_FFMPEG" == '1' ]]; then
CONAN_SYSREQUIRES_SUDO=0 CONAN_SYSREQUIRES_MODE=enabled conan install .. --build=openjpeg --build=libx264 --build=ffmpeg --build=libx265
else
CONAN_SYSREQUIRES_SUDO=0 CONAN_SYSREQUIRES_MODE=enabled conan install ..
fi

cmake .. -G "$CMAKE_GENERATOR" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DCMAKE_INSTALL_PREFIX="$OpenImageIO_ROOT" \
Expand Down
74 changes: 74 additions & 0 deletions src/build-scripts/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash

set -ex
apt update
# apt upgrade -y
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install sudo wget gzip software-properties-common -y

if [[ ! -d /opt/cmake ]]; then
currentPath=$(pwd)
wget https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-linux-x86_64.tar.gz
mkdir -p /opt/cmake
cd /opt
tar -xzf "${currentPath}/cmake-3.23.2-linux-x86_64.tar.gz"
rm "${currentPath}/cmake-3.23.2-linux-x86_64.tar.gz"
mv cmake-3.23.2-linux-x86_64/* cmake/
rm -rf cmake-3.23.2-linux-x86_64/
cd "${currentPath}"
fi

export PATH=/opt/cmake/bin:$PATH

export CXX=g++-8
export CC=gcc-8
export COMPILER=gcc-8
export CMAKE_CXX_STANDARD=17

export USE_OPENVDB=0
export USE_QT5=0
export USE_OPENGL=0
export USE_NUKE=0
export USE_R3DSDK=0
export USE_JPEGTURBO=0

export USE_FFMPEG=1
export USE_PNG=1
export USE_OPENCV=0
export USE_GIF=1
export USE_PTEX=1
export USE_WEBP=1
export USE_OPENCOLORIO=1
export USE_OPENEXR=1
export USE_LIBHEIF=1
export USE_TIFF=1
export USE_LIBRAW=1
export USE_OPENJPEG=1
export USE_FREETYPE=1

export OPENCOLORIO_VERSION=v2.1.2
export PUGIXML_VERSION=v1.11.4
export FMT_VERSION=9.0.0
export OPENEXR_VERSION=v3.1.5
export PYBIND11_VERSION=v2.9.2

export OPENCOLORIO_BUILD_SHARED_LIBS=OFF
export OPENEXR_CMAKE_FLAGS=-DBUILD_SHARED_LIBS=OFF
export PUGIXML_BUILD_OPTS=-DBUILD_SHARED_LIBS=OFF

export MY_CMAKE_FLAGS="${MY_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=OFF -DLINKSTATIC=ON -DOIIO_BUILD_TESTS=OFF -DOPENCOLORIO_NO_CONFIG=ON -DOIIO_BUILD_TOOLS=ON"
export PYTHON_VERSION=3.9

export OPENIMAGEIO_OPTIONS="openexr:core=1"

source src/build-scripts/ci-startup.bash

export CMAKE_BUILD_PARALLEL_LEVEL=16

unset TERM

apt install python3 python3-pip cmake pkg-config -y
python3 -m pip install conan

source src/build-scripts/gh-installdeps.bash

source src/build-scripts/ci-build.bash
Loading

0 comments on commit 8ff082f

Please sign in to comment.