Travis OS X: Use MacPorts for program depends

This commit is contained in:
mazmazz 2020-06-09 14:51:38 -04:00
parent 06e330459b
commit eb57419eb5
9 changed files with 299 additions and 92 deletions

View file

@ -14,37 +14,17 @@ matrix:
################################
- os: osx
osx_image: xcode11.5
env:
- CFLAGS="-march=core2 -mtune=haswell"
- CXXFLAGS="-march=core2 -mtune=haswell"
env:
- MARCH=core2
- MTUNE=haswell
- MACOSX_DEPLOYMENT_TARGET=10.9
- CFLAGS="-march=$MARCH -mtune=$MTUNE"
- CXXFLAGS="-march=$MARCH -mtune=$MTUNE"
- DPL_UPLOAD_INSTALLER_FTP="${DPL_UPLOAD_INSTALLER_FTP:-1}"
cache:
directories:
# Note: brew update cache (/usr/local/Homebrew) does not appear to be effective.
# Would be nice to implement this solution -- https://stackoverflow.com/a/53331571
#- /usr/local/Homebrew
- $HOME/Library/Caches/Homebrew
- $HOME/homebrew_cache
- $HOME/.ccache
- $HOME/macports_cache
- $HOME/srb2_cache
before_install:
# Initialize Deployer defaults
- source ./travis/defaults.sh
# Unpack homebrew.
# Unlink current cmake so our installed cmake can overwrite.
- if [[ -f "$HOME/homebrew_cache/homebrew-cache-Cellar.tar.gz" ]]; then
brew unlink cmake;
tar xzf $HOME/homebrew_cache/homebrew-cache-Cellar.tar.gz --directory=/usr/local/Cellar;
tar xzf $HOME/homebrew_cache/homebrew-cache-opt.tar.gz --directory=/usr/local/opt;
fi;
before_cache:
- brew cleanup
# Credit https://discourse.brew.sh/t/best-practice-for-homebrew-on-travis-brew-update-is-5min-to-build-time/5215/9
# Cache only .git files under "/usr/local/Homebrew" so "brew update" does not take 5min every build
#- find /usr/local/Homebrew \! -regex ".+\.git.+" -delete
- tar czf $HOME/homebrew_cache/homebrew-cache-Cellar.tar.gz --directory=/usr/local/Cellar p7zip cmake ccache sdl2 sdl2_mixer game-music-emu libopenmpt
- tar czf $HOME/homebrew_cache/homebrew-cache-opt.tar.gz --directory=/usr/local/opt p7zip cmake ccache sdl2 sdl2_mixer game-music-emu libopenmpt
deploy:
- provider: releases
skip_cleanup: true
@ -431,28 +411,13 @@ addons:
before_install:
# Initialize Deployer defaults
- source ./travis/defaults.sh
- export CCACHE_COMPRESS="true"
install:
# OS X: Install library dependencies via Homebrew
# * `brew install --build-from-source` builds libraries for our CFLAGS, which target core2 CPU
# * `sdl2_mixer` requires options from the formula tap https://github.com/mazmazz/homebrew-srb2
- mkdir -p $HOME/srb2_cache
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
BREW_UPGRADE="bash ./travis/osx_brew_upgrade.sh";
brew tap mazmazz/srb2;
brew update > /dev/null;
$BREW_UPGRADE p7zip; brew link p7zip;
$BREW_UPGRADE cmake; brew link cmake;
$BREW_UPGRADE ccache; brew link ccache;
$BREW_UPGRADE --build-from-source sdl2; brew link sdl2;
$BREW_UPGRADE --build-from-source mazmazz/srb2/sdl2_mixer --with-flac --with-mpg123; brew link mazmazz/srb2/sdl2_mixer;
$BREW_UPGRADE --build-from-source mazmazz/srb2/game-music-emu; brew link mazmazz/srb2/game-music-emu;
$BREW_UPGRADE --build-from-source libopenmpt; brew link libopenmpt;
fi
# Windows: Install MSYS2 and build toolchain
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
source ./travis/windows_install.sh;
# Install Windows and OS X toolchains
- if [ -f "./travis/${TRAVIS_OS_NAME}_install.sh" ]; then
source ./travis/${TRAVIS_OS_NAME}_install.sh;
fi
@ -495,16 +460,7 @@ before_script:
# Prepare CMake
- mkdir build
- cd build
- mkdir package
- export CFLAGS="-Wall -W -Werror $WFLAGS $CFLAGS"
- export CCACHE_COMPRESS=true
# enable CCACHE on OSX
# also fix LIBRARY_PATH to include SDL2
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
export PATH="/usr/local/opt/ccache/bin:$PATH";
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib";
__CMAKE_CCACHE="-DSRB2_USE_CCACHE=ON";
fi;
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
__CMAKE_GENERATOR="MinGW Makefiles";
__CMAKE_COMPILER="-DCMAKE_C_COMPILER=gcc -DCMAKE_MAKE_PROGRAM=mingw32-make";
@ -516,7 +472,12 @@ before_script:
__CMAKE_GENERATOR="Unix Makefiles";
__MAKE="make";
fi;
- cmake .. -G "$__CMAKE_GENERATOR" ${__CMAKE_COMPILER} ${__CMAKE_CCACHE} -DCMAKE_BUILD_TYPE=RelWithDebInfo ${__CMAKE_LIBRARIES} ${__CMAKE_ASM}
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
__CMAKE_CCACHE="-DSRB2_USE_CCACHE=ON";
__CMAKE_PREFIX_PATH="-DCMAKE_PREFIX_PATH=/opt/local/include/gme;/opt/local/include/libopenmpt";
fi;
- cmake .. -G "$__CMAKE_GENERATOR" ${__CMAKE_COMPILER} ${__CMAKE_PREFIX_PATH} ${__CMAKE_CCACHE}
-DCMAKE_BUILD_TYPE=RelWithDebInfo ${__CMAKE_LIBRARIES} ${__CMAKE_ASM}
-DCMAKE_INSTALL_PREFIX=$PWD/bin -DCPACK_PACKAGE_DIRECTORY=$PWD/package
-DSRB2_ASSET_HASHED="${SRB2_ASSET_HASHED}" -DSRB2_ASSET_DOCS="${SRB2_ASSET_DOCS}"
-DSRB2_ASSET_DIRECTORY="${SRB2_ASSET_DIRECTORY}"

