Index: build/jenkins/pipelines/macos-bundle.Jenkinsfile =================================================================== --- /dev/null +++ build/jenkins/pipelines/macos-bundle.Jenkinsfile @@ -0,0 +1,50 @@ +/* Copyright (C) 2019 Wildfire Games. + * This file is part of 0 A.D. + * + * 0 A.D. is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * 0 A.D. is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with 0 A.D. If not, see . + */ + +pipeline { + agent { label 'MacSlave' } + + // Archive the installer for public download; keep only the latest one. + options { + buildDiscarder(logRotator(artifactNumToKeepStr: '1')) + } + + parameters { + booleanParam(name: 'release', defaultValue: false) + } + + stages { + stage("Checkout") { + steps { + svn "https://svn.wildfiregames.com/public/ps/trunk" + sh "svn cleanup" + sh "svn st --no-ignore | cut -c 9- | xargs rm -rf" + } + } + stage("Bundle") { + steps { + sh "cd source/tools/dist && ./build-osx-bundle.sh" + } + } + } + + post { + success { + archiveArtifacts 'build/workspaces/*.dmg' + } + } +} Index: build/jenkins/pipelines/macos-differential.Jenkinsfile =================================================================== --- /dev/null +++ build/jenkins/pipelines/macos-differential.Jenkinsfile @@ -0,0 +1,111 @@ +/* Copyright (C) 2019 Wildfire Games. + * This file is part of 0 A.D. + * + * 0 A.D. is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * 0 A.D. is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with 0 A.D. If not, see . + */ + +pipeline { + agent { label 'MacSlave' } + options { + skipDefaultCheckout() + } + + parameters { + string(name: 'DIFF_ID', defaultValue: '', description: 'ID of the Phabricator Differential.') + string(name: 'PHID', defaultValue: '', description: 'Phabricator ID') + } + + stages { + stage ("Checkout") { + options { + retry(3) + } + steps { + script { + try { + svn "https://svn.wildfiregames.com/public/ps/trunk" + } catch(e) { + sh "svn cleanup" + sleep 300 + throw e + } + } + sh "svn cleanup" + } + } + stage ("Patch") { + steps { + script { + try { + sh "arc patch --diff ${params.DIFF_ID} --force" + } catch (e) { + sh "svn revert -R ." + sh "svn st --no-ignore | cut -c 9- | xargs rm -rf" + sh "arc patch --diff ${params.DIFF_ID} --force" + } + } + } + } + stage("macOS libraries build") { + steps { + sh "cd libraries/osx/ && ./build-osx-libs.sh -j4" + } + } + stage("Update workspaces") { + steps { + sh "cd build/workspaces/ && ./update-workspaces.sh -j4 --atlas --jenkins-tests" + } + } + stage("Debug Build & Tests") { + steps { + sh "cd build/workspaces/gcc/ && make -j4 config=debug" + script { + try { + sh "binaries/system/test_dbg > cxxtest-debug.xml" + } catch (e) { + echo (message: readFile (file: "cxxtest-debug.xml")) + throw e + } finally { + junit "cxxtest-debug.xml" + } + } + } + } + stage("Release Build & Tests") { + steps { + sh "cd build/workspaces/gcc/ && make -j4 config=release" + script { + try { + sh "binaries/system/test > cxxtest-release.xml" + } catch (e) { + echo (message: readFile (file: "cxxtest-release.xml")) + throw e + } finally { + junit "cxxtest-release.xml" + } + } + } + } + } + + post { + always { + step([$class: 'PhabricatorNotifier', commentOnSuccess: true, commentWithConsoleLinkOnFailure: true]) + sh "rm -f cxxtest_*.xml" + sh "svn revert -R ." + sh "svn st binaries/data/ | cut -c 9- | xargs rm -rf" + sh "svn st source/ | cut -c 9- | xargs rm -rf" + } + } +} Index: build/jenkins/pipelines/macos-svn.Jenkinsfile =================================================================== --- /dev/null +++ build/jenkins/pipelines/macos-svn.Jenkinsfile @@ -0,0 +1,92 @@ +/* Copyright (C) 2019 Wildfire Games. + * This file is part of 0 A.D. + * + * 0 A.D. is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * 0 A.D. is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with 0 A.D. If not, see . + */ + +pipeline { + agent { label 'MacSlave' } + + parameters { + string(name: 'SVN_REV', defaultValue: '', description: 'For instance 21000') + string(name: 'PHID', defaultValue: '', description: 'Phabricator ID') + } + + stages { + stage("Checkout") { + options { + // Account for network errors + retry(3) + } + steps { + script { + try { + svn "https://svn.wildfiregames.com/public/ps/trunk@${params.SVN_REV}" + } catch(e) { + sh "svn cleanup" + sleep 300 + throw e + } + } + sh "svn cleanup" + } + } + stage("macOS libraries build") { + steps { + sh "cd libraries/osx/ && ./build-osx-libs.sh -j4" + } + } + stage("Update workspaces") { + steps { + sh "cd build/workspaces/ && ./update-workspaces.sh -j4 --atlas --jenkins-tests" + } + } + stage("Debug Build & Tests") { + steps { + sh "cd build/workspaces/gcc/ && make -j4 config=debug" + script { + try { + sh "binaries/system/test_dbg > cxxtest-debug.xml" + } catch (e) { + echo (message: readFile (file: "cxxtest-debug.xml")) + throw e + } finally { + junit "cxxtest-debug.xml" + } + } + } + } + stage("Release Build & Tests") { + steps { + sh "cd build/workspaces/gcc/ && make -j4 config=release" + script { + try { + sh "binaries/system/test > cxxtest-release.xml" + } catch (e) { + echo (message: readFile (file: "cxxtest-release.xml")) + throw e + } finally { + junit "cxxtest-release.xml" + } + } + } + } + } + + post { + always { + step([$class: 'PhabricatorNotifier']) + } + } +} Index: build/workspaces/build-osx-bundle.sh =================================================================== --- build/workspaces/build-osx-bundle.sh +++ build/workspaces/build-osx-bundle.sh @@ -1,220 +0,0 @@ -#!/bin/sh -# -# This script will build an OS X app bundle for 0 A.D. -# -# App bundles are intended to be self-contained and portable. -# An SDK is required, usually included with Xcode. The SDK ensures -# that only those system libraries are used which are available on -# the chosen target and compatible systems. -# -# Steps to build a 0 A.D. bundle are: -# 1. confirm ARCH is set to desired target architecture -# 2. confirm SYSROOT points to the correct target SDK -# 3. confirm MIN_OSX_VERSION matches the target OS X version -# 4. update BUNDLE_VERSION to match current 0 A.D. version -# 5. run this script -# - -# Force build architecture, as sometimes environment is broken. -# For a universal fat binary, the approach would be to build every -# library with both archs and combine them with lipo, then do the -# same thing with the game itself. -# Choices are "x86_64" or "i386" (ppc and ppc64 not supported) -export ARCH=${ARCH:="x86_64"} - -OSX_VERSION=`sw_vers -productVersion | grep -Eo "^\d+.\d+"` -# Set SDK and mimimum required OS X version -export SYSROOT=${SYSROOT:="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk"} -export MIN_OSX_VERSION=${MIN_OSX_VERSION:="10.9"} - -# 0 A.D. release version, e.g. Alpha 21 is 0.0.21 -BUNDLE_VERSION=${BUNDLE_VERSION:="0.0.X"} - -# Define compiler as "clang", this is all Mavericks supports. -# gcc symlinks may still exist, but they are simply clang with -# slightly different config, which confuses build scripts. -# llvm-gcc and gcc 4.2 are no longer supported by SpiderMonkey. -export CC=${CC:="clang"} CXX=${CXX:="clang++"} - -# Unique identifier string for this bundle (reverse-DNS style) -BUNDLE_IDENTIFIER=${BUNDLE_IDENTIFIER:="com.wildfiregames.0ad"} -# Minimum version of OS X on which the bundle will run -BUNDLE_MIN_OSX_VERSION="${MIN_OSX_VERSION}.0" - -die() -{ - echo ERROR: $* - exit 1 -} - -# Check that we're actually on OS X -if [ "`uname -s`" != "Darwin" ]; then - die "This script is intended for OS X only" -fi - -# Check SDK exists -if [ ! -d "$SYSROOT" ]; then - die "$SYSROOT does not exist! You probably need to install Xcode" -fi - -cd "$(dirname $0)" -# Now in build/workspaces/ (where we assume this script resides) - -JOBS=${JOBS:="-j5"} -build_release=false -build_path="$HOME/0ad-export" -# TODO: proper logging of all output, but show errors in terminal too -build_log="$(pwd)/bundle-build.log" - -# Parse command-line options: -for i in "$@" -do - case $i in - -j* ) JOBS=$i ;; - --release ) build_release=true ;; - esac -done - -rm -f $build_log - -# For release, export an SVN copy -if [ "$build_release" = "true" ]; then - echo "\nExporting SVN and preparing release\n" - - BUNDLE_OUTPUT="$build_path/0ad.app" - SVN_REV=`svnversion -n ../..` - rm -rf $build_path - svn export ../.. $build_path >> $build_log 2>&1 || die "Error exporting SVN working directory" - cd $build_path - rm -f binaries/data/config/dev.cfg - # Only include translations for a subset of languages - . source/tools/dist/remove-incomplete-translations.sh $build_path/binaries/data || die "Error excluding translations" - echo L\"${SVN_REV}-release\" > build/svn_revision/svn_revision.txt - cd build/workspaces -fi - -BUNDLE_OUTPUT=${BUNDLE_OUTPUT:="$(pwd)/0ad.app"} -BUNDLE_CONTENTS=$BUNDLE_OUTPUT/Contents -BUNDLE_BIN=$BUNDLE_CONTENTS/MacOS -BUNDLE_RESOURCES=$BUNDLE_CONTENTS/Resources -BUNDLE_FRAMEWORKS=$BUNDLE_CONTENTS/Frameworks -BUNDLE_PLUGINS=$BUNDLE_CONTENTS/PlugIns -BUNDLE_SHAREDSUPPORT=$BUNDLE_CONTENTS/SharedSupport - -# TODO: Do we really want to regenerate everything? (consider if one task fails) - -# Build libraries against SDK -echo "\nBuilding libraries\n" -pushd ../../libraries/osx > /dev/null -./build-osx-libs.sh $JOBS --force-rebuild >> $build_log 2>&1 || die "Libraries build script failed" -popd > /dev/null - -# Clean and update workspaces -echo "\nGenerating workspaces\n" - -# Pass OS X options through to Premake -(./clean-workspaces.sh && SYSROOT="$SYSROOT" MIN_OSX_VERSION="$MIN_OSX_VERSION" ./update-workspaces.sh --macosx-bundle="$BUNDLE_IDENTIFIER" --sysroot="$SYSROOT" --macosx-version-min="$MIN_OSX_VERSION") >> $build_log 2>&1 || die "update-workspaces.sh failed!" - -pushd gcc > /dev/null -echo "\nBuilding game\n" -(make clean && CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" make ${JOBS}) >> $build_log 2>&1 || die "Game build failed!" -popd > /dev/null - -# Run test to confirm all is OK -# TODO: tests are currently broken on OS X (see http://trac.wildfiregames.com/ticket/2780) -#pushd ../../binaries/system > /dev/null -#echo "\nRunning tests\n" -#./test || die "Post-build testing failed!" -#popd > /dev/null - -# Create bundle structure -echo "\nCreating bundle directories\n" -rm -rf ${BUNDLE_OUTPUT} -mkdir -p ${BUNDLE_BIN} -mkdir -p ${BUNDLE_FRAMEWORKS} -mkdir -p ${BUNDLE_PLUGINS} -mkdir -p ${BUNDLE_RESOURCES} -mkdir -p ${BUNDLE_SHAREDSUPPORT} - -# Build archive(s) - don't archive the _test.* mods -pushd ../../binaries/data/mods > /dev/null -archives="" -for modname in [a-zA-Z0-9]* -do - archives="${archives} ${modname}" -done -popd > /dev/null - -pushd ../../binaries/system > /dev/null - -for modname in $archives -do - echo "\nBuilding archive for '${modname}'\n" - ARCHIVEBUILD_INPUT="$(pwd)/../data/mods/${modname}" - ARCHIVEBUILD_OUTPUT="${BUNDLE_RESOURCES}/data/mods/${modname}" - - # For some reason the output directory has to exist? - mkdir -p ${ARCHIVEBUILD_OUTPUT} - - (./pyrogenesis -archivebuild=${ARCHIVEBUILD_INPUT} -archivebuild-output=${ARCHIVEBUILD_OUTPUT}/${modname}.zip) >> $build_log 2>&1 || die "Archive build for '${modname}' failed!" -done - -# Copy binaries -echo "\nCopying binaries\n" -# Only pyrogenesis for now, until we find a way to load -# multiple binaries from one app bundle -# TODO: Would be nicer if we could set this path in premake -cp pyrogenesis ${BUNDLE_BIN} - -# Copy libs -echo "\nCopying libs\n" -# TODO: Would be nicer if we could set this path in premake -cp -v libAtlasUI.dylib ${BUNDLE_FRAMEWORKS} -cp -v libCollada.dylib ${BUNDLE_FRAMEWORKS} - -popd > /dev/null - -# Copy data -echo "\nCopying non-archived game data\n" -pushd ../../binaries/data > /dev/null -if [ "$build_release" = "false" ]; then - mv config/dev.cfg config/dev.bak -fi -cp -R -v config ${BUNDLE_RESOURCES}/data/ -cp -R -v l10n ${BUNDLE_RESOURCES}/data/ -cp -R -v tools ${BUNDLE_RESOURCES}/data/ -if [ "$build_release" = "false" ]; then - mv config/dev.bak config/dev.cfg -fi -popd > /dev/null -cp -v ../resources/0ad.icns ${BUNDLE_RESOURCES} - -# Copy license/readmes -# TODO: Also want copies in the DMG - decide on layout -echo "\nCopying readmes\n" -cp -v ../../*.txt ${BUNDLE_RESOURCES} -cp -v ../../libraries/LICENSE.txt ${BUNDLE_RESOURCES}/LIB_LICENSE.txt - -# Create Info.plist -echo "\nCreating Info.plist\n" -alias PlistBuddy=/usr/libexec/PlistBuddy -INFO_PLIST="${BUNDLE_CONTENTS}/Info.plist" - -PlistBuddy -c "Add :CFBundleName string 0 A.D." ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleIdentifier string ${BUNDLE_IDENTIFIER}" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleVersion string ${BUNDLE_VERSION}" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundlePackageType string APPL" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleSignature string none" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleExecutable string pyrogenesis" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleShortVersionString string ${BUNDLE_VERSION}" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleDevelopmentRegion string English" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleInfoDictionaryVersion string 6.0" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleIconFile string 0ad" ${INFO_PLIST} -PlistBuddy -c "Add :LSMinimumSystemVersion string ${BUNDLE_MIN_OSX_VERSION}" ${INFO_PLIST} -PlistBuddy -c "Add :NSHumanReadableCopyright string Copyright © $(date +%Y) Wildfire Games" ${INFO_PLIST} - -# TODO: Automatically create compressed DMG with hdiutil? -# (this is a bit complicated so I do it manually for now) -# (also we need to have good icon placement, background image, etc) - -echo "\nBundle complete! Located in ${BUNDLE_OUTPUT}" Index: build/workspaces/clean-workspaces.sh =================================================================== --- build/workspaces/clean-workspaces.sh +++ build/workspaces/clean-workspaces.sh @@ -27,7 +27,9 @@ cd "$(dirname $0)" # Now in build/workspaces/ (where we assume this script resides) -if [ "$preserve_libs" != "true" ]; then +# We don't build bundled libs with update-workspaces.sh on macOS, +# so we shouldn't clean them up here. +if [ "$preserve_libs" != "true" ] && [ "`uname -s`" != "Darwin" ]; then echo "Cleaning bundled third-party dependencies..." (cd ../../libraries/source/fcollada/src && rm -rf ./output) Index: libraries/osx/build-osx-libs.sh =================================================================== --- libraries/osx/build-osx-libs.sh +++ libraries/osx/build-osx-libs.sh @@ -344,6 +344,7 @@ --prefix="$INSTALL_DIR" \ --disable-video-x11 \ --without-x \ + --enable-video-cocoa \ --enable-shared=no \ && make $JOBS && make install) || die "SDL2 build failed" popd @@ -959,6 +960,7 @@ mkdir -p $INCLUDE_DIR_DEBUG cp -R -L dist/include/* $INCLUDE_DIR_DEBUG/ cp dist/sdk/lib/*.a $INSTALL_DIR/lib + cp js/src/*.a $INSTALL_DIR/lib popd mv moz.build.bak moz.build Index: source/tools/dist/build-osx-bundle.sh =================================================================== --- source/tools/dist/build-osx-bundle.sh +++ source/tools/dist/build-osx-bundle.sh @@ -7,35 +7,24 @@ # that only those system libraries are used which are available on # the chosen target and compatible systems. # -# Steps to build a 0 A.D. bundle are: -# 1. confirm ARCH is set to desired target architecture -# 2. confirm SYSROOT points to the correct target SDK -# 3. confirm MIN_OSX_VERSION matches the target OS X version -# 4. update BUNDLE_VERSION to match current 0 A.D. version -# 5. run this script -# # Force build architecture, as sometimes environment is broken. # For a universal fat binary, the approach would be to build every # library with both archs and combine them with lipo, then do the # same thing with the game itself. -# Choices are "x86_64" or "i386" (ppc and ppc64 not supported) +# Choices are "x86_64" or "i386" (ppc and ppc64 not supported) export ARCH=${ARCH:="x86_64"} -OSX_VERSION=`sw_vers -productVersion | grep -Eo "^\d+.\d+"` -# Set SDK and mimimum required OS X version -export SYSROOT=${SYSROOT:="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk"} +# Set mimimum required OS X version, SDK location and tools +# Old SDKs can be found at https://github.com/phracker/MacOSX-SDKs export MIN_OSX_VERSION=${MIN_OSX_VERSION:="10.9"} - -# 0 A.D. release version, e.g. Alpha 21 is 0.0.21 -BUNDLE_VERSION=${BUNDLE_VERSION:="0.0.X"} - -# Define compiler as "clang", this is all Mavericks supports. -# gcc symlinks may still exist, but they are simply clang with -# slightly different config, which confuses build scripts. -# llvm-gcc and gcc 4.2 are no longer supported by SpiderMonkey. +export SYSROOT=${SYSROOT:="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${MIN_OSX_VERSION}.sdk"} export CC=${CC:="clang"} CXX=${CXX:="clang++"} +# 0 A.D. release version +BUNDLE_VERSION=${BUNDLE_VERSION:="0.0.24dev"} +BUNDLE_FILENAME="0ad-${BUNDLE_VERSION}-alpha-osx64.dmg" + # Unique identifier string for this bundle (reverse-DNS style) BUNDLE_IDENTIFIER=${BUNDLE_IDENTIFIER:="com.wildfiregames.0ad"} # Minimum version of OS X on which the bundle will run @@ -57,14 +46,12 @@ die "$SYSROOT does not exist! You probably need to install Xcode" fi -cd "$(dirname $0)" -# Now in build/workspaces/ (where we assume this script resides) +# We assume this script resides in source/tools/dist/ +DMGBUILD_CONFIG="$(pwd)/dmgbuild-settings.py" +cd "$(dirname $0)/../../../build/workspaces/" JOBS=${JOBS:="-j5"} build_release=false -build_path="$HOME/0ad-export" -# TODO: proper logging of all output, but show errors in terminal too -build_log="$(pwd)/bundle-build.log" # Parse command-line options: for i in "$@" @@ -75,17 +62,14 @@ esac done -rm -f $build_log - # For release, export an SVN copy if [ "$build_release" = "true" ]; then echo "\nExporting SVN and preparing release\n" - BUNDLE_OUTPUT="$build_path/0ad.app" SVN_REV=`svnversion -n ../..` - rm -rf $build_path - svn export ../.. $build_path >> $build_log 2>&1 || die "Error exporting SVN working directory" - cd $build_path + rm -rf "0ad-export" + svn export ../.. "0ad-export" || die "Error exporting SVN working directory" + cd "0ad-export" rm -f binaries/data/config/dev.cfg # Only include translations for a subset of languages . source/tools/dist/remove-incomplete-translations.sh $build_path/binaries/data || die "Error excluding translations" @@ -93,7 +77,9 @@ cd build/workspaces fi -BUNDLE_OUTPUT=${BUNDLE_OUTPUT:="$(pwd)/0ad.app"} +BUNDLE_APP="0 A.D..app" +BUNDLE_DMG_NAME="0 A.D." +BUNDLE_OUTPUT=${BUNDLE_OUTPUT:="$(pwd)/${BUNDLE_APP}"} BUNDLE_CONTENTS=$BUNDLE_OUTPUT/Contents BUNDLE_BIN=$BUNDLE_CONTENTS/MacOS BUNDLE_RESOURCES=$BUNDLE_CONTENTS/Resources @@ -106,35 +92,34 @@ # Build libraries against SDK echo "\nBuilding libraries\n" pushd ../../libraries/osx > /dev/null -./build-osx-libs.sh $JOBS --force-rebuild >> $build_log 2>&1 || die "Libraries build script failed" +./build-osx-libs.sh $JOBS --force-rebuild || die "Libraries build script failed" popd > /dev/null # Clean and update workspaces echo "\nGenerating workspaces\n" # Pass OS X options through to Premake -(./clean-workspaces.sh && SYSROOT="$SYSROOT" MIN_OSX_VERSION="$MIN_OSX_VERSION" ./update-workspaces.sh --macosx-bundle="$BUNDLE_IDENTIFIER" --sysroot="$SYSROOT" --macosx-version-min="$MIN_OSX_VERSION") >> $build_log 2>&1 || die "update-workspaces.sh failed!" +(./clean-workspaces.sh && SYSROOT="$SYSROOT" MIN_OSX_VERSION="$MIN_OSX_VERSION" ./update-workspaces.sh --macosx-bundle="$BUNDLE_IDENTIFIER" --sysroot="$SYSROOT" --macosx-version-min="$MIN_OSX_VERSION") || die "update-workspaces.sh failed!" pushd gcc > /dev/null echo "\nBuilding game\n" -(make clean && CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" make ${JOBS}) >> $build_log 2>&1 || die "Game build failed!" +(make clean && CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" make ${JOBS}) || die "Game build failed!" popd > /dev/null # Run test to confirm all is OK -# TODO: tests are currently broken on OS X (see http://trac.wildfiregames.com/ticket/2780) -#pushd ../../binaries/system > /dev/null -#echo "\nRunning tests\n" -#./test || die "Post-build testing failed!" -#popd > /dev/null +pushd ../../binaries/system > /dev/null +echo "\nRunning tests\n" +./test || die "Post-build testing failed!" +popd > /dev/null # Create bundle structure echo "\nCreating bundle directories\n" -rm -rf ${BUNDLE_OUTPUT} -mkdir -p ${BUNDLE_BIN} -mkdir -p ${BUNDLE_FRAMEWORKS} -mkdir -p ${BUNDLE_PLUGINS} -mkdir -p ${BUNDLE_RESOURCES} -mkdir -p ${BUNDLE_SHAREDSUPPORT} +rm -rf "${BUNDLE_OUTPUT}" +mkdir -p "${BUNDLE_BIN}" +mkdir -p "${BUNDLE_FRAMEWORKS}" +mkdir -p "${BUNDLE_PLUGINS}" +mkdir -p "${BUNDLE_RESOURCES}" +mkdir -p "${BUNDLE_SHAREDSUPPORT}" # Build archive(s) - don't archive the _test.* mods pushd ../../binaries/data/mods > /dev/null @@ -154,9 +139,9 @@ ARCHIVEBUILD_OUTPUT="${BUNDLE_RESOURCES}/data/mods/${modname}" # For some reason the output directory has to exist? - mkdir -p ${ARCHIVEBUILD_OUTPUT} + mkdir -p "${ARCHIVEBUILD_OUTPUT}" - (./pyrogenesis -archivebuild=${ARCHIVEBUILD_INPUT} -archivebuild-output=${ARCHIVEBUILD_OUTPUT}/${modname}.zip) >> $build_log 2>&1 || die "Archive build for '${modname}' failed!" + (./pyrogenesis -archivebuild="${ARCHIVEBUILD_INPUT}" -archivebuild-output="${ARCHIVEBUILD_OUTPUT}/${modname}.zip") || die "Archive build for '${modname}' failed!" done # Copy binaries @@ -164,13 +149,13 @@ # Only pyrogenesis for now, until we find a way to load # multiple binaries from one app bundle # TODO: Would be nicer if we could set this path in premake -cp pyrogenesis ${BUNDLE_BIN} +cp pyrogenesis "${BUNDLE_BIN}" # Copy libs echo "\nCopying libs\n" # TODO: Would be nicer if we could set this path in premake -cp -v libAtlasUI.dylib ${BUNDLE_FRAMEWORKS} -cp -v libCollada.dylib ${BUNDLE_FRAMEWORKS} +cp -v libAtlasUI.dylib "${BUNDLE_FRAMEWORKS}" +cp -v libCollada.dylib "${BUNDLE_FRAMEWORKS}" popd > /dev/null @@ -180,41 +165,45 @@ if [ "$build_release" = "false" ]; then mv config/dev.cfg config/dev.bak fi -cp -R -v config ${BUNDLE_RESOURCES}/data/ -cp -R -v l10n ${BUNDLE_RESOURCES}/data/ -cp -R -v tools ${BUNDLE_RESOURCES}/data/ +cp -R -v config "${BUNDLE_RESOURCES}/data/" +cp -R -v l10n "${BUNDLE_RESOURCES}/data/" +cp -R -v tools "${BUNDLE_RESOURCES}/data/" if [ "$build_release" = "false" ]; then mv config/dev.bak config/dev.cfg fi popd > /dev/null -cp -v ../resources/0ad.icns ${BUNDLE_RESOURCES} +cp -v ../resources/0ad.icns "${BUNDLE_RESOURCES}" # Copy license/readmes # TODO: Also want copies in the DMG - decide on layout echo "\nCopying readmes\n" -cp -v ../../*.txt ${BUNDLE_RESOURCES} -cp -v ../../libraries/LICENSE.txt ${BUNDLE_RESOURCES}/LIB_LICENSE.txt +cp -v ../../*.txt "${BUNDLE_RESOURCES}" +cp -v ../../libraries/LICENSE.txt "${BUNDLE_RESOURCES}/LIB_LICENSE.txt" # Create Info.plist echo "\nCreating Info.plist\n" alias PlistBuddy=/usr/libexec/PlistBuddy INFO_PLIST="${BUNDLE_CONTENTS}/Info.plist" -PlistBuddy -c "Add :CFBundleName string 0 A.D." ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleIdentifier string ${BUNDLE_IDENTIFIER}" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleVersion string ${BUNDLE_VERSION}" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundlePackageType string APPL" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleSignature string none" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleExecutable string pyrogenesis" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleShortVersionString string ${BUNDLE_VERSION}" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleDevelopmentRegion string English" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleInfoDictionaryVersion string 6.0" ${INFO_PLIST} -PlistBuddy -c "Add :CFBundleIconFile string 0ad" ${INFO_PLIST} -PlistBuddy -c "Add :LSMinimumSystemVersion string ${BUNDLE_MIN_OSX_VERSION}" ${INFO_PLIST} -PlistBuddy -c "Add :NSHumanReadableCopyright string Copyright © $(date +%Y) Wildfire Games" ${INFO_PLIST} - -# TODO: Automatically create compressed DMG with hdiutil? -# (this is a bit complicated so I do it manually for now) -# (also we need to have good icon placement, background image, etc) +PlistBuddy -c "Add :CFBundleName string 0 A.D." "${INFO_PLIST}" +PlistBuddy -c "Add :CFBundleIdentifier string ${BUNDLE_IDENTIFIER}" "${INFO_PLIST}" +PlistBuddy -c "Add :CFBundleVersion string ${BUNDLE_VERSION}" "${INFO_PLIST}" +PlistBuddy -c "Add :CFBundlePackageType string APPL" "${INFO_PLIST}" +PlistBuddy -c "Add :CFBundleSignature string none" "${INFO_PLIST}" +PlistBuddy -c "Add :CFBundleExecutable string pyrogenesis" "${INFO_PLIST}" +PlistBuddy -c "Add :CFBundleShortVersionString string ${BUNDLE_VERSION}" "${INFO_PLIST}" +PlistBuddy -c "Add :CFBundleDevelopmentRegion string English" "${INFO_PLIST}" +PlistBuddy -c "Add :CFBundleInfoDictionaryVersion string 6.0" "${INFO_PLIST}" +PlistBuddy -c "Add :CFBundleIconFile string 0ad" "${INFO_PLIST}" +PlistBuddy -c "Add :LSMinimumSystemVersion string ${BUNDLE_MIN_OSX_VERSION}" "${INFO_PLIST}" +PlistBuddy -c "Add :NSHumanReadableCopyright string Copyright © $(date +%Y) Wildfire Games" "${INFO_PLIST}" + +# Package the app into a dmg +dmgbuild \ + -s "${DMGBUILD_CONFIG}" \ + -D app="${BUNDLE_OUTPUT}" \ + -D background="../../build/resources/dmgbackground.png" \ + "${BUNDLE_DMG_NAME}" "${BUNDLE_FILENAME}" + -echo "\nBundle complete! Located in ${BUNDLE_OUTPUT}" +echo "\nBundle complete! Located in ${BUNDLE_OUTPUT}, compressed as ${BUNDLE_FILENAME}." Index: source/tools/dist/dmgbuild-settings.py =================================================================== --- /dev/null +++ source/tools/dist/dmgbuild-settings.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- +import biplist +import os.path + +# +# 0 A.D. settings file for dmgbuild +# + +# Use like this: +# dmgbuild -s settings.py -D app=/path/to/My.app -D background=/path/to/background.png "My Application" MyApp.dmg + +application = defines.get('app') + + +def icon_from_app(app_path): + plist_path = os.path.join(app_path, 'Contents', 'Info.plist') + plist = biplist.readPlist(plist_path) + icon_name = plist['CFBundleIconFile'] + icon_root,icon_ext = os.path.splitext(icon_name) + if not icon_ext: + icon_ext = '.icns' + icon_name = icon_root + icon_ext + return os.path.join(app_path, 'Contents', 'Resources', icon_name) + +# .. Basics .................................................................... + +# Volume format (see hdiutil create -help) +format = defines.get('format', 'UDBZ') + +# Volume size +size = defines.get('size', '3G') + +# Files to include +files = [ application ] + +# Symlinks to create +symlinks = { 'Applications': '/Applications' } + +# Volume icon +# +# You can either define icon, in which case that icon file will be copied to the +# image, *or* you can define badge_icon, in which case the icon file you specify +# will be used to badge the system's Removable Disk icon +# +#icon = '/path/to/icon.icns' +badge_icon = icon_from_app(application) + +# Where to put the icons +icon_locations = { + os.path.basename(application): (125, 170), + 'Applications': (475, 170) +} + +# .. Window configuration ...................................................... + +# Background +background = defines.get('background') + +show_status_bar = False +show_tab_view = False +show_toolbar = False +show_pathbar = False +show_sidebar = False +sidebar_width = 0 + +# Window position in ((x, y), (w, h)) format +window_rect = ((0, 0), (600, 393)) + +# Select the default view; must be one of +# +# 'icon-view' +# 'list-view' +# 'column-view' +# 'coverflow' +# +default_view = 'icon-view' + +# General view configuration +show_icon_preview = False + +# Set these to True to force inclusion of icon/list view settings (otherwise +# we only include settings for the default view) +include_icon_view_settings = 'auto' +include_list_view_settings = 'auto' + +# .. Icon view configuration ................................................... + +arrange_by = None +grid_offset = (0, 0) +grid_spacing = 100 +scroll_position = (0, 0) +label_pos = 'bottom' # or 'right' +text_size = 12 +icon_size = 90 + +# .. List view configuration ................................................... + +# Column names are as follows: +# +# name +# date-modified +# date-created +# date-added +# date-last-opened +# size +# kind +# label +# version +# comments +# +list_icon_size = 16 +list_text_size = 12 +list_scroll_position = (0, 0) +list_sort_by = 'name' +list_use_relative_dates = True +list_calculate_all_sizes = False, +list_columns = ('name', 'date-modified', 'size', 'kind', 'date-added') +list_column_widths = { + 'name': 300, + 'date-modified': 181, + 'date-created': 181, + 'date-added': 181, + 'date-last-opened': 181, + 'size': 97, + 'kind': 115, + 'label': 100, + 'version': 75, + 'comments': 300, +} +list_column_sort_directions = { + 'name': 'ascending', + 'date-modified': 'descending', + 'date-created': 'descending', + 'date-added': 'descending', + 'date-last-opened': 'descending', + 'size': 'descending', + 'kind': 'ascending', + 'label': 'ascending', + 'version': 'ascending', + 'comments': 'ascending', +} + +# .. License configuration ..................................................... + +# TODO: Use licenses from the app bundle.