From 9a19a87a08efe7f44ea6f07fd8bd1cab446c9469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Wed, 20 Aug 2014 22:27:43 +0200 Subject: [PATCH] Add modules documentation. Possible workaround for #5 --- README.md | 6 ++++ install.sh | 5 +-- love-release.1 | 5 +++ love-release.sh | 15 +++++---- scripts/example.sh | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 scripts/example.sh diff --git a/README.md b/README.md index 82071ac..3e73b19 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,12 @@ with eventual underscores (i.e. [a-zA-Z0-9\_]), otherwise you'll get errors. `--clean` Clean the cache located in `~/.cache/love-release`. One can replace the Love files there. +#### MODULES +The script is modular. +Each different platform is handled by a subscript stored in `scripts`. +If you’d like to add the support of another platform, +or your own build script, see `scripts/example.sh`. + #### ICONS The script doesn’t yet handle the process of creating icons, but if provided it can use them. diff --git a/install.sh b/install.sh index 5ca88ac..3349dad 100755 --- a/install.sh +++ b/install.sh @@ -22,8 +22,9 @@ cp -r ./scripts "$INSTALL_DIR" cp -r ./include "$INSTALL_DIR" mkdir -p "$MANPAGE_DIR" -gzip -9 -k love-release.1 -mv love-release.1.gz "$MANPAGE_DIR" +cp love-release.1 "$MANPAGE_DIR"/love-release.1 +sed -i -e "s/scripts/${INSTALL_DIR//\//\\\/}\/scripts/g" "$MANPAGE_DIR"/love-release.1 +gzip -9 "$MANPAGE_DIR"/love-release.1 echo "Done !" diff --git a/love-release.1 b/love-release.1 index 589b8d3..4b32bd7 100644 --- a/love-release.1 +++ b/love-release.1 @@ -131,6 +131,11 @@ Set the version of your package. .B \-\-clean Clean the cache located in \fI~/.cache/love-release\fR. One can replace the Love files there. +.SH MODULES +The script is modular. +Each different platform is handled by a subscript stored in \fIscripts\fR. +If you'd like to add the support of another platform, +or your own build script, see \fIscripts/example.sh\fR. .SH ICONS The script doesn’t yet handle the process of creating icons, but if provided it can use them. diff --git a/love-release.sh b/love-release.sh index 2e626d3..6c235f8 100755 --- a/love-release.sh +++ b/love-release.sh @@ -13,17 +13,20 @@ LOVE_VERSION=0.9.1 ## - a dot "." if it has an optional argument ## - a colon ":" if it requires an argument -## SCRIPT_ARGS="a; osname:" -SCRIPT_ARGS="l; d; g; m; w." +## Love file +SCRIPT_ARGS="l;" ## Windows -SCRIPT_ARGS="icon: $SCRIPT_ARGS" +SCRIPT_ARGS="w. icon: $SCRIPT_ARGS" + ## Debian -SCRIPT_ARGS="package-version: maintainer-name: maintainer-email: homepage: description: package-name: $SCRIPT_ARGS" +SCRIPT_ARGS="d; package-version: maintainer-name: maintainer-email: homepage: description: package-name: $SCRIPT_ARGS" + ## Android -SCRIPT_ARGS="activity: package-version: maintainer-name: package-name: update-android; $SCRIPT_ARGS" +SCRIPT_ARGS="g; activity: package-version: maintainer-name: package-name: update-android; $SCRIPT_ARGS" + ## Mac OS X -SCRIPT_ARGS="icon: maintainer-name: $SCRIPT_ARGS" +SCRIPT_ARGS="m; icon: maintainer-name: $SCRIPT_ARGS" ## Add a short summary of your platform script here diff --git a/scripts/example.sh b/scripts/example.sh new file mode 100644 index 0000000..c89e6dc --- /dev/null +++ b/scripts/example.sh @@ -0,0 +1,78 @@ +# Example + +# This example script should show you how to write a module for love-release. + +# What's the point anyway ? +# Well, you could do that if you wanted to support another platform, +# or maybe to set up your own build script if you'd want to use old or custom versions of love, +# or finally to add other directives at build time. + + +# Read this example and take a look at the other modules. +# To create a new module, you have to create a file in this directory, +# and to edit the main love-release script. +# If you wish to submit a new module, please also edit README.md and love-release.1 + + +# Love-release script + +## 1. Register your module +# To register your platforms scripts, you have to choose a command name that will trigger your script. +# It must be followed by: +# - a semicolon ";" if it doesn't require an argument +# - a dot "." if it has an optional argument +# - a colon ":" if it requires an argument +SCRIPT_ARGS="q; wer: ty. uiop $SCRIPT_ARGS" + +## 2. Add a short summary of your module +SHORT_HELP=" -q Create an Example application" + +## 3. Source your script at the end of the file in the getoptex loop +while getoptex "$SCRIPT_ARGS" "$@" +do + if [ "$OPTOPT" = "q" ]; then + source "$PLATFORMS_DIR"/love.sh + fi +done + + +# Module script + +## 0. Theses variables are available: +## $MAIN_CACHE_DIR - if you need to cache something independant from love version +## $CACHE_DIR - if you need to cache something dependant from love version +## $PROJECT_FILES - if empty, means * +## $EXCLUDE_FILES - every hidden file (.*) is excluded +## $PROJECT_NAME +## $PROJECT_DIR +## $RELEASE_DIR +## $LOVE_FILE - points to the love file + +## 1. Init the module +### $1: Module name +init_module "Example" + +## 2. Parse the options +# $OPTOPT holds the option and $OPTARG holds the eventual argument passed to it. +while getoptex "$SCRIPT_ARGS" "$@" +do + if [ "$OPTOPT" = "wer" ]; then + WER=$OPTARG + elif [ "$OPTOPT" = "ty" ]; then + TY=$OPTARG + elif [ "$OPTOPT" = "uiop" ]; then + UIOP=true + fi +done + +## 3. Create the love file +### $1: Compression level 0-9 +create_love_file 9 + +## 4. Write your code + +## 5. Exit the module +### $1: exit code. 0 - success, other - failure +### $2: error message +exit_module +