View file

@ -0,0 +1,20 @@
PortSystem 1.0
PortGroup cmake 1.1
PortGroup bitbucket 1.0
name libgme
version 0.6.2
categories audio devel
platforms darwin
license lgpl
maintainers nomaintainer
description Videogame music file emulator collection
bitbucket.author mpyne
bitbucket.project game-music-emu
bitbucket.version 0.6.2
bitbucket.tarball_from downloads
extract.suffix .tar.xz
checksums rmd160 743793e4e752074e7dcdccfb2d92dd0c86a9edd0 \
sha256 5046cb471d422dbe948b5f5dd4e5552aaef52a0899c4b2688e5a68a556af7342

View file

@ -0,0 +1,31 @@
PortSystem 1.0
name libopenmpt
version 0.5.0
categories audio devel
platforms darwin
license bsd
maintainers nomaintainer
description Software library to decode tracked music files
homepage https://lib.openmpt.org/libopenmpt/
master_sites https://lib.openmpt.org/files/libopenmpt/src/
distname ${name}-${version}+release.autotools
livecheck.url ${master_sites}
checksums rmd160 ad501fc60a8952bf7160fb1c41b76c8c6624b4a9 \
sha256 43cba54a3f7220c3cc5baae1e2c19a5af7196bfdb95ff4d0c4979d9fbc6c837e
depends_build port:pkgconfig
depends_lib port:zlib \
port:libogg \
port:libvorbis \
port:mpg123
configure.args --disable-dependency-tracking \
--disable-silent-rules \
--without-vorbisfile \
--without-portaudio \
--without-portaudiocpp \
--without-sndfile \
--without-flac

View file

@ -0,0 +1,65 @@
PortSystem 1.0
name libsdl2_mixer
set my_name SDL2_mixer
version 2.0.4
categories audio devel
platforms darwin
license zlib
maintainers {jmr @jmroot} openmaintainer
description Audio mixer library for SDL
long_description \
A sample multi-channel audio mixer library. It supports any number of \
simultaneously playing channels of 16 bit stereo audio, plus a single \
channel of music.
homepage http://www.libsdl.org/projects/SDL_mixer/
master_sites ${homepage}release/
distname ${my_name}-${version}
checksums rmd160 d5674a92bc9a81e3aba0072c4d7e2314e56958d6 \
sha256 b4cf5a382c061cd75081cf246c2aa2f9df8db04bdda8dcdc6b6cca55bede2419
depends_build port:pkgconfig
depends_lib port:libsdl2 \
port:flac \
port:libmodplug \
port:libvorbis \
port:mpg123
configure.args --disable-sdltest \
--disable-dependency-tracking \
--enable-music-flac \
--disable-music-flac-shared \
--enable-music-midi \
--disable-music-midi-fluidsynth \
--disable-music-midi-fluidsynth-shared \
--enable-music-midi-native \
--disable-music-midi-timidity \
--enable-music-mod \
--disable-music-mod-mikmod \
--disable-music-mod-mikmod-shared \
--enable-music-mod-modplug \
--disable-music-mod-modplug-shared \
--enable-music-mp3 \
--enable-music-mp3-mpg123 \
--disable-music-mp3-mpg123-shared \
--enable-music-ogg \
--disable-music-ogg-shared \
--disable-music-opus \
--disable-music-opus-shared \
--enable-music-wave
compiler.blacklist *gcc* { clang < 211 }
post-destroot {
set docdir ${prefix}/share/doc/${name}
xinstall -d ${destroot}${docdir}
xinstall -m 0644 -W ${worksrcpath} CHANGES.txt COPYING.txt README.txt \
${destroot}${docdir}
}
livecheck.type regex
livecheck.url ${homepage}
livecheck.regex ${my_name}-(\\d+(?:\\.\\d+)*)

View file

@ -0,0 +1,60 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
PortSystem 1.0
name libpng
version 1.6.37
revision 0
checksums rmd160 7d68b596480e994aeccb2794df48a3613f1de9c4 \
sha256 505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca \
size 1012272
set branch [join [lrange [split ${version} .] 0 1] ""]
categories graphics
maintainers {ryandesign @ryandesign}
license zlib
platforms darwin openbsd freebsd sunos linux
homepage http://www.libpng.org/pub/png/libpng.html
use_xz yes
description Library for manipulating PNG images
long_description Libpng was written as a companion to the PNG \
specification, as a way to reduce the amount of time \
and effort it takes to support the PNG file format in \
application programs. Most users will not have to \
modify the library significantly, advanced users may \
want to modify it more. The library was coded for \
both users. All attempts were made to make it as \
complete as possible, while keeping the code easy to \
understand. Currently, this library only supports C. \
Support for other languages is being considered.
master_sites sourceforge:project/${name}/${name}${branch}/${version} \
ftp://ftp.simplesystems.org/pub/libpng/png/src/${name}${branch}/
depends_lib port:zlib
patchfiles-append libpng.pc.in.patch
patchfiles-append png.h.patch
use_parallel_build yes
test.run yes
test.target check
post-destroot {
set docdir ${prefix}/share/doc/${subport}
xinstall -d ${destroot}${docdir}/examples
xinstall -m 0644 -W ${worksrcpath} \
ANNOUNCE \
CHANGES \
LICENSE \
README \
TODO \
${destroot}${docdir}
xinstall -m 0644 ${worksrcpath}/example.c ${destroot}${docdir}/examples
}
livecheck.type regexm
livecheck.regex {Current.+?(?:version|release).+?<B>(?:libpng )?([0-9.]+)</B>}

View file

@ -0,0 +1,11 @@
--- libpng.pc.in.orig 2017-09-29 03:40:57.000000000 -0500
+++ libpng.pc.in 2018-03-05 21:17:59.000000000 -0600
@@ -6,7 +6,7 @@
Name: libpng
Description: Loads and saves PNG files
Version: @PNGLIB_VERSION@
-Requires: zlib
+Requires.private: zlib
Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
Libs.private: @LIBS@
Cflags: -I${includedir}

View file

@ -0,0 +1,11 @@
--- png.h.orig
+++ png.h
@@ -3207,7 +3207,7 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
#ifdef PNG_MIPS_MSA_API_SUPPORTED
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
#endif
-#define PNG_IGNORE_ADLER32 8
+//#define PNG_IGNORE_ADLER32 8
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */
#endif

View file

@ -1,37 +0,0 @@
#!/bin/sh
build_from_source=""
package=$1
if [[ "$package" == "--build-from-source" ]]; then
build_from_source="--build-from-source";
package=$2;
args=${a[@]:2};
else
args=${a[@]:1};
fi
pkg_installed=false
pkg_updated=false
verbose=true
# TODO: ensure valid input
list_output=`brew list | grep $package`
outdated_output=`brew outdated | grep $package`
# now enable error checking
set -e
if [[ ! -z "$list_output" ]]; then
pkg_installed=true
$verbose && echo "package $package is installed"
if [[ -z "$outdated_output" ]]; then
pkg_updated=true
$verbose && echo "package $package is up-to-date."
else
$verbose && echo "package $package is out-of-date. updating..."
brew upgrade $build_from_source $package $args
fi
else
$verbose && echo "package $package is not installed. installing..."
brew install $build_from_source $package $args
fi

85
travis/osx_install.sh Normal file
View file

@ -0,0 +1,85 @@
#!/bin/bash
# Deployer for Travis-CI
# OS X Setup
# If cache file exists, extract it
if [ -f "$HOME/macports_cache/macports.tar" ]; then
echo "Extracting MacPorts cache...";
sudo tar -C / -xf "$HOME/macports_cache/macports.tar";
unlink "$HOME/macports_cache/macports.tar";
else
echo "MacPorts cache not found; installing from scratch...";
VERBOSE=1;
fi
# Verbose?
if [[ "$VERBOSE" == "1" ]]; then
__V="-v";
fi
# Install MacPorts
# https://github.com/GiovanniBussi/macports-ci
echo "Installing MacPorts..."
curl -LO https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci
source ./macports-ci install
# Enable ccache in MacPorts
echo "Configuring MacPorts..."
echo "configureccache yes" | sudo tee -a /opt/local/etc/macports/macports.conf
# Set compiler defaults
# Asinine -- https://lists.macports.org/pipermail/macports-users/2009-February/013828.html
sudo cp /opt/local/libexec/macports/lib/port1.0/portconfigure.tcl /opt/local/libexec/macports/lib/port1.0/portconfigure.tcl~
sudo sed -i.bak "s@default configure.march {}@default configure.march ${MARCH:-core2}@" /opt/local/libexec/macports/lib/port1.0/portconfigure.tcl
sudo sed -i.bak "s@default configure.mtune {}@default configure.mtune ${MTUNE:-haswell}@" /opt/local/libexec/macports/lib/port1.0/portconfigure.tcl
# Undocumented and unreliable -- https://trac.macports.org/ticket/54332
echo "macosx_deployment_target ${MACOSX_DEPLOYMENT_TARGET:-10.9}" | sudo tee -a /opt/local/etc/macports/macports.conf
# Hail mary option, in case the above does not work
__OPTS="macosx_deployment_target=${MACOSX_DEPLOYMENT_TARGET:-10.9} configure.march=${MARCH:-core2} configure.mtune=${MTUNE:-haswell}"
# Add local Portfile repository
# These take priority over the public repository
echo "Initiating local Portfile repository..."
source macports-ci localports "libs/localports"
# Build dependencies
echo "Installing build dependencies..."
# First install zlib as a source package, since this is a program dependency AND a ccache dependency
sudo port -s -N $__V install zlib $__OPTS
# Now install ccache, so the subsequent packages can use it
sudo port -N $__V install ccache
# Now the rest
sudo port -N $__V install p7zip
sudo port -N $__V install cmake
sudo port -N $__V install pkgconfig
sudo port -N $__V install autoconf
sudo port -N $__V install automake
echo "Installing library dependencies..."
sudo port -s -N $__V install libsdl2 $__OPTS
sudo port -s -N $__V install libsdl2_mixer $__OPTS
sudo port -s -N $__V install libgme $__OPTS
sudo port -s -N $__V install libopenmpt $__OPTS
sudo port -s -N $__V install libpng $__OPTS
# Clean up from earlier
sudo unlink /opt/local/libexec/macports/lib/port1.0/portconfigure.tcl
sudo mv /opt/local/libexec/macports/lib/port1.0/portconfigure.tcl~ /opt/local/libexec/macports/lib/port1.0/portconfigure.tcl
# Clean prefix tree
# https://superuser.com/a/165670
#sudo port -f clean --all all
sudo rm -rf /opt/local/var/macports/build/*
sudo rm -rf /opt/local/var/macports/distfiles/*
sudo rm -rf /opt/local/var/macports/packages/*
sudo port -f uninstall inactive
# Make cache
echo "Making MacPorts cache in $HOME/macports_cache/macports.tar...";
tar -cf $HOME/macports_cache/macports.tar /opt/local
# Set compiler flags
export CFLAGS="$CFLAGS -I/opt/local/include -I/opt/local/include/gme -I/opt/local/include/libopenmpt"
export CXXFLAGS="$CXXFLAGS -I/opt/local/include -I/opt/local/include/gme -I/opt/local/include/libopenmpt"
export LDFLAGS="$LDFLAGS -L/opt/local/lib"
echo "OS X Setup Complete!"