Skip to content

Commit 74a9795

Browse files
authored
Merge pull request #542 from freakboy3742/ios-devel
Add modifications to support cross-platform builds.
2 parents 2472c68 + 59f2449 commit 74a9795

File tree

5 files changed

+53
-24
lines changed

5 files changed

+53
-24
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ downloads/
22
archives/
33
*.orig
44
*.swp
5+
venv*/
6+
.venv/
57

68
# lib_check downloads these
79
*-stamp
10+
arch_tmp/
811
arb*/
912
bzip2*/
1013
cfitsio/
1114
flex*/
1215
freetype*/
1316
giflib*/
17+
harfbuzz*/
1418
hdf5*/
1519
jpeg*/
1620
lcms2*/

common_utils.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@ function fetch_unpack {
288288
untar ../$out_archive && \
289289
ls -1d * &&
290290
rsync --delete -ah * ..)
291+
292+
# If a patch exists, apply it
293+
if [ -e "${PATCH_DIR}/${archive_fname}.patch" ]; then
294+
# The arch_tmp folder will contain the name of folder that was just
295+
# unpacked from the archive. Apply the patch in that directory.
296+
local package_dir=$(ls -1c arch_tmp)
297+
patch --force -i "${PATCH_DIR}/${archive_fname}.patch" -d $package_dir
298+
fi
291299
}
292300

293301
function clean_code {

library_builders.sh

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function build_simple {
6868
local archive=${name_version}.${ext}
6969
fetch_unpack $url/$archive
7070
(cd $name_version \
71-
&& ./configure --prefix=$BUILD_PREFIX $configure_args \
71+
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS $configure_args \
7272
&& make -j4 \
7373
&& make install)
7474
touch "${name}-stamp"
@@ -85,7 +85,7 @@ function build_github {
8585
fi
8686
local out_dir=$(fetch_unpack "https://github.com/${path}/archive/${tag_name}.tar.gz")
8787
(cd $out_dir \
88-
&& ./configure --prefix=$BUILD_PREFIX $configure_args \
88+
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS $configure_args \
8989
&& make -j4 \
9090
&& make install)
9191
touch "${name}-stamp"
@@ -156,7 +156,7 @@ function build_jpeg {
156156
if [ -e jpeg-stamp ]; then return; fi
157157
fetch_unpack http://ijg.org/files/jpegsrc.v${JPEG_VERSION}.tar.gz
158158
(cd jpeg-${JPEG_VERSION} \
159-
&& ./configure --prefix=$BUILD_PREFIX \
159+
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS \
160160
&& make -j4 \
161161
&& make install)
162162
touch jpeg-stamp
@@ -167,7 +167,9 @@ function build_libjpeg_turbo {
167167
local cmake=$(get_modern_cmake)
168168
fetch_unpack https://download.sourceforge.net/libjpeg-turbo/libjpeg-turbo-${JPEGTURBO_VERSION}.tar.gz
169169
(cd libjpeg-turbo-${JPEGTURBO_VERSION} \
170-
&& $cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \
170+
&& $cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \
171+
-DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib \
172+
$HOST_CMAKE_FLAGS . \
171173
&& make install)
172174

173175
# Prevent build_jpeg
@@ -197,21 +199,23 @@ function build_tiff {
197199
}
198200

199201
function get_modern_cmake {
200-
# Install cmake >= 2.8
202+
# Install cmake >= 2.8 if it isn't installed
201203
local cmake=cmake
202-
if [ -n "$IS_MACOS" ]; then
203-
brew install cmake > /dev/null
204-
elif [ -n "$IS_ALPINE" ]; then
205-
apk add cmake > /dev/null
206-
elif [[ $MB_ML_VER == "_2_24" ]]; then
207-
# debian:9 based distro
208-
apt-get install -y cmake
209-
else
210-
if [ "`yum search cmake | grep ^cmake28\.`" ]; then
211-
cmake=cmake28
204+
if ! which $cmake > /dev/null; then
205+
if [ -n "$IS_MACOS" ]; then
206+
brew install cmake > /dev/null
207+
elif [ -n "$IS_ALPINE" ]; then
208+
apk add cmake > /dev/null
209+
elif [[ $MB_ML_VER == "_2_24" ]]; then
210+
# debian:9 based distro
211+
apt-get install -y cmake
212+
else
213+
if [ "`yum search cmake | grep ^cmake28\.`" ]; then
214+
cmake=cmake28
215+
fi
216+
# centos based distro
217+
yum_install $cmake > /dev/null
212218
fi
213-
# centos based distro
214-
yum_install $cmake > /dev/null
215219
fi
216220
echo $cmake
217221
}
@@ -234,7 +238,7 @@ function build_openjpeg {
234238
fi
235239
local out_dir=$(fetch_unpack https://github.com/uclouvain/openjpeg/archive/${archive_prefix}${OPENJPEG_VERSION}.tar.gz)
236240
(cd $out_dir \
237-
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \
241+
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib $HOST_CMAKE_FLAGS . \
238242
&& make install)
239243
touch openjpeg-stamp
240244
}
@@ -318,7 +322,7 @@ function build_hdf5 {
318322
(cd hdf5-$HDF5_VERSION \
319323
&& export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BUILD_PREFIX/lib \
320324
&& ./configure --with-szlib=$BUILD_PREFIX --prefix=$BUILD_PREFIX \
321-
--enable-threadsafe --enable-unsupported --with-pthread=yes \
325+
--enable-threadsafe --enable-unsupported --with-pthread=yes $HOST_CONFIGURE_FLAGS \
322326
&& make -j4 \
323327
&& make install)
324328
touch hdf5-stamp
@@ -331,7 +335,7 @@ function build_libaec {
331335
# Note URL will change for each version
332336
fetch_unpack https://gitlab.dkrz.de/k202009/libaec/uploads/ea0b7d197a950b0c110da8dfdecbb71f/${tar_name}
333337
(cd $root_name \
334-
&& ./configure --prefix=$BUILD_PREFIX \
338+
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS \
335339
&& make \
336340
&& make install)
337341
touch libaec-stamp
@@ -342,7 +346,7 @@ function build_blosc {
342346
local cmake=$(get_modern_cmake)
343347
fetch_unpack https://github.com/Blosc/c-blosc/archive/v${BLOSC_VERSION}.tar.gz
344348
(cd c-blosc-${BLOSC_VERSION} \
345-
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \
349+
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib $HOST_CMAKE_FLAGS . \
346350
&& make install)
347351
touch blosc-stamp
348352
}
@@ -355,7 +359,7 @@ function build_lzo {
355359
if [ -e lzo-stamp ]; then return; fi
356360
fetch_unpack https://www.oberhumer.com/opensource/lzo/download/lzo-${LZO_VERSION}.tar.gz
357361
(cd lzo-${LZO_VERSION} \
358-
&& ./configure --prefix=$BUILD_PREFIX --enable-shared \
362+
&& ./configure --prefix=$BUILD_PREFIX --enable-shared $HOST_CONFIGURE_FLAGS \
359363
&& make \
360364
&& make install)
361365
touch lzo-stamp
@@ -415,7 +419,7 @@ function build_netcdf {
415419
build_curl
416420
fetch_unpack https://github.com/Unidata/netcdf-c/archive/v${NETCDF_VERSION}.tar.gz
417421
(cd netcdf-c-${NETCDF_VERSION} \
418-
&& ./configure --prefix=$BUILD_PREFIX --enable-dap \
422+
&& ./configure --prefix=$BUILD_PREFIX --enable-dap $HOST_CONFIGURE_FLAGS \
419423
&& make -j4 \
420424
&& make install)
421425
touch netcdf-stamp
@@ -538,7 +542,7 @@ function build_cfitsio {
538542
local cfitsio_name_ver=cfitsio${CFITSIO_VERSION}
539543
fetch_unpack https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/${cfitsio_name_ver}.tar.gz
540544
(cd cfitsio \
541-
&& ./configure --prefix=$BUILD_PREFIX \
545+
&& ./configure --prefix=$BUILD_PREFIX $HOST_CONFIGURE_FLAGS \
542546
&& make shared && make install)
543547
fi
544548
touch cfitsio-stamp
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This is a completely cosmetic patch to validate that source patching works as expected.
2+
#
3+
diff -ur harfbuzz-2.7.4-orig/README harfbuzz-2.7.4/README
4+
--- harfbuzz-2.7.4-orig/README 2024-12-12 09:23:15
5+
+++ harfbuzz-2.7.4/README 2024-12-12 09:23:02
6+
@@ -13,3 +13,5 @@
7+
For test execution, see https://github.com/harfbuzz/harfbuzz/blob/master/TESTING.md
8+
9+
Documentation: https://harfbuzz.github.io
10+
+
11+
+Harfbuzz has been patched by multibuild

tests/test_library_builders.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ source tests/utils.sh
2121

2222
start_spinner
2323

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

2729
suppress build_bzip2
2830
suppress build_openssl

0 commit comments

Comments
 (0)