mac build/builder improvements
Improve, refactor and clean up `tools/osx/builder` to build a relatively full-featured ffmpeg as well. This requires lots of other dists. It's kind of like a mini port system now. Will generalize it shortly to a sourced library for using with both the mac and the mingw builds. Will hopefully become a separate repo on github at some point. Add perl dist support to the builder. Add an `--env` flag to the builder to print the build environment variables so that they can be read in with `eval` for debugging purposes. Also add the `FFMPEG_STATIC` cmake option to link static ffmpeg libraries correctly. Move the codesigning and zipping of the `.app` bundle to the builder script and out of cmake, as this is something most users don't need.
This commit is contained in:
parent
f527d0a2a3
commit
420450255c
|
@ -193,9 +193,21 @@ SET(VBAMCORE_LIBS
|
|||
)
|
||||
|
||||
if(ENABLE_FFMPEG)
|
||||
FIND_PACKAGE ( PkgConfig REQUIRED )
|
||||
FIND_PACKAGE(PkgConfig REQUIRED)
|
||||
|
||||
PKG_CHECK_MODULES(FFMPEG REQUIRED libavcodec libavformat libswscale libavutil)
|
||||
|
||||
if(FFMPEG_STATIC)
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_STATIC_LIBRARIES})
|
||||
set(FFMPEG_LDFLAGS ${FFMPEG_STATIC_LDFLAGS} ${FFMPEG_STATIC_OTHER_LDFLAGS})
|
||||
|
||||
if(APPLE)
|
||||
set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} -framework CoreText -framework ApplicationServices)
|
||||
endif()
|
||||
else()
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES})
|
||||
set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} ${FFMPEG_OTHER_LDFLAGS})
|
||||
endif()
|
||||
endif(ENABLE_FFMPEG)
|
||||
|
||||
if(NOT ENABLE_FFMPEG)
|
||||
|
|
38
README.md
38
README.md
|
@ -118,24 +118,26 @@ cmake .. -DCMAKE_BUILD_TYPE=Debug
|
|||
|
||||
Here is the complete list:
|
||||
|
||||
| **CMake Option** | **What it Does** | **Defaults** |
|
||||
|----------------------|----------------------------------------------------------------------|-----------------------|
|
||||
| ENABLE_SDL | Build the SDL port | OFF |
|
||||
| ENABLE_WX | Build the wxWidgets port | ON |
|
||||
| ENABLE_DEBUGGER | Enable the debugger | ON |
|
||||
| ENABLE_NLS | Enable translations | ON |
|
||||
| ENABLE_ASM_CORE | Enable x86 ASM CPU cores (**BUGGY AND DANGEROUS**) | OFF |
|
||||
| ENABLE_ASM | Enable the following two ASM options | ON for 32 bit builds |
|
||||
| ENABLE_ASM_SCALERS | Enable x86 ASM graphic filters | ON for 32 bit builds |
|
||||
| ENABLE_MMX | Enable MMX | ON for 32 bit builds |
|
||||
| ENABLE_LINK | Enable GBA linking functionality (requires SFML) | ON |
|
||||
| ENABLE_LIRC | Enable LIRC support | OFF |
|
||||
| ENABLE_FFMPEG | Enable ffmpeg A/V recording | ON on Linux and MSys2 |
|
||||
| ENABLE_LTO | Compile with Link Time Optimization (gcc and clang only) | ON for release build |
|
||||
| ENABLE_GBA_LOGGING | Enable extended GBA logging | ON |
|
||||
| ENABLE_DIRECT3D | Direct3D rendering for wxWidgets (Windows, **NOT IMPLEMENTED!!!**) | ON |
|
||||
| ENABLE_XAUDIO2 | Enable xaudio2 sound output for wxWidgets (Windows only) | ON |
|
||||
| ENABLE_OPENAL | Enable OpenAL for the wxWidgets port | ON |
|
||||
| **CMake Option** | **What it Does** | **Defaults** |
|
||||
|-----------------------|----------------------------------------------------------------------|-----------------------|
|
||||
| ENABLE_SDL | Build the SDL port | OFF |
|
||||
| ENABLE_WX | Build the wxWidgets port | ON |
|
||||
| ENABLE_DEBUGGER | Enable the debugger | ON |
|
||||
| ENABLE_NLS | Enable translations | ON |
|
||||
| ENABLE_ASM_CORE | Enable x86 ASM CPU cores (**BUGGY AND DANGEROUS**) | OFF |
|
||||
| ENABLE_ASM | Enable the following two ASM options | ON for 32 bit builds |
|
||||
| ENABLE_ASM_SCALERS | Enable x86 ASM graphic filters | ON for 32 bit builds |
|
||||
| ENABLE_MMX | Enable MMX | ON for 32 bit builds |
|
||||
| ENABLE_LINK | Enable GBA linking functionality (requires SFML) | ON |
|
||||
| ENABLE_LIRC | Enable LIRC support | OFF |
|
||||
| ENABLE_FFMPEG | Enable ffmpeg A/V recording | ON on Linux and MSys2 |
|
||||
| ENABLE_LTO | Compile with Link Time Optimization (gcc and clang only) | ON for release build |
|
||||
| ENABLE_GBA_LOGGING | Enable extended GBA logging | ON |
|
||||
| ENABLE_DIRECT3D | Direct3D rendering for wxWidgets (Windows, **NOT IMPLEMENTED!!!**) | ON |
|
||||
| ENABLE_XAUDIO2 | Enable xaudio2 sound output for wxWidgets (Windows only) | ON |
|
||||
| ENABLE_OPENAL | Enable OpenAL for the wxWidgets port | ON |
|
||||
| SFML_STATIC_LIBRARIES | Set this to ON if linking static SFML libraries | OFF |
|
||||
| FFMPEG_STATIC | Set this to ON if linking static ffmpeg librariesl | OFF |
|
||||
|
||||
Note for distro packagers, we use the CMake module
|
||||
[GNUInstallDirs](https://cmake.org/cmake/help/v2.8.12/cmake.html#module:GNUInstallDirs)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# From: https://stackoverflow.com/a/7216542
|
||||
function(JOIN VALUES GLUE OUTPUT)
|
||||
string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
|
||||
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
|
||||
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
|
||||
endfunction()
|
|
@ -5,6 +5,8 @@ IF(NOT CMAKE_VERSION VERSION_LESS 3.0)
|
|||
cmake_policy(SET CMP0043 NEW) # for wxWidgets
|
||||
ENDIF()
|
||||
|
||||
include(VbamFunctions)
|
||||
|
||||
if( WIN32 )
|
||||
# not yet implemented
|
||||
option( ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" ON )
|
||||
|
@ -511,6 +513,13 @@ TARGET_LINK_LIBRARIES (
|
|||
${OPENAL_LIBRARY}
|
||||
)
|
||||
|
||||
join("${FFMPEG_LDFLAGS}" " " FFMPEG_LDFLAGS_STR)
|
||||
|
||||
set_target_properties(
|
||||
visualboyadvance-m
|
||||
PROPERTIES LINK_FLAGS ${FFMPEG_LDFLAGS_STR}
|
||||
)
|
||||
|
||||
# Build a console app in debug mode on Windows
|
||||
IF(WIN32 AND CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,console")
|
||||
|
@ -535,14 +544,6 @@ if(APPLE)
|
|||
ADD_CUSTOM_COMMAND(TARGET visualboyadvance-m POST_BUILD
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/tools/osx/third_party_libs_tool ./visualboyadvance-m.app
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
ADD_CUSTOM_COMMAND(TARGET visualboyadvance-m POST_BUILD
|
||||
COMMAND codesign -s "Developer ID Application" --deep ./visualboyadvance-m.app
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
ADD_CUSTOM_COMMAND(TARGET visualboyadvance-m POST_BUILD
|
||||
COMMAND zip -9r ./visualboyadvance-m-Mac.zip ./visualboyadvance-m.app
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
ENDIF()
|
||||
endif(APPLE)
|
||||
|
||||
|
|
|
@ -4,43 +4,140 @@ set -e
|
|||
|
||||
BUILD_ROOT=$HOME/vbam-build
|
||||
|
||||
# build env
|
||||
build_env() {
|
||||
cat <<EOF
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.7
|
||||
export CFLAGS="-I$BUILD_ROOT/root/include"
|
||||
export CFLAGS="-I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
|
||||
export CPPFLAGS="-I$BUILD_ROOT/root/include"
|
||||
export CXXFLAGS="-I$BUILD_ROOT/root/include -std=c++11 -stdlib=libc++"
|
||||
export OBJCXXFLAGS="-I$BUILD_ROOT/root/include -std=c++11 -stdlib=libc++"
|
||||
export LDFLAGS="-L$BUILD_ROOT/root/lib"
|
||||
export CXXFLAGS="-I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=c++11 -stdlib=libc++ -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
|
||||
export OBJCXXFLAGS="-I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=c++11 -stdlib=libc++ -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
|
||||
export LDFLAGS="-L$BUILD_ROOT/root/lib -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
|
||||
export CMAKE_PREFIX_PATH="$BUILD_ROOT/root"
|
||||
export PKG_CONFIG_PATH="$BUILD_ROOT/root/lib/pkgconfig"
|
||||
export PATH="$BUILD_ROOT/root/bin:$PATH"
|
||||
|
||||
export PERL_MB_OPT='--install_base $BUILD_ROOT/root/perl5'
|
||||
export PERL_MM_OPT='INSTALL_BASE=$BUILD_ROOT/root/perl5'
|
||||
export PERL5LIB="$BUILD_ROOT/root/perl5/lib/perl5"
|
||||
export PERL_LOCAL_LIB_ROOT="$BUILD_ROOT/root/perl5"
|
||||
|
||||
export PATH="$BUILD_ROOT/root/bin:$BUILD_ROOT/root/perl5/bin:$PATH"
|
||||
EOF
|
||||
}
|
||||
|
||||
eval "$(build_env)"
|
||||
|
||||
DISTS='
|
||||
nasm http://www.nasm.us/pub/nasm/releasebuilds/2.13.01/nasm-2.13.01.tar.xz bin/nasm
|
||||
yasm http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz bin/yasm
|
||||
zlib https://zlib.net/zlib-1.2.11.tar.gz lib/libz.a
|
||||
xz https://tukaani.org/xz/xz-5.2.3.tar.xz lib/liblzma.a
|
||||
bzip2 http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz lib/libbz2.a
|
||||
pcre https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.bz2 lib/libpcre.a
|
||||
libffi ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz lib/libffi.a
|
||||
libiconv https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz lib/libiconv.a
|
||||
gettext http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz lib/libintl.a
|
||||
glib http://mirror.umd.edu/gnome/sources/glib/2.54/glib-2.54.1.tar.xz lib/libglib-2.0.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 lib/libpng.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 lib/libtiff.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 lib/libsfml-system-s.a
|
||||
sfml https://github.com/SFML/SFML/archive/2.4.2.tar.gz lib/libsfml-system-s.a
|
||||
wxwidgets https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3/wxWidgets-3.0.3.tar.bz2 lib/libwx_baseu-3.0.a
|
||||
xvidcore http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.bz2 lib/libxvidcore.a
|
||||
fribidi http://fribidi.org/download/fribidi-0.19.7.tar.bz2 lib/libfribidi.a
|
||||
libass https://github.com/libass/libass/releases/download/0.13.7/libass-0.13.7.tar.xz lib/libass.a
|
||||
libgsm http://www.quut.com/gsm/gsm-1.0.17.tar.gz lib/libgsm.a
|
||||
libmodplug https://github.com/Konstanty/libmodplug/archive/5a39f5913d07ba3e61d8d5afdba00b70165da81d.tar.gz lib/libmodplug.a
|
||||
libopencore-amrnb https://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.5.tar.gz lib/libopencore-amrnb.a
|
||||
opus https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz lib/libopus.a
|
||||
snappy https://github.com/google/snappy/archive/1.1.7.tar.gz lib/libsnappy.a
|
||||
libsoxr https://downloads.sourceforge.net/project/soxr/soxr-0.1.2-Source.tar.xz lib/libsoxr.a
|
||||
speex http://downloads.us.xiph.org/releases/speex/speex-1.2.0.tar.gz lib/libspeex.a
|
||||
libvorbis https://github.com/xiph/vorbis/archive/v1.3.5.tar.gz lib/libvorbis.a
|
||||
libogg http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz lib/libogg.a
|
||||
libtheora https://github.com/Distrotech/libtheora/archive/17b02c8c564475bb812e540b551219fc42b1f75f.tar.gz lib/libtheora.a
|
||||
vidstab https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz lib/libvidstab.a
|
||||
libvo-amrwbenc https://github.com/mstorsjo/vo-amrwbenc/archive/v0.1.3.tar.gz lib/libvo-amrwbenc.a
|
||||
mp3lame https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz lib/libmp3lame.a
|
||||
libxml2 ftp://xmlsoft.org/libxml2/libxml2-2.9.6.tar.gz lib/libxml2.a
|
||||
XML-NamespaceSupport https://cpan.metacpan.org/authors/id/P/PE/PERIGRIN/XML-NamespaceSupport-1.12.tar.gz perl5/lib/perl5/XML/NamespaceSupport.pm
|
||||
XML-SAX-Base https://cpan.metacpan.org/authors/id/G/GR/GRANTM/XML-SAX-Base-1.09.tar.gz perl5/lib/perl5/XML/SAX/Base.pm
|
||||
XML-SAX https://cpan.metacpan.org/authors/id/G/GR/GRANTM/XML-SAX-0.99.tar.gz perl5/lib/perl5/XML/SAX.pm
|
||||
docbook2x https://downloads.sourceforge.net/project/docbook2x/docbook2x/0.8.8/docbook2X-0.8.8.tar.gz bin/docbook2man
|
||||
expat https://github.com/libexpat/libexpat/archive/R_2_2_4.tar.gz lib/libexpat.a
|
||||
graphite2 https://github.com/silnrsi/graphite/releases/download/1.3.10/graphite2-1.3.10.tgz lib/libgraphite2.a
|
||||
freetype http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.bz2 lib/libfreetype.a
|
||||
harfbuzz https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.6.0.tar.bz2 lib/libharfbuzz.a
|
||||
fontconfig https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.6.tar.bz2 lib/libfontconfig.a
|
||||
libbluray ftp://ftp.videolan.org/pub/videolan/libbluray/1.0.0/libbluray-1.0.0.tar.bz2 lib/libbluray.a
|
||||
libvpx http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.6.1.tar.bz2 lib/libvpx.a
|
||||
libwavpack http://www.wavpack.com/wavpack-5.1.0.tar.bz2 lib/libwavpack.a
|
||||
libx264 ftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2 lib/libx264.a
|
||||
libx265 https://bitbucket.org/multicoreware/x265/downloads/x265_2.5.tar.gz lib/libx265.a
|
||||
libxavs https://github.com/Distrotech/xavs/archive/distrotech-xavs-git.tar.gz lib/libxavs.a
|
||||
libzmq https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz lib/libzmq.a
|
||||
# libzvbi https://downloads.sourceforge.net/project/zapping/zvbi/0.2.35/zvbi-0.2.35.tar.bz2 lib/libzvbi.a
|
||||
ffmpeg http://ffmpeg.org/releases/ffmpeg-3.3.4.tar.xz lib/libavformat.a
|
||||
xz https://tukaani.org/xz/xz-5.2.3.tar.xz lib/liblzma.a
|
||||
'
|
||||
|
||||
CONFIGURE_ARGS="--disable-shared --enable-static --prefix=$BUILD_ROOT/root"
|
||||
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=$BUILD_ROOT/root -DCMAKE_INSTALL_PREFIX=$BUILD_ROOT/root"
|
||||
|
||||
CMAKE_ARGS="-DBUILD_SHARED_LIBS=NO -DENABLE_SHARED=NO -DCMAKE_PREFIX_PATH=$BUILD_ROOT/root -DCMAKE_INSTALL_PREFIX=$BUILD_ROOT/root -DCMAKE_BUILD_TYPE=Release"
|
||||
|
||||
DIST_PATCHES='
|
||||
docbook2x https://sourceforge.net/p/docbook2x/bugs/_discuss/thread/0cfa4055/f6a5/attachment/docbook2x.patch
|
||||
graphite2 https://gist.githubusercontent.com/rkitover/418600634d7cf19e2bf1c3708b50c042/raw/b5e9ee6c237a588157a754de6705a56fc315b00a/graphite2-static.patch
|
||||
'
|
||||
|
||||
DIST_PRE_BUILD="
|
||||
expat cd expat; sed -i .bak 's/cp \\\$</mv \$</' doc/doc.mk
|
||||
libmodplug sed -i .bak '/-mmacosx-version-min=/d' configure.ac; sed -i .bak 's/-lstdc++/-lc++/g' libmodplug.pc.in; rm -f configure
|
||||
libzmq sed -i .bak 's/-lstdc++/-lc++/g' src/libzmq.pc.in
|
||||
xvidcore cd build/generic; sed -i .bak '/^all:/{ s/ *\\\$(SHARED_LIB)//; }; /^install:/{ s, *\\\$(BUILD_DIR)/\\\$(SHARED_LIB),,; }; s/\\\$(INSTALL).*\\\$(SHARED_LIB).*/:/; s/\\\$(LN_S).*\\\$(SHARED_LIB).*/:/' Makefile
|
||||
libx265 cd source
|
||||
ffmpeg sed -i .bak 's/-lstdc++/-lc++/g' configure
|
||||
"
|
||||
|
||||
DIST_POST_BUILD="
|
||||
"
|
||||
|
||||
DIST_OVERRIDES="
|
||||
zlib --static --prefix=$BUILD_ROOT/root
|
||||
openssl darwin64-x86_64-cc no-shared --prefix=$BUILD_ROOT/root
|
||||
"
|
||||
|
||||
DIST_ARGS="
|
||||
sfml -DBUILD_SHARED_LIBS=NO
|
||||
wxwidgets --with-macosx-version-min=$MACOSX_DEPLOYMENT_TARGET --enable-stl LDFLAGS=-stdlib=libc++
|
||||
pcre --enable-utf8 --enable-pcre8 --enable-pcre16 --enable-pcre32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
|
||||
libmodplug CC=clang++ CXX=clang++
|
||||
freetype --with-harfbuzz=no
|
||||
harfbuzz --with-cairo=no
|
||||
libvpx --disable-unit-tests --disable-tools --disable-docs --disable-examples
|
||||
libxavs --disable-asm
|
||||
libzvbi --without-x --without-doxygen
|
||||
libxml2 --without-python
|
||||
wxwidgets --with-macosx-version-min=$MACOSX_DEPLOYMENT_TARGET --enable-stl LDFLAGS='$LDFLAGS -stdlib=libc++' --disable-precomp-headers
|
||||
libbluray --disable-bdjava
|
||||
libopencore-amrnb --disable-compile-c
|
||||
vidstab -DUSE_OMP=NO
|
||||
ffmpeg --extra-ldflags='-framework CoreText' --pkg-config-flags=--static --enable-nonfree --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-version3 --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-openssl --enable-lzma
|
||||
#
|
||||
# TODO: add these if possible (from brew) --enable-indev=qtkit --enable-securetransport --enable-chromaprint --enable-ffplay --enable-frei0r --enable-libbs2b --enable-libcaca --enable-libfdk-aac --enable-libgme --enable-libgsm --enable-librtmp --enable-librubberband --enable-libssh --enable-libtesseract --enable-libtwolame --enable-webp --enable-libzimg
|
||||
#
|
||||
# Possibly also: --enable-libzvbi
|
||||
# I could not get libzvbi to build
|
||||
#
|
||||
# these require > 10.7:
|
||||
# --enable-opencl # requires 10.8
|
||||
# --enable-videotoolbox # requires 10.8
|
||||
"
|
||||
|
||||
DIST_MAKE_ARGS="
|
||||
expat DOCBOOK_TO_MAN=docbook2man
|
||||
"
|
||||
|
||||
main() {
|
||||
read_command_line "$@"
|
||||
setup
|
||||
delete_outdated_dists
|
||||
download_dists
|
||||
|
@ -48,8 +145,18 @@ main() {
|
|||
build_project
|
||||
}
|
||||
|
||||
read_command_line() {
|
||||
case "$1" in
|
||||
--env)
|
||||
build_env
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
setup() {
|
||||
mkdir -p "$BUILD_ROOT"
|
||||
mkdir -p "$BUILD_ROOT/root/include"
|
||||
[ -e "$BUILD_ROOT/root/inc" ] || ln -s "$BUILD_ROOT/root/include" "$BUILD_ROOT/root/inc"
|
||||
|
||||
DIST_NAMES=$( table_column 0 3 "$DISTS")
|
||||
DIST_URLS=$( table_column 1 3 "$DISTS")
|
||||
|
@ -63,55 +170,68 @@ setup() {
|
|||
}
|
||||
|
||||
delete_outdated_dists() {
|
||||
[ ! -d "$BUILD_ROOT/downloads" ] && return 0
|
||||
|
||||
files=
|
||||
i=0
|
||||
for dist in $DIST_NAMES; do
|
||||
dist_url=$(list_get $i $DIST_URLS)
|
||||
dist_file="$BUILD_ROOT/dists/${dist_url##*/}"
|
||||
dist_file="$BUILD_ROOT/downloads/$dist-${dist_url##*/}"
|
||||
|
||||
files="$files $dist_file"
|
||||
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
for file in $BUILD_ROOT/dists/*; do
|
||||
OLDIFS=$IFS
|
||||
IFS='
|
||||
'; find "$BUILD_ROOT/downloads" -type f -maxdepth 1 -not -name '.*' | \
|
||||
while read -r file; do
|
||||
IFS=$OLDIFS
|
||||
if ! list_contains "$file" $files; then
|
||||
echo "\n[32mDeleting outdated dist: [1;34m$file[0m\n"
|
||||
rm -f "$file"
|
||||
fi
|
||||
done
|
||||
IFS=$OLDIFS
|
||||
}
|
||||
|
||||
download_dists() {
|
||||
mkdir -p "$BUILD_ROOT/dists"
|
||||
mkdir -p "$BUILD_ROOT/downloads"
|
||||
|
||||
i=0
|
||||
while [ $i -lt $DISTS_NUM ]; do
|
||||
dist_name=$(list_get $i $DIST_NAMES)
|
||||
dist_url=$( list_get $i $DIST_URLS)
|
||||
dist_file="$BUILD_ROOT/dists/${dist_url##*/}"
|
||||
orig_dist_file="$BUILD_ROOT/downloads/${dist_url##*/}"
|
||||
dist_file="$BUILD_ROOT/downloads/$dist_name-${dist_url##*/}"
|
||||
dist_dir="$BUILD_ROOT/dists/$dist_name"
|
||||
|
||||
cd "$BUILD_ROOT/downloads"
|
||||
|
||||
cd "$BUILD_ROOT/dists"
|
||||
if [ ! -e "$dist_file" ]; then
|
||||
echo "\n[32mFetching [1;35m$dist_name[0m: [1;34m$dist_url[0m\n"
|
||||
curl -LO "$dist_url"
|
||||
|
||||
mv -f "$orig_dist_file" "$dist_file"
|
||||
|
||||
# force rebuild for new dist file
|
||||
rm -f "$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
|
||||
rm -rf "$BUILD_ROOT/libs/$dist_name"
|
||||
rm -rf "$dist_dir"
|
||||
fi
|
||||
|
||||
dist_dir="$BUILD_ROOT/libs/$dist_name"
|
||||
|
||||
if [ ! -d "$dist_dir" ]; then
|
||||
mkdir -p "$dist_dir"
|
||||
|
||||
tmp_dir="$BUILD_ROOT/libs/tmp"
|
||||
tmp_dir="$BUILD_ROOT/dists/tmp"
|
||||
mkdir -p "$tmp_dir"
|
||||
cd "$tmp_dir"
|
||||
|
||||
case "$dist_file" in
|
||||
*.tar.gz)
|
||||
*.tar)
|
||||
tar xf "$dist_file"
|
||||
;;
|
||||
*.tar.gz|*.tgz)
|
||||
tar zxf "$dist_file"
|
||||
;;
|
||||
*.tar.xz)
|
||||
|
@ -127,6 +247,9 @@ download_dists() {
|
|||
|
||||
mv */* "$dist_dir"
|
||||
rm -rf "$tmp_dir"
|
||||
|
||||
# force rebuild if dist dir was deleted
|
||||
rm -f "$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
|
||||
fi
|
||||
|
||||
i=$((i + 1))
|
||||
|
@ -134,68 +257,109 @@ download_dists() {
|
|||
}
|
||||
|
||||
build_dists() {
|
||||
cd "$BUILD_ROOT/libs"
|
||||
|
||||
i=0
|
||||
for dist in $DIST_NAMES; do
|
||||
target_lib="$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
|
||||
while [ $i -lt $DISTS_NUM ]; do
|
||||
install_artifact="$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
|
||||
|
||||
if [ ! -e "$target_lib" ]; then
|
||||
cd "$dist"
|
||||
|
||||
if [ -e configure -o -e configure.ac -o -e configure.in -o -e Makefile.am ]; then
|
||||
echo "\n[32mBuilding [1;35m$dist[0m\n"
|
||||
|
||||
if [ ! -e configure ]; then
|
||||
aclocal
|
||||
|
||||
if command -v glibtoolize >/dev/null; then
|
||||
glibtoolize
|
||||
else
|
||||
libtoolize
|
||||
fi
|
||||
|
||||
autoheader
|
||||
autoconf
|
||||
[ -e Makefile.am ] && automake --add-missing
|
||||
fi
|
||||
|
||||
./configure $(dist_args "$dist" autoconf)
|
||||
make -j$NUM_CPUS
|
||||
make install prefix=$BUILD_ROOT/root
|
||||
|
||||
echo "\n[32mDone!!![0m\n"
|
||||
elif [ -e CMakeLists.txt ]; then
|
||||
echo "\n[32mBuilding [1;35m$dist[0m\n"
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake .. $(dist_args "$dist" cmake)
|
||||
make -j$NUM_CPUS
|
||||
rm -rf destdir
|
||||
mkdir destdir
|
||||
make install DESTDIR="$PWD/destdir"
|
||||
|
||||
cd "$PWD/destdir/$BUILD_ROOT/root"
|
||||
find . ! -type d | (cd "$BUILD_ROOT/root"; IFS='
|
||||
'; while read f; do
|
||||
mkdir -p "${f%/*}"
|
||||
cp -a "$BUILD_ROOT/libs/$dist/build/destdir/$BUILD_ROOT/root/$f" "$f"
|
||||
done)
|
||||
|
||||
cd "$BUILD_ROOT/libs/$dist"
|
||||
|
||||
echo "\n[32mDone!!![0m\n"
|
||||
fi
|
||||
|
||||
cd ..
|
||||
if [ ! -e "$install_artifact" ]; then
|
||||
build_dist $(list_get $i $DIST_NAMES)
|
||||
fi
|
||||
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
build_dist() {
|
||||
dist=$1
|
||||
[ -n "$1" ] || error 'build_dist: dist name required'
|
||||
shift
|
||||
extra_dist_args=$@
|
||||
|
||||
cd "$BUILD_ROOT/dists/$dist"
|
||||
|
||||
echo "\n[32mBuilding [1;35m$dist[0m\n"
|
||||
|
||||
ORIG_LDFLAGS=$LDFLAGS
|
||||
|
||||
# have to make sure C++ flags are passed when linking, but only for C++ and **NOT** C
|
||||
# this fails if there are any .c files in the project
|
||||
if [ "$(find . -name '*.cpp' -o -name '*.cc' | wc -l)" -ne 0 -a "$(find . -name '*.c' | wc -l)" -eq 0 ]; then
|
||||
export LDFLAGS="$CXXFLAGS $LDFLAGS"
|
||||
fi
|
||||
|
||||
dist_patch "$dist"
|
||||
dist_pre_build "$dist"
|
||||
|
||||
if [ -e configure -o -e configure.ac -o -e configure.in -o -e Makefile.am ]; then
|
||||
if [ ! -e configure ]; then
|
||||
if [ -e autogen.sh ]; then
|
||||
sh autogen.sh
|
||||
elif [ -e buildconf.sh ]; then
|
||||
sh buildconf.sh
|
||||
else
|
||||
if [ -d m4 ]; then
|
||||
aclocal -I m4
|
||||
else
|
||||
aclocal
|
||||
fi
|
||||
|
||||
if command -v glibtoolize >/dev/null; then
|
||||
glibtoolize
|
||||
else
|
||||
libtoolize
|
||||
fi
|
||||
|
||||
autoheader || :
|
||||
autoconf
|
||||
[ -e Makefile.am ] && automake --add-missing
|
||||
fi
|
||||
fi
|
||||
|
||||
eval "set -- $(dist_args "$dist" autoconf) $extra_dist_args"
|
||||
./configure "$@"
|
||||
eval "set -- $(dist_make_args "$dist")"
|
||||
make -j$NUM_CPUS "$@"
|
||||
make install prefix=$BUILD_ROOT/root
|
||||
elif [ -e CMakeLists.txt ]; then
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
eval "set -- $(dist_args "$dist" cmake) $extra_dist_args"
|
||||
cmake .. "$@"
|
||||
eval "set -- $(dist_make_args "$dist")"
|
||||
make -j$NUM_CPUS "$@"
|
||||
rm -rf destdir
|
||||
mkdir destdir
|
||||
make install DESTDIR="$PWD/destdir"
|
||||
|
||||
cd "destdir/$BUILD_ROOT/root"
|
||||
OLDPWD=$PWD
|
||||
find . ! -type d | (cd "$BUILD_ROOT/root";IFS='
|
||||
'; while read f; do
|
||||
mkdir -p "${f%/*}"
|
||||
cp -a "$OLDPWD/$f" "$f"
|
||||
done)
|
||||
elif [ -e Makefile.PL ]; then
|
||||
eval "set -- $(dist_args "$dist" perl) $extra_dist_args"
|
||||
perl Makefile.PL "$@"
|
||||
eval "set -- $(dist_make_args "$dist")"
|
||||
make -j$NUM_CPUS "$@"
|
||||
make install
|
||||
elif [ -e Makefile ]; then
|
||||
eval "set -- $(dist_make_args "$dist")"
|
||||
make -j$NUM_CPUS "$@"
|
||||
make install PREFIX="$BUILD_ROOT/root" INSTALL_ROOT="$BUILD_ROOT/root"
|
||||
else
|
||||
error "don't know how to build [1;35m$dist[0m"
|
||||
fi
|
||||
|
||||
dist_post_build "$dist"
|
||||
|
||||
export LDFLAGS=$ORIG_LDFLAGS
|
||||
|
||||
echo "\n[32mDone!!![0m\n"
|
||||
}
|
||||
|
||||
list_get() {
|
||||
i=0
|
||||
n=${1:=0}
|
||||
|
@ -213,10 +377,15 @@ list_get() {
|
|||
|
||||
dist_args() {
|
||||
dist=$1
|
||||
[ -n "$dist" ] || error 'dist name required'
|
||||
[ -n "$dist" ] || error 'dist_args: dist name required'
|
||||
buildsys=$2
|
||||
[ "$buildsys" = autoconf -o "$buildsys" = cmake ] || \
|
||||
error "buildsystem type required, must be 'autoconf' or 'cmake'"
|
||||
case "$buildsys" in
|
||||
autoconf|cmake|perl)
|
||||
;;
|
||||
*)
|
||||
error "dist_args: buildsystem type required, must be 'autoconf', 'cmake' or 'perl'"
|
||||
;;
|
||||
esac
|
||||
|
||||
args=$(table_line "$dist" "$DIST_OVERRIDES")
|
||||
|
||||
|
@ -228,6 +397,9 @@ dist_args() {
|
|||
cmake)
|
||||
args="$CMAKE_ARGS $(table_line "$dist" "$DIST_ARGS")"
|
||||
;;
|
||||
perl)
|
||||
args="$(table_line "$dist" "$DIST_ARGS")"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
@ -236,12 +408,66 @@ dist_args() {
|
|||
return 0
|
||||
}
|
||||
|
||||
dist_make_args() {
|
||||
dist=$1
|
||||
[ -n "$dist" ] || error 'dist_make_args: dist name required'
|
||||
|
||||
echo "$(table_line "$dist" "$DIST_MAKE_ARGS")"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
dist_patch() {
|
||||
[ -n "$1" ] || error 'dist_patch: dist name required'
|
||||
|
||||
_patch_url="$(table_line "$1" "$DIST_PATCHES")"
|
||||
|
||||
[ -n "$_patch_url" ] || return 0
|
||||
|
||||
echo "\n[32mApplying patch [1;34m$_patch_url[0m to [1;35m$1[0m\n"
|
||||
|
||||
curl -LO "$_patch_url"
|
||||
patch -p1 < "${_patch_url##*/}"
|
||||
|
||||
echo "\n[32mDone!!![0m\n"
|
||||
}
|
||||
|
||||
dist_pre_build() {
|
||||
[ -n "$1" ] || error 'dist_pre_build: dist name required'
|
||||
|
||||
_cmd=$(table_line "$1" "$DIST_PRE_BUILD")
|
||||
[ -n "$_cmd" ] || return 0
|
||||
|
||||
echo "\n[32mRunning pre-build for: [1;35m$dist[0m:\n$_cmd\n"
|
||||
|
||||
eval "$_cmd"
|
||||
}
|
||||
|
||||
dist_post_build() {
|
||||
[ -n "$1" ] || error 'dist_post_build: dist name required'
|
||||
|
||||
_cmd=$(table_line "$1" "$DIST_POST_BUILD")
|
||||
[ -n "$_cmd" ] || return 0
|
||||
|
||||
if [ -z "$IN_DIST_POST_BUILD" ]; then
|
||||
IN_DIST_POST_BUILD=1
|
||||
|
||||
echo "\n[32mRunning post-build for: [1;35m$dist[0m:\n$_cmd\n"
|
||||
|
||||
eval "$_cmd"
|
||||
|
||||
IN_DIST_POST_BUILD=
|
||||
fi
|
||||
}
|
||||
|
||||
table_line() {
|
||||
name=$1
|
||||
[ -n "$name" ] || error 'item name required'
|
||||
table=$2
|
||||
[ -n "$table" ] || error 'table string required'
|
||||
|
||||
table=$(echo "$table" | grep -Ev '^ *#')
|
||||
|
||||
OLDIFS=$IFS
|
||||
IFS='
|
||||
'
|
||||
|
@ -274,7 +500,7 @@ find_checkout() {
|
|||
}
|
||||
|
||||
error() {
|
||||
printf >&2 '\n[31mERROR[0m: %s.\n\n' "$1"
|
||||
printf >&2 '\n[31mERROR[0m: %s\n\n' "$1"
|
||||
[ -z "$2" ] && exit 1
|
||||
}
|
||||
|
||||
|
@ -284,9 +510,14 @@ build_project() {
|
|||
mkdir -p "$BUILD_ROOT/project"
|
||||
cd "$BUILD_ROOT/project"
|
||||
|
||||
cmake "$CHECKOUT" -DCMAKE_PREFIX_PATH="$BUILD_ROOT/root" -DENABLE_FFMPEG=OFF -DSFML_STATIC_LIBRARIES=TRUE
|
||||
cmake "$CHECKOUT" -DCMAKE_PREFIX_PATH="$BUILD_ROOT/root" -DCMAKE_BUILD_TYPE=Release -DSFML_STATIC_LIBRARIES=TRUE -DENABLE_FFMPEG=ON -DFFMPEG_STATIC=TRUE
|
||||
make -j$NUM_CPUS
|
||||
|
||||
codesign -s "Developer ID Application" --deep ./visualboyadvance-m.app || :
|
||||
|
||||
rm -f ./visualboyadvance-m-Mac.zip
|
||||
zip -9r ./visualboyadvance-m-Mac.zip ./visualboyadvance-m.app
|
||||
|
||||
echo "\n[32mBuild Successful!!![0m\n\nBuild results can be found in: [1;34m$BUILD_ROOT/project[0m\n"
|
||||
}
|
||||
|
||||
|
@ -298,6 +529,8 @@ table_column() {
|
|||
table=$3
|
||||
[ -n "$table" ] || error 'table_column: table required'
|
||||
|
||||
table=$(echo "$table" | grep -Ev '^ *#')
|
||||
|
||||
i=0
|
||||
res=
|
||||
for item in $table; do
|
||||
|
@ -316,6 +549,8 @@ table_rows() {
|
|||
table=$1
|
||||
[ -n "$table" ] || error 'table_rows: table required'
|
||||
|
||||
table=$(echo "$table" | grep -Ev '^ *#')
|
||||
|
||||
i=0
|
||||
OLDIFS=$IFS
|
||||
IFS='
|
||||
|
|
Loading…
Reference in New Issue