Options can be prefixed for a specific module

Options can now be prefixed to be used only for the module the prefix
corresponds to. For example `--author` will set the author's name for
the whole project, but `--Wauthor` will set it for Windows only and
`--Dauthor` for Debian only.

If a module requires new options, they will be automatically prefixed at
compilation.
Most of the modules options have been renamed for consistency.

The `read_option` function was added to parse the default options.
It can use a prefix to parse the options for a module.

Each module now has a specific directory in the cache to allow
per-module cache cleaning.
This commit is contained in:
Antonin Décimo
2015-06-23 22:24:13 +02:00
parent 63bb8cc807
commit 979ddf5719
4 changed files with 116 additions and 90 deletions

View File

@@ -10,12 +10,16 @@ COMPLETION_DIR=/usr/share/bash-completion/completions
SED_INSTALL_DIR=$(shell echo "$(INSTALL_DIR)" | sed -e 's/[\/&]/\\&/g')
love-release: clean
mkdir -p $(BUILD_DIR)
mkdir -p '$(BUILD_DIR)'
longopt=$$(grep "^LONG_OPTIONS" love-release.sh | sed -re 's/LONG_OPTIONS="(.*)"/\1/'); \
for file in scripts/*.sh; do \
short="$${short}$$(grep -E -m 1 "^OPTIONS=['\"]?.*['\"]?" "$$file" | sed -r -e "s/OPTIONS=['\"]?//" -e "s/['\"]?$$//")"; \
long="$${long}$$(grep -E -m 1 "^LONG_OPTIONS=['\"]?.*['\"]?" "$$file" | sed -r -e "s/LONG_OPTIONS=['\"]?//" -e "s/['\"]?$$//")"; \
s="$$(grep -E -m 1 "^OPTIONS=['\"]?.*['\"]?" "$$file" | sed -re "s/OPTIONS=['\"]?//" -e "s/['\"]?$$//")"; \
short="$${s}$${short}"; \
l="$$s$$(echo "$$longopt" | sed -e "s/,/,$${s}/g")"; \
ll="$$(grep -E -m 1 "^LONG_OPTIONS=['\"]?.*['\"]?" "$$file" | sed -re "s/LONG_OPTIONS=['\"]?//" -e "s/['\"]?$$//" -e "s/,/,$${s}/g")"; \
if [[ -n $$ll ]]; then l="$${l},$${s}$${ll}"; fi; \
long="$${l},$${long}"; \
done; \
if [[ -n $$long && $${long: -1} != ',' ]]; then long="$${long},"; fi; \
sed -re "s/^OPTIONS=(['\"]?)/OPTIONS=\1$$short/" -e "s/^LONG_OPTIONS=(['\"]?)/LONG_OPTIONS=\1$$long/" \
-e 's/INSTALLED=false/INSTALLED=true/' \
-e 's/SCRIPTS_DIR="scripts"/SCRIPTS_DIR="$(SED_INSTALL_DIR)\/scripts"/' love-release.sh > '$(BUILD_DIR)/love-release'
@@ -32,14 +36,18 @@ install:
embedded: clean
mkdir -p '$(BUILD_DIR)'
longopt=$$(grep "^LONG_OPTIONS" love-release.sh | sed -re 's/LONG_OPTIONS="(.*)"/\1/'); \
for file in scripts/*.sh; do \
module="$$(basename -s '.sh' "$$file")"; \
content='(source <(cat <<\EndOfModule'$$'\n'"$$(cat $$file)"$$'\n''EndOfModule'$$'\n''))'$$'\n''default_module'$$'\n\n'; \
echo "$$content" >> "$(BUILD_DIR)/tmp"; \
short="$${short}$$(grep -E -m 1 "^OPTIONS=['\"]?.*['\"]?" "$$file" | sed -r -e "s/OPTIONS=['\"]?//" -e "s/['\"]?$$//")"; \
long="$${long}$$(grep -E -m 1 "^LONG_OPTIONS=['\"]?.*['\"]?" "$$file" | sed -r -e "s/LONG_OPTIONS=['\"]?//" -e "s/['\"]?$$//")"; \
s="$$(grep -E -m 1 "^OPTIONS=['\"]?.*['\"]?" "$$file" | sed -re "s/OPTIONS=['\"]?//" -e "s/['\"]?$$//")"; \
short="$${s}$${short}"; \
l="$$s$$(echo "$$longopt" | sed -e "s/,/,$${s}/g")"; \
ll="$$(grep -E -m 1 "^LONG_OPTIONS=['\"]?.*['\"]?" "$$file" | sed -re "s/LONG_OPTIONS=['\"]?//" -e "s/['\"]?$$//" -e "s/,/,$${s}/g")"; \
if [[ -n $$ll ]]; then l="$${l},$${s}$${ll}"; fi; \
long="$${l},$${long}"; \
done; \
if [[ -n $$long && $${long: -1} != ',' ]]; then long="$${long},"; fi; \
sed -re "s/^OPTIONS=(['\"]?)/OPTIONS=\1$$short/" -e "s/^LONG_OPTIONS=(['\"]?)/LONG_OPTIONS=\1$$long/" \
-e 's/EMBEDDED=false/EMBEDDED=true/' \
-e '/include_scripts_here$$/r $(BUILD_DIR)/tmp' love-release.sh > '$(BUILD_DIR)/love-release.sh'

View File

@@ -71,6 +71,9 @@ See the `conf.lua` file included to see how configuration works.
`-W64` Create Windows x64 executable only
#### PROJECT OPTIONS
You can use the option of a module and append a long option from this list to set a specific
option for a module. For example, the option `--Wauthor` will set the author's name for windows only.
`-a, --author` Set the project's author.
`-d, --description` Set the project's description.
@@ -101,58 +104,58 @@ containing your game executable and its dlls.
Creating installers and using icons require [Wine](http://www.winehq.org/) to be installed.
When the script installs Resource Hacker or Inno Setup, an install wizard GUI will appear.
Please let everything as is, do not uncheck checkboxes or replace installation directory.
`--win-icon` Path to an ico file to use.
`--win-installer` Create an installer with [Inno Setup](http://www.jrsoftware.org/isinfo.php).
`--win-appid` Your game ID. You can use a GUID/UUID and generate one with `uuidgen`.
It should remain the same between updates.
Mandatory if using an installer, not needed for a simple zip.
`--win-maintainer-name` Set the maintainers name.
Mandatory if using an installer, not needed for a simple zip.
`--win-package-name` Set the name of your package.
Mandatory if using an installer, not needed for a simple zip.
`--win-package-version` Set the version of your package.
Mandatory if using an installer, not needed for a simple zip.
`--Wicon` Path to an ico file to use.
`--Winstaller` Create an installer with [Inno Setup](http://www.jrsoftware.org/isinfo.php).
`--Wappid` Your game ID. You can use a GUID/UUID and generate one with `uuidgen`.
It should remain the same between updates.
Mandatory if using an installer, not needed for a simple zip.
`--Wauthor` Set the maintainers name.
Mandatory if using an installer, not needed for a simple zip.
`--Wpkg` Set the name of your package.
Mandatory if using an installer, not needed for a simple zip.
`--Wversion` Set the version of your package.
Mandatory if using an installer, not needed for a simple zip.
#### MAC OS X
`--osx-icon` Path to an icns file to use.
`--osx-maintainer-name` Set the maintainers name. Provide it for OS X CFBundleIdentifier.
`--Micon` Path to an icns file to use.
`--Mauthor` Set the maintainers name. Provide it for OS X CFBundleIdentifier.
#### DEBIAN
`--deb-icon` Path to a single folder where icons are stored.
To be properly recognized, icons filename must contain `YYxYY`,
where `YY` is the resolution of the icon.
SVG files are recognized if suffixed with `.svg`.
Other files will be ignored.
`--maintainer-email` Set the maintainers email.
`--deb-maintainer-name` Set the maintainers name.
`--deb-package-name` Set the name of the package and the command that will be used to launch your game.
By default, it is the name of your project converted to lowercase,
with eventual spaces replaced by dashes.
`--deb-package-version` Set the version of your package.
`--Dicon` Path to a single folder where icons are stored.
To be properly recognized, icons filename must contain `YYxYY`,
where `YY` is the resolution of the icon.
SVG files are recognized if suffixed with `.svg`.
Other files will be ignored.
`--Demail` Set the maintainers email.
`--Dauthor` Set the maintainers name.
`--Dpkg` Set the name of the package and the command that will be used to launch your game.
By default, it is the name of your project converted to lowercase,
with eventual spaces replaced by dashes.
`--Dversion` Set the version of your package.
#### ANDROID
Note that every argument passed to the options should be alphanumerical,
with eventual underscores (i.e. [a-zA-Z0-9\_]), otherwise you'll get errors.
`--apk-icon` Path to a single folder where icons are stored.
The script will first look up for filename that contains
`42x42`, `72x72`, `96x96` or `144x144`.
It will then search the icon directory for subdirectories like
`drawable-mdpi`, `drawable-hdpi`, `drawable-xhdpi` and `drawable-xxhdpi`
to find an `ic_launcher.png` image.
OUYA icon (size `732x412`, or `drawable-xhdpi/ouya_icon.png`) is supported.
`--apk-activity` The name of the class that extends GameActivity.
By default it is the name of the project with Activity appended,
eventual spaces and dashes replaced by underscores.
`--apk-maintainer-name` Set the maintainers name.
It must be only alphanumerical characters, with eventual underscores.
`--apk-package-name` Set the name of the package.
By default, it is the name of your project, with eventual spaces replaced by underscores.
`--apk-package-version` Set the version of your package.
`--update-android` Update the love-android-sdl2.git repository used in the cache.
`--Aicon` Path to a single folder where icons are stored.
The script will first look up for filename that contains
`42x42`, `72x72`, `96x96` or `144x144`.
It will then search the icon directory for subdirectories like
`drawable-mdpi`, `drawable-hdpi`, `drawable-xhdpi` and `drawable-xxhdpi`
to find an `ic_launcher.png` image.
OUYA icon (size `732x412`, or `drawable-xhdpi/ouya_icon.png`) is supported.
`--Aactivity` The name of the class that extends GameActivity.
By default it is the name of the project with Activity appended,
eventual spaces and dashes replaced by underscores.
`--Aauthor` Set the maintainers name.
It must be only alphanumerical characters, with eventual underscores.
`--Apkg` Set the name of the package.
By default, it is the name of your project, with eventual spaces replaced by underscores.
`--Aversion` Set the version of your package.
`--Aupdate` Update the love-android-sdl2.git repository used in the cache.
#### OTHERS
`--clean` Clean the cache located in `~/.cache/love-release`.
One can replace the Love files there.
`--clean` Clean the cache located in `~/.cache/love-release`.
One can replace the Love files there.
#### MODULES
The script is modular.

View File

@@ -63,6 +63,9 @@ Create Windows x86 executable only.
.B \-W64
Create Windows x64 executable only.
.SH PROJECT OPTIONS
You can use the option of a module and append a long option from this list to set a specific
option for a module. For example, the option \fI\-\-Wauthor\fR will set the author's name for windows only.
.br
.TP
.B \-a, \-\-author \fIauthor\fR
Set the project's author.
@@ -105,62 +108,62 @@ Creating installers and using icons require Wine to be installed.
When the script installs Resource Hacker or Inno Setup, an install wizard GUI will appear.
Please let everything as is, do not uncheck checkboxes or replace installation directory.
.TP
.B \-\-win\-icon \fIicon\fR
.B \-\-Wicon \fIicon\fR
Path to an ico file to use.
.TP
.B \-\-win\-installer
.B \-\-Winstaller
Create an installer with Inno Setup.
.TP
.B \-\-win\-appid \fIid\fR
.B \-\-Wappid \fIid\fR
Your game ID. You can use a GUID/UUID and generate one with \fIuuigen\fR.
It should remain the same between updates.
Mandatory if using an installer, not needed for a simple zip.
.TP
.B \-\-win\-maintainer\-name \fIname\fR
.B \-\-Wauthor \fIname\fR
Set the maintainers name.
Mandatory if using an installer, not needed for a simple zip.
.TP
.B \-\-win\-package\-name \fIname\fR
.B \-\-Wpkg \fIname\fR
Set the name of the package.
Mandatory if using an installer, not needed for a simple zip.
.TP
.B \-\-win\-package\-version \fIversion\fR
.B \-\-Wversion \fIversion\fR
Set the version of your package.
Mandatory if using an installer, not needed for a simple zip.
.SH MAC OS X
.TP
.B \-\-osx\-icon \fIicon\fR
.B \-\-Micon \fIicon\fR
Path to an icns file to use.
.TP
.B \-\-osx\-maintainer\-name \fIname\fR
.B \-\-Mauthor \fIname\fR
Set the maintainer's name. Provide it for OS X CFBundleIdentifier.
.SH DEBIAN
.TP
.B \-\-deb-icon \fIdir\fR
.B \-\-Dicon \fIdir\fR
Path to a single folder where icons are stored.
To be properly recognized, icons filename must contain \fIYYxYY\fR,
where \fIYY\fR is the resolution of the icon.
SVG files are recognized if suffixed with \fI.svg\fR.
Other files will be ignored.
.TP
.B \-\-maintainer-email \fIemail\fR
.B \-\-Demail \fIemail\fR
Set the maintainer's email.
.TP
.B \-\-deb\-maintainer\-name \fIname\fR
.B \-\-Dauthor \fIname\fR
Set the maintainer's name.
.TP
.B \-\-deb\-package-name \fIname\fR
.B \-\-Dpkg \fIname\fR
Set the name of the package and the command that will be use to launch your game.
By default, it is the name of your project converted to lowercase,
with eventual spaces replaced by dashes.
.TP
.B \-\-deb\-package\-version \fIversion\fR
.B \-\-Dversion \fIversion\fR
Set the version of your package.
.SH ANDROID
Note that every argument passed to the options should be alphanumerical,
with eventual underscores (i.e. [a-zA-Z0-9_]), otherwise you'll get errors.
.TP
.B \-\-apk\-icon \fIdir\fR
.B \-\-Aicon \fIdir\fR
Path to a single folder where icons are stored.
The script will first look up for filename that contains
\fI42x42\fR, \fI72x72\fR, \fI96x96\fR or \fI144x144\fR.
@@ -169,23 +172,23 @@ It will then search the icon directory for subdirectories like
to find an \fIic_launcher.png\fR image.
OUYA icon (size \fI732x412\fR, or \fIdrawable-xhdpi/ouya_icon.png\fR) is supported.
.TP
.B \-\-apk\-activity \fIactivity\fR
.B \-\-Aactivity \fIactivity\fR
The name of the class that extends GameActivity.
By default it is the name of the project with 'Activity' appended,
eventual spaces and dashes replaced by underscores.
.TP
.B \-\-apk\-maintainer\-name \fIname\fR
.B \-\-Aauthor \fIname\fR
Set the maintainers name.
It must be only alphanumerical characters, with eventual underscores.
.TP
.B \-\-apk\-package\-name \fIname\fR
.B \-\-Apkg \fIname\fR
Set the name of the package.
By default, it is the name of your project, with eventual spaces replaced by underscores.
.TP
.B \-\-apk\-package\-version \fIversion\fR
.B \-\-Aversion \fIversion\fR
Set the version of your package.
.TP
.B \-\-update\-android
.B \-\-Aupdate
Update the love-android-sdl2.git repository used in the cache.
.SH OTHERS
.TP

View File

@@ -230,6 +230,33 @@ EOF
fi
}
# Read script options
## $1: options prefix
read_options () {
local pre="$1"
eval set -- "$ARGS"
while true; do
case "$1" in
-a|--${pre}author ) AUTHOR="$2"; shift 2 ;;
--clean ) rm -rf "$CACHE_DIR"; shift ;;
-d|--${pre}description ) DESCRIPTION="$2"; shift 2 ;;
-e|--${pre}email ) EMAIL="$2"; shift 2 ;;
-h|--${pre}help ) short_help; exit 0 ;;
-i|--${pre}icon ) ICON="$2"; shift 2 ;;
-l|--${pre}love ) if ! gen_version "$2"; then exit_module "version"; fi; shift 2 ;;
-p|--${pre}pkg ) IDENTITY="$2"; shift 2 ;;
-r|--${pre}release ) RELEASE_DIR="$2"; shift 2 ;;
-t|--${pre}title ) TITLE="$2"; shift 2 ;;
-u|--${pre}url ) URL="$2"; shift 2 ;;
-v|--${pre}version ) GAME_VERSION="$2"; shift 2 ;;
-- ) shift; break ;;
* ) shift ;;
esac
done
}
# Test if default module should be executed
default_module () {
if [[ $? -ne 2 ]]; then
@@ -301,10 +328,12 @@ init_module () {
fi
if compare_version "$LOVE_VERSION" ">" "$VERSION"; then
echo "LÖVE $LOVE_VERSION is out ! Your project uses LÖVE ${VERSION}."
gen_version $VERSION
unset VERSION
fi
gen_version $VERSION
unset VERSION
MODULE="$1"
CACHE_DIR="$CACHE_DIR/$2"
read_options "$3"
mkdir -p "$RELEASE_DIR" "$CACHE_DIR"
echo "Generating $TITLE with LÖVE $LOVE_VERSION for ${MODULE}..."
return 0
@@ -373,30 +402,13 @@ LONG_OPTIONS="author:,clean,description:,email:,help,icon:,love:,pkg:,release:,t
ARGS=$(getopt -o "$OPTIONS" -l "$LONG_OPTIONS" -n 'love-release' -- "$@")
if (( $? != 0 )); then short_help; exit_module "options"; fi
eval set -- "$ARGS"
while true; do
case "$1" in
-a|--author ) AUTHOR="$2"; shift 2 ;;
--clean ) rm -rf "$CACHE_DIR"; shift ;;
-d|--description ) DESCRIPTION="$2"; shift 2 ;;
-e|--email ) EMAIL="$2"; shift 2 ;;
-h|--help ) short_help; exit 0 ;;
-i|--icon ) ICON="$2"; shift 2 ;;
-l|--love ) if ! gen_version "$2"; then exit_module "version"; fi; shift 2 ;;
-p|--pkg ) IDENTITY="$2"; shift 2 ;;
-r|--release ) RELEASE_DIR="$2"; shift 2 ;;
-t|--title ) TITLE="$2"; shift 2 ;;
-u|--url ) URL="$2"; shift 2 ;;
-v|--version ) GAME_VERSION="$2"; shift 2 ;;
-- ) shift; break ;;
* ) shift ;;
esac
done
read_options
while [[ $1 != '--' ]]; do shift; done; shift
for arg do
FILES+=( "$arg" )
done
if (( ${#FILES} == 0 )); then FILES+=( "." ); fi
eval set -- "$ARGS"
if [[ $INSTALLED == false && $EMBEDDED == false ]]; then
exit_module "undef" "love-release has not been installed, and is not embedded into one script."