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

Add modifications to support cross-platform builds #542

Merged
merged 3 commits into from
Dec 12, 2024
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ downloads/
archives/
*.orig
*.swp
venv*/
.venv/

# lib_check downloads these
*-stamp
arch_tmp/
arb*/
bzip2*/
cfitsio/
flex*/
freetype*/
giflib*/
harfbuzz*/
hdf5*/
jpeg*/
lcms2*/
Expand Down
8 changes: 8 additions & 0 deletions common_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ function fetch_unpack {
untar ../$out_archive && \
ls -1d * &&
rsync --delete -ah * ..)

# If a patch exists, apply it
if [ -e "${PATCH_DIR}/${archive_fname}.patch" ]; then
# The arch_tmp folder will contain the name of folder that was just
# unpacked from the archive. Apply the patch in that directory.
local package_dir=$(ls -1c arch_tmp)
patch --force -i "${PATCH_DIR}/${archive_fname}.patch" -d $package_dir
fi
}

function clean_code {
Expand Down
52 changes: 28 additions & 24 deletions library_builders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function build_simple {
local archive=${name_version}.${ext}
fetch_unpack $url/$archive
(cd $name_version \
&& ./configure --prefix=$BUILD_PREFIX $configure_args \
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS $configure_args \
&& make -j4 \
&& make install)
touch "${name}-stamp"
Expand All @@ -85,7 +85,7 @@ function build_github {
fi
local out_dir=$(fetch_unpack "https://github.com/${path}/archive/${tag_name}.tar.gz")
(cd $out_dir \
&& ./configure --prefix=$BUILD_PREFIX $configure_args \
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS $configure_args \
&& make -j4 \
&& make install)
touch "${name}-stamp"
Expand Down Expand Up @@ -156,7 +156,7 @@ function build_jpeg {
if [ -e jpeg-stamp ]; then return; fi
fetch_unpack http://ijg.org/files/jpegsrc.v${JPEG_VERSION}.tar.gz
(cd jpeg-${JPEG_VERSION} \
&& ./configure --prefix=$BUILD_PREFIX \
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS \
&& make -j4 \
&& make install)
touch jpeg-stamp
Expand All @@ -167,7 +167,9 @@ function build_libjpeg_turbo {
local cmake=$(get_modern_cmake)
fetch_unpack https://download.sourceforge.net/libjpeg-turbo/libjpeg-turbo-${JPEGTURBO_VERSION}.tar.gz
(cd libjpeg-turbo-${JPEGTURBO_VERSION} \
&& $cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \
&& $cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \
-DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib \
$HOST_CMAKE_FLAGS . \
&& make install)

# Prevent build_jpeg
Expand Down Expand Up @@ -197,21 +199,23 @@ function build_tiff {
}

function get_modern_cmake {
# Install cmake >= 2.8
# Install cmake >= 2.8 if it isn't installed
local cmake=cmake
if [ -n "$IS_MACOS" ]; then
brew install cmake > /dev/null
elif [ -n "$IS_ALPINE" ]; then
apk add cmake > /dev/null
elif [[ $MB_ML_VER == "_2_24" ]]; then
# debian:9 based distro
apt-get install -y cmake
else
if [ "`yum search cmake | grep ^cmake28\.`" ]; then
cmake=cmake28
if ! which $cmake > /dev/null; then
if [ -n "$IS_MACOS" ]; then
brew install cmake > /dev/null
elif [ -n "$IS_ALPINE" ]; then
apk add cmake > /dev/null
elif [[ $MB_ML_VER == "_2_24" ]]; then
# debian:9 based distro
apt-get install -y cmake
else
if [ "`yum search cmake | grep ^cmake28\.`" ]; then
cmake=cmake28
fi
# centos based distro
yum_install $cmake > /dev/null
fi
# centos based distro
yum_install $cmake > /dev/null
fi
echo $cmake
}
Expand All @@ -234,7 +238,7 @@ function build_openjpeg {
fi
local out_dir=$(fetch_unpack https://github.com/uclouvain/openjpeg/archive/${archive_prefix}${OPENJPEG_VERSION}.tar.gz)
(cd $out_dir \
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib $HOST_CMAKE_FLAGS . \
&& make install)
touch openjpeg-stamp
}
Expand Down Expand Up @@ -318,7 +322,7 @@ function build_hdf5 {
(cd hdf5-$HDF5_VERSION \
&& export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BUILD_PREFIX/lib \
&& ./configure --with-szlib=$BUILD_PREFIX --prefix=$BUILD_PREFIX \
--enable-threadsafe --enable-unsupported --with-pthread=yes \
--enable-threadsafe --enable-unsupported --with-pthread=yes $HOST_CONFIGURE_FLAGS \
&& make -j4 \
&& make install)
touch hdf5-stamp
Expand All @@ -331,7 +335,7 @@ function build_libaec {
# Note URL will change for each version
fetch_unpack https://gitlab.dkrz.de/k202009/libaec/uploads/ea0b7d197a950b0c110da8dfdecbb71f/${tar_name}
(cd $root_name \
&& ./configure --prefix=$BUILD_PREFIX \
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS \
&& make \
&& make install)
touch libaec-stamp
Expand All @@ -342,7 +346,7 @@ function build_blosc {
local cmake=$(get_modern_cmake)
fetch_unpack https://github.com/Blosc/c-blosc/archive/v${BLOSC_VERSION}.tar.gz
(cd c-blosc-${BLOSC_VERSION} \
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib $HOST_CMAKE_FLAGS . \
&& make install)
touch blosc-stamp
}
Expand All @@ -355,7 +359,7 @@ function build_lzo {
if [ -e lzo-stamp ]; then return; fi
fetch_unpack https://www.oberhumer.com/opensource/lzo/download/lzo-${LZO_VERSION}.tar.gz
(cd lzo-${LZO_VERSION} \
&& ./configure --prefix=$BUILD_PREFIX --enable-shared \
&& ./configure --prefix=$BUILD_PREFIX --enable-shared $HOST_CONFIGURE_FLAGS \
&& make \
&& make install)
touch lzo-stamp
Expand Down Expand Up @@ -415,7 +419,7 @@ function build_netcdf {
build_curl
fetch_unpack https://github.com/Unidata/netcdf-c/archive/v${NETCDF_VERSION}.tar.gz
(cd netcdf-c-${NETCDF_VERSION} \
&& ./configure --prefix=$BUILD_PREFIX --enable-dap \
&& ./configure --prefix=$BUILD_PREFIX --enable-dap $HOST_CONFIGURE_FLAGS \
&& make -j4 \
&& make install)
touch netcdf-stamp
Expand Down Expand Up @@ -538,7 +542,7 @@ function build_cfitsio {
local cfitsio_name_ver=cfitsio${CFITSIO_VERSION}
fetch_unpack https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/${cfitsio_name_ver}.tar.gz
(cd cfitsio \
&& ./configure --prefix=$BUILD_PREFIX \
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS \
&& make shared && make install)
fi
touch cfitsio-stamp
Expand Down
11 changes: 11 additions & 0 deletions tests/patches/harfbuzz-2.7.4.tar.xz.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is a completely cosmetic patch to validate that source patching works as expected.
#
diff -ur harfbuzz-2.7.4-orig/README harfbuzz-2.7.4/README
--- harfbuzz-2.7.4-orig/README 2024-12-12 09:23:15
+++ harfbuzz-2.7.4/README 2024-12-12 09:23:02
@@ -13,3 +13,5 @@
For test execution, see https://github.com/harfbuzz/harfbuzz/blob/master/TESTING.md

Documentation: https://harfbuzz.github.io
+
+Harfbuzz has been patched by multibuild
2 changes: 2 additions & 0 deletions tests/test_library_builders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ source tests/utils.sh

start_spinner

PATCH_DIR=$(pwd)/tests/patches
fetch_unpack https://github.com/harfbuzz/harfbuzz/releases/download/2.7.4/harfbuzz-2.7.4.tar.xz
[ -d harfbuzz-2.7.4 ] || ingest ".tar.xz should have been unpacked"
[ -n "$(grep 'Harfbuzz has been patched by multibuild' harfbuzz-2.7.4/README)" ] || ingest "Harfbuzz should have been patched"

suppress build_bzip2
suppress build_openssl
Expand Down
Loading