commit 5f5096208952bf6b9d138c042d9ce03085c79fc3 Author: Antonin Décimo Date: Tue Nov 5 19:27:10 2013 +0100 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..4cad2c6 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +### SYNOPSIS +`love-release.sh [OPTIONS] [FILES...]` + +### DESCRIPTION +You can use love-release.sh to generate Love2D executables for Linux, OS X, Windows (x86 and x86_64), +as specified in love2d.org. +An Internet connection is required. The script uses wget, zip and unzip commands. + +By default, the script generates releases for every system. But if you add options, +it will generate releases only for the specified systems. + +A directory (default is `./releases`) will be created, and filled with the zipped releases: +`YourGame-win-x86.zip`, `YourGame-win-x64.zip`, `YourGame-osx.zip` and `YourGame.love`. + +### OPTIONS +- *-h*, help +- *-l*, generates a .love file +- *-m*, generates a Mac OS X app +- *-w*, generates Windows x86 and x86_64 executables + - *-w32*, generates Windows x86 executable + - *-w64*, generates Windows x86_64 executable +- *-n*, project's name. By default, the directory's name is used +- *-r*, release directory. By default, a subdirectory called 'releases' is created +- *-u*, company name. Provide it for OSX CFBundleIdentifier, otherwise USER is used +- *-v*, love version. Default is 0.8.0. Prior to it, no special Win64 version is available + +### SEE ALSO +- [https://www.love2d.org](https://www.love2d.org) +- [https://www.love2d.org/wiki/Game_Distribution](https://www.love2d.org/wiki/Game_Distribution) diff --git a/love-release.sh b/love-release.sh new file mode 100755 index 0000000..49d55db --- /dev/null +++ b/love-release.sh @@ -0,0 +1,339 @@ +#!/bin/bash + +HELP="### Generates Love2D Game releases ### + +SYNOPSIS + love-release.sh [OPTIONS] [FILES...] + +DESCRIPTION + You can use love-release.sh to generate Love2D executables for Linux, OS X, Windows (x86 and x86_64), as specified in love2d.org. + An Internet connection is required. The script uses wget, zip and unzip commands. + + By default, the script generates releases for every system. But if you add options, + it will generate releases only for the specified systems. + + A directory (default is './releases') will be created, and filled with the zipped releases: + 'YourGame-win-x86.zip', 'YourGame-win-x64.zip', 'YourGame-osx.zip' and 'YourGame.love'. + +OPTIONS + -h, print this help + + -l, generates a .love file + -m, generates a Mac OS X app + -w, generates Windows x86 and x86_64 executables + -w32, generates Windows x86 executable + -w64, generates Windows x86_64 executable + + -n, project's name. By default, the directory's name is used + -r, release directory. By default, a subdirectory called 'releases' is created + -u, company name. Provide it for OSX CFBundleIdentifier, otherwise USER is used + -v, love version. Default is 0.8.0. Prior to it, no special Win64 version is available + +SEE ALSO + https://www.love2d.org + https://www.love2d.org/wiki/Game_Distribution + https://www.github.org/MisterDA/love-release +" + + +## Test if requirements are installed ## +command -v wget >/dev/null 2>&1 || { echo "wget is not installed. Aborting." >&2; exit 1; } +command -v zip >/dev/null 2>&1 || { echo "zip is not installed. Aborting." >&2; exit 1; } +command -v unzip >/dev/null 2>&1 || { echo "unzip is not installed. Aborting." >&2; exit 1; } + + +## Parsing functions ## +function getoptex() +{ + let $# || return 1 + local optlist="${1#;}" + let OPTIND || OPTIND=1 + [ $OPTIND -lt $# ] || return 1 + shift $OPTIND + if [ "$1" != "-" ] && [ "$1" != "${1#-}" ] + then OPTIND=$[OPTIND+1]; if [ "$1" != "--" ] + then + local o + o="-${1#-$OPTOFS}" + for opt in ${optlist#;} + do + OPTOPT="${opt%[;.:]}" + unset OPTARG + local opttype="${opt##*[^;:.]}" + [ -z "$opttype" ] && opttype=";" + if [ ${#OPTOPT} -gt 1 ] + then # long-named option + case $o in + "--$OPTOPT") + if [ "$opttype" != ":" ]; then return 0; fi + OPTARG="$2" + if [ -z "$OPTARG" ]; + then # error: must have an agrument + let OPTERR && echo "$0: error: $OPTOPT must have an argument" >&2 + OPTARG="$OPTOPT"; + OPTOPT="?" + return 1; + fi + OPTIND=$[OPTIND+1] # skip option's argument + return 0 + ;; + "--$OPTOPT="*) + if [ "$opttype" = ";" ]; + then # error: must not have arguments + let OPTERR && echo "$0: error: $OPTOPT must not have arguments" >&2 + OPTARG="$OPTOPT" + OPTOPT="?" + return 1 + fi + OPTARG=${o#"--$OPTOPT="} + return 0 + ;; + esac + else # short-named option + case "$o" in + "-$OPTOPT") + unset OPTOFS + [ "$opttype" != ":" ] && return 0 + OPTARG="$2" + if [ -z "$OPTARG" ] + then + echo "$0: error: -$OPTOPT must have an argument" >&2 + OPTARG="$OPTOPT" + OPTOPT="?" + return 1 + fi + OPTIND=$[OPTIND+1] # skip option's argument + return 0 + ;; + "-$OPTOPT"*) + if [ $opttype = ";" ] + then # an option with no argument is in a chain of options + OPTOFS="$OPTOFS?" # move to the next option in the chain + OPTIND=$[OPTIND-1] # the chain still has other options + return 0 + else + unset OPTOFS + OPTARG="${o#-$OPTOPT}" + return 0 + fi + ;; + esac + fi + done + echo "$0: error: invalid option: $o" + fi; fi + OPTOPT="?" + unset OPTARG + return 1 +} +function optlistex +{ + local l="$1" + local m # mask + local r # to store result + while [ ${#m} -lt $[${#l}-1] ]; do m="$m?"; done # create a "???..." mask + while [ -n "$l" ] + do + r="${r:+"$r "}${l%$m}" # append the first character of $l to $r + l="${l#?}" # cut the first charecter from $l + m="${m#?}" # cut one "?" sign from m + if [ -n "${l%%[^:.;]*}" ] + then # a special character (";", ".", or ":") was found + r="$r${l%$m}" # append it to $r + l="${l#?}" # cut the special character from l + m="${m#?}" # cut one more "?" sign + fi + done + echo $r +} +function getopt() +{ + local optlist=`optlistex "$1"` + shift + getoptex "$optlist" "$@" + return $? +} + + +## Set defaults ## +RELEASE_LOVE=false +RELEASE_OSX=false +RELEASE_WIN_32=false +RELEASE_WIN_64=false +PROJECT_NAME=${PWD##/*/} +RELEASE_DIR=$PWD/releases +COMPANY_NAME=$USER +LOVE_VERSION=0.8.0 + + +## Parsing options ## +while getopt "hlmw.n:r:u:v:" "$@" +do + if [ $OPTOPT = "h" ]; then # print help + echo "$HELP" + exit + elif [ $OPTOPT = "l" ]; then + RELEASE_LOVE=true + elif [ $OPTOPT = "m" ]; then + RELEASE_OSX=true + elif [ $OPTOPT = "w" ]; then + if [ $OPTARG = "32" ]; then + RELEASE_WIN_32=true + elif [ $OPTARG = "64" ]; then + RELEASE_WIN_64=true + else + RELEASE_WIN_32=true + RELEASE_WIN_64=true + fi + elif [ $OPTOPT = "n" ]; then + PROJECT_NAME=$OPTARG + elif [ $OPTOPT = "r" ]; then + RELEASE_DIR=$OPTARG + elif [ $OPTOPT = "u" ]; then + COMPANY_NAME=$OPTARG + elif [ $OPTOPT = "v" ]; then + LOVE_VERSION=$OPTARG + fi +done +shift $[OPTIND-1] +for file in "$@" +do + PROJECT_FILES="$PROJECT_FILES $file" +done +if [ $RELEASE_LOVE = false ] && [ $RELEASE_OSX = false ] && [ $RELEASE_WIN_32 = false ] && [ $RELEASE_WIN_64 = false ]; then + RELEASE_LOVE=true + RELEASE_OSX=true + RELEASE_WIN_32=true + RELEASE_WIN_64=true +fi +LOVE_SUPPORT_WIN_64=`echo "${LOVE_VERSION#[0-9]\.}>=8.0" | bc` + + +## Releases generation ## +mkdir -p $RELEASE_DIR + +rm -rf $RELEASE_DIR/$PROJECT_NAME.love 2> /dev/null +if [ -z $PROJECT_FILES ]; then + zip -r $RELEASE_DIR/$PROJECT_NAME.love -x $0 ${RELEASE_DIR##/*/}/ ${RELEASE_DIR##/*/}/* @ * +else + zip -r $RELEASE_DIR/$PROJECT_NAME.love -x $0 ${RELEASE_DIR##/*/}/ ${RELEASE_DIR##/*/}/* @ $PROJECT_FILES +fi +cd $RELEASE_DIR + + +## Windows 32-bits ## +if [ $RELEASE_WIN_32 = true ]; then + wget https://bitbucket.org/rude/love/downloads/love-$LOVE_VERSION-win-x86.zip + unzip -qq love-$LOVE_VERSION-win-x86.zip + rm -rf $PROJECT_NAME-win-x86.zip 2> /dev/null + cat love-$LOVE_VERSION-win-x86/love.exe $PROJECT_NAME.love > love-$LOVE_VERSION-win-x86/$PROJECT_NAME.exe + rm love-$LOVE_VERSION-win-x86/love.exe + zip -qr $PROJECT_NAME-win-x86.zip love-$LOVE_VERSION-win-x86 + rm -rf love-$LOVE_VERSION-win-x86.zip love-$LOVE_VERSION-win-x86 +fi + +## Windows 64-bits ## +if [ $LOVE_SUPPORT_WIN_64 = "1" ] && [ $RELEASE_WIN_64 = true ]; then + wget https://bitbucket.org/rude/love/downloads/love-$LOVE_VERSION-win-x64.zip + unzip -qq love-$LOVE_VERSION-win-x64.zip + rm -rf $PROJECT_NAME-win-x64.zip 2> /dev/null + cat love-$LOVE_VERSION-win-x64/love.exe $PROJECT_NAME.love > love-$LOVE_VERSION-win-x64/$PROJECT_NAME.exe + rm love-$LOVE_VERSION-win-x64/love.exe + zip -qr $PROJECT_NAME-win-x64.zip love-$LOVE_VERSION-win-x64 + rm -rf love-$LOVE_VERSION-win-x64.zip love-$LOVE_VERSION-win-x64 +fi + +## Mac OS X ## +if [ $RELEASE_OSX = true ]; then + wget https://bitbucket.org/rude/love/downloads/love-$LOVE_VERSION-macosx-ub.zip + unzip -qq love-$LOVE_VERSION-macosx-ub.zip + rm -rf $PROJECT_NAME.app 2> /dev/null + mv love.app $PROJECT_NAME.app + cp $PROJECT_NAME.love $PROJECT_NAME.app/Contents/Resources +echo ' + + + + BuildMachineOSBuild + 11D50b + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeIconFile + LoveDocument.icns + CFBundleTypeName + LÖVE Project + CFBundleTypeRole + Viewer + LSHandlerRank + Owner + LSItemContentTypes + + org.love2d.love-game + + + + CFBundleTypeName + Folder + CFBundleTypeOSTypes + + fold + + CFBundleTypeRole + Viewer + LSHandlerRank + None + + + CFBundleExecutable + love + CFBundleIconFile + Love.icns + CFBundleIdentifier + com.$COMPANY_NAME.$PROJECT_NAME + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $PROJECT_NAME + CFBundlePackageType + APPL + CFBundleShortVersionString + $LOVE_VERSION + CFBundleSignature + LoVe + DTCompiler + + DTPlatformBuild + 4E2002 + DTPlatformVersion + GM + DTSDKBuild + 11D50a + DTSDKName + macosx10.7 + DTXcode + 0432 + DTXcodeBuild + 4E2002 + NSHumanReadableCopyright + © 2006-2012 LÖVE Development Team + NSMainNibFile + SDLMain + NSPrincipalClass + NSApplication + + +' > $PROJECT_NAME.app/Contents/Info.plist + zip -qr $PROJECT_NAME-osx.zip $PROJECT_NAME.app + rm -rf love-$LOVE_VERSION-macosx-ub.zip $PROJECT_NAME.app +fi + +## Love file ## +if [ $RELEASE_LOVE = false ] +then + rm $PROJECT_NAME.love +fi + +echo "Done !"