mac builder refactor/improvements
Refactor the code in `tools/osx/builder` somewhat and make it cleaner. Move a few table processing loops into functions to make things less ugly. Delete dists not listed in the table (e.g. when they are updated) and when a dist is re-downloaded, delete the tree and the target file to force a rebuild. Use number version for gettext instead of `-latest`. Specify full dist target, e.g. `lib/libfoo.a` instead of just `libfoo.a`.
This commit is contained in:
parent
d7ff2afb80
commit
5e633984b8
|
@ -16,15 +16,15 @@ export PKG_CONFIG_PATH="$BUILD_ROOT/root/lib/pkgconfig"
|
||||||
export PATH="$BUILD_ROOT/root/bin:$PATH"
|
export PATH="$BUILD_ROOT/root/bin:$PATH"
|
||||||
|
|
||||||
DISTS='
|
DISTS='
|
||||||
gettext http://ftp.gnu.org/pub/gnu/gettext/gettext-latest.tar.xz libintl.a
|
gettext http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz lib/libintl.a
|
||||||
openssl https://www.openssl.org/source/openssl-1.0.2l.tar.gz libssl.a
|
openssl https://www.openssl.org/source/openssl-1.0.2l.tar.gz lib/libssl.a
|
||||||
libpng https://download.sourceforge.net/libpng/libpng-1.6.32.tar.xz libpng.a
|
libpng https://download.sourceforge.net/libpng/libpng-1.6.32.tar.xz lib/libpng.a
|
||||||
libjpeg-turbo https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.5.2.tar.gz libjpeg.a
|
libjpeg-turbo https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.5.2.tar.gz lib/libjpeg.a
|
||||||
libtiff http://dl.maptools.org/dl/libtiff/tiff-3.8.2.tar.gz libtiff.a
|
libtiff http://dl.maptools.org/dl/libtiff/tiff-3.8.2.tar.gz lib/libtiff.a
|
||||||
sdl2 https://www.libsdl.org/release/SDL2-2.0.6.tar.gz libSDL2.a
|
sdl2 https://www.libsdl.org/release/SDL2-2.0.6.tar.gz lib/libSDL2.a
|
||||||
sfml https://www.sfml-dev.org/files/SFML-2.4.2-sources.zip libsfml-system-s.a
|
sfml https://www.sfml-dev.org/files/SFML-2.4.2-sources.zip lib/libsfml-system-s.a
|
||||||
wxwidgets https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3/wxWidgets-3.0.3.tar.bz2 libwx_baseu-3.0.a
|
wxwidgets https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3/wxWidgets-3.0.3.tar.bz2 lib/libwx_baseu-3.0.a
|
||||||
ffmpeg http://ffmpeg.org/releases/ffmpeg-3.3.4.tar.xz libavformat.a
|
ffmpeg http://ffmpeg.org/releases/ffmpeg-3.3.4.tar.xz lib/libavformat.a
|
||||||
'
|
'
|
||||||
|
|
||||||
CONFIGURE_ARGS="--disable-shared --enable-static --prefix=$BUILD_ROOT/root"
|
CONFIGURE_ARGS="--disable-shared --enable-static --prefix=$BUILD_ROOT/root"
|
||||||
|
@ -41,6 +41,7 @@ DIST_ARGS="
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
setup
|
setup
|
||||||
|
delete_outdated_dists
|
||||||
download_dists
|
download_dists
|
||||||
build_dists
|
build_dists
|
||||||
build_project
|
build_project
|
||||||
|
@ -49,73 +50,82 @@ main() {
|
||||||
setup() {
|
setup() {
|
||||||
mkdir -p "$BUILD_ROOT"
|
mkdir -p "$BUILD_ROOT"
|
||||||
|
|
||||||
i=0
|
DIST_NAMES=$( table_column 0 3 "$DISTS")
|
||||||
DIST_NAMES=
|
DIST_URLS=$( table_column 1 3 "$DISTS")
|
||||||
for item in $DISTS; do
|
DIST_TARGETS=$(table_column 2 3 "$DISTS")
|
||||||
if [ $((i % 3)) -eq 0 ]; then
|
|
||||||
DIST_NAMES="$DIST_NAMES $item"
|
|
||||||
fi
|
|
||||||
i=$((i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
i=0
|
DISTS_NUM=$(table_rows "$DISTS")
|
||||||
DIST_TARGETS=
|
|
||||||
for item in $DISTS; do
|
|
||||||
if [ $((i % 3)) -eq 2 ]; then
|
|
||||||
DIST_TARGETS="$DIST_TARGETS $item"
|
|
||||||
fi
|
|
||||||
i=$((i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
NUM_CPUS=$(sysctl -n hw.ncpu)
|
NUM_CPUS=$(sysctl -n hw.ncpu)
|
||||||
|
|
||||||
CHECKOUT=$(find_checkout)
|
CHECKOUT=$(find_checkout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete_outdated_dists() {
|
||||||
|
files=
|
||||||
|
i=0
|
||||||
|
for dist in $DIST_NAMES; do
|
||||||
|
dist_url=$(list_get $i $DIST_URLS)
|
||||||
|
dist_file="$BUILD_ROOT/dists/${dist_url##*/}"
|
||||||
|
|
||||||
|
files="$files $dist_file"
|
||||||
|
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
for file in $BUILD_ROOT/dists/*; do
|
||||||
|
if ! list_contains "$file" $files; then
|
||||||
|
echo "\n[32mDeleting outdated dist: [1;34m$file[0m\n"
|
||||||
|
rm -f "$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
download_dists() {
|
download_dists() {
|
||||||
mkdir -p "$BUILD_ROOT/dists"
|
mkdir -p "$BUILD_ROOT/dists"
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
for item in $DISTS; do
|
while [ $i -lt $DISTS_NUM ]; do
|
||||||
if [ $((i % 3)) -eq 0 ]; then
|
dist_name=$(list_get $i $DIST_NAMES)
|
||||||
dist_name=$item
|
dist_url=$( list_get $i $DIST_URLS)
|
||||||
elif [ $((i % 3)) -eq 1 ]; then
|
dist_file="$BUILD_ROOT/dists/${dist_url##*/}"
|
||||||
dist_url=$item
|
|
||||||
dist_file="$BUILD_ROOT/dists/${dist_url##*/}"
|
|
||||||
|
|
||||||
cd "$BUILD_ROOT/dists"
|
cd "$BUILD_ROOT/dists"
|
||||||
if [ ! -e "$dist_file" ]; then
|
if [ ! -e "$dist_file" ]; then
|
||||||
echo "\n[32mFetching [1;35m$dist_name[0m: [1;34m$dist_url[0m\n"
|
echo "\n[32mFetching [1;35m$dist_name[0m: [1;34m$dist_url[0m\n"
|
||||||
curl -LO "$dist_url"
|
curl -LO "$dist_url"
|
||||||
fi
|
|
||||||
|
|
||||||
dist_dir="$BUILD_ROOT/libs/$dist_name"
|
# force rebuild for new dist file
|
||||||
|
rm -f "$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
|
||||||
|
rm -rf "$BUILD_ROOT/libs/$dist_name"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -d "$dist_dir" ]; then
|
dist_dir="$BUILD_ROOT/libs/$dist_name"
|
||||||
mkdir -p "$dist_dir"
|
|
||||||
|
|
||||||
tmp_dir="$BUILD_ROOT/libs/tmp"
|
if [ ! -d "$dist_dir" ]; then
|
||||||
mkdir -p "$tmp_dir"
|
mkdir -p "$dist_dir"
|
||||||
cd "$tmp_dir"
|
|
||||||
|
|
||||||
case "$dist_file" in
|
tmp_dir="$BUILD_ROOT/libs/tmp"
|
||||||
*.tar.gz)
|
mkdir -p "$tmp_dir"
|
||||||
tar zxf "$dist_file"
|
cd "$tmp_dir"
|
||||||
;;
|
|
||||||
*.tar.xz)
|
|
||||||
xzcat "$dist_file" | tar xf -
|
|
||||||
;;
|
|
||||||
*.tar.bz2)
|
|
||||||
bzcat "$dist_file" | tar xf -
|
|
||||||
;;
|
|
||||||
*.zip)
|
|
||||||
unzip -q "$dist_file"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
mv */* "$dist_dir"
|
case "$dist_file" in
|
||||||
rm -rf "$tmp_dir"
|
*.tar.gz)
|
||||||
fi
|
tar zxf "$dist_file"
|
||||||
|
;;
|
||||||
|
*.tar.xz)
|
||||||
|
xzcat "$dist_file" | tar xf -
|
||||||
|
;;
|
||||||
|
*.tar.bz2)
|
||||||
|
bzcat "$dist_file" | tar xf -
|
||||||
|
;;
|
||||||
|
*.zip)
|
||||||
|
unzip -q "$dist_file"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
mv */* "$dist_dir"
|
||||||
|
rm -rf "$tmp_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
|
@ -127,7 +137,7 @@ build_dists() {
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
for dist in $DIST_NAMES; do
|
for dist in $DIST_NAMES; do
|
||||||
target_lib="$BUILD_ROOT/root/lib/$(list_get $i $DIST_TARGETS)"
|
target_lib="$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
|
||||||
|
|
||||||
if [ ! -e "$target_lib" ]; then
|
if [ ! -e "$target_lib" ]; then
|
||||||
cd "$dist"
|
cd "$dist"
|
||||||
|
@ -137,7 +147,13 @@ build_dists() {
|
||||||
|
|
||||||
if [ ! -e configure ]; then
|
if [ ! -e configure ]; then
|
||||||
aclocal
|
aclocal
|
||||||
glibtoolize
|
|
||||||
|
if command -v glibtoolize >/dev/null; then
|
||||||
|
glibtoolize
|
||||||
|
else
|
||||||
|
libtoolize
|
||||||
|
fi
|
||||||
|
|
||||||
autoheader
|
autoheader
|
||||||
autoconf
|
autoconf
|
||||||
[ -e Makefile.am ] && automake --add-missing
|
[ -e Makefile.am ] && automake --add-missing
|
||||||
|
@ -273,4 +289,55 @@ build_project() {
|
||||||
echo "\n[32mBuild Successful!!![0m\n\nBuild results can be found in: [1;34m$BUILD_ROOT/project[0m\n"
|
echo "\n[32mBuild Successful!!![0m\n\nBuild results can be found in: [1;34m$BUILD_ROOT/project[0m\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table_column() {
|
||||||
|
col=$1
|
||||||
|
[ -n "$col" ] || error 'table_column: column required'
|
||||||
|
row_size=$2
|
||||||
|
[ -n "$row_size" ] || error 'table_column: row_size required'
|
||||||
|
table=$3
|
||||||
|
[ -n "$table" ] || error 'table_column: table required'
|
||||||
|
|
||||||
|
i=0
|
||||||
|
res=
|
||||||
|
for item in $table; do
|
||||||
|
if [ $((i % row_size)) -eq "$col" ]; then
|
||||||
|
res="$res $item"
|
||||||
|
fi
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $res
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
table_rows() {
|
||||||
|
table=$1
|
||||||
|
[ -n "$table" ] || error 'table_rows: table required'
|
||||||
|
|
||||||
|
i=0
|
||||||
|
OLDIFS=$IFS
|
||||||
|
IFS='
|
||||||
|
'; for line in $table; do
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
IFS=$OLDIFS
|
||||||
|
|
||||||
|
echo $i
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
list_contains() {
|
||||||
|
_item=$1
|
||||||
|
[ -n "$_item" ] || error 'list_contains: item required'
|
||||||
|
shift
|
||||||
|
|
||||||
|
for _pos; do
|
||||||
|
[ "$_item" = "$_pos" ] && return 0
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
Loading…
Reference in New Issue