diff --git a/.gitignore b/.gitignore index 57f9a3c..69aaa99 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ /gnu/ /bloatrunner /*.tar.gz +publish diff --git a/configure.ac b/configure.ac index bf12045..6a1029f 100644 --- a/configure.ac +++ b/configure.ac @@ -9,6 +9,7 @@ AM_SILENT_RULES([yes]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env]) AC_CONFIG_FILES([bloatrunner], [chmod +x bloatrunner]) +AC_CONFIG_FILES([publish], [chmod +x publish]) GUILE_PKG([3.0]) GUILE_PROGS diff --git a/game/model/level.scm b/game/model/level.scm index 0914819..3b72937 100644 --- a/game/model/level.scm +++ b/game/model/level.scm @@ -78,7 +78,7 @@ (%make-level width height tiles))) (define (level-parse-file filename) - (level-parse (call-with-input-file (assets-file-name filename) get-string-all))) + (level-parse (call-with-input-file filename get-string-all))) (define (level-tile-at-row-col level row col ) diff --git a/game/util/assets.scm b/game/util/assets.scm index a4aaf82..49f4d42 100644 --- a/game/util/assets.scm +++ b/game/util/assets.scm @@ -13,20 +13,26 @@ (define hero-texture #f) (define hero-atlas #f) -(define prefix (or (getenv "ASSET_DIR") "." )) - - -(define (assets-file-name name) - (string-append prefix "/" name) +(define (assets-location) + (if (current-filename) + (pk "Assets location: " (string-append (dirname (current-filename)) "/../..")) + (or (getenv "ASSET_DIR") "." )) ) +(define (assets-file-name . names) + "Return the full path of a file in the assets directory. The file is + specified by a list of names, which are joined together. The + ASSET_DIR environment variable can be used to specify a prefix to the + asset directory." + (string-append (assets-location) "/" (string-join names "/"))) + (define (read-level-map filename) - (call-with-input-file get-string-all)) + (call-with-input-file filename get-string-all)) (define (assets-map-levels f) (map f - (map (lambda (filename)(string-append prefix "/assets/levels/" filename)) + (map (lambda (filename)(assets-file-name "assets/levels/" filename)) (scandir (assets-file-name "assets/levels") (lambda (filename) (string-suffix? ".map" filename )))))) diff --git a/publish.in b/publish.in new file mode 100644 index 0000000..d819f5d --- /dev/null +++ b/publish.in @@ -0,0 +1,36 @@ + +ITCH_CHANNEL=snamellit/Bloatrunner + +if [[ ! -f Makefile ]]; then + make distclean +fi + +./bootstrap.sh +./configure GUILE=$(which guile) +make -j16 +make dist + +SOURCETAR="@PACKAGE@-@VERSION@.tar.gz" + +if [ -f "$SOURCETAR" ]; then + echo "Found source tarball $SOURCE" + BASENAME="@PACKAGE@-@VERSION@" + + echo releasing $BASENAME + + butler push $SOURCETAR $ITCH_CHANNEL:source + + TARBALL=$(guix pack -R -Sbloatrunner=bin -L .guix/modules bloatrunner) + echo created $TARBALL + TARGETNAME=/tmp/$BASENAME-linux-x86_64.tar.gz + echo copy $TARBALL to $TARGETNAME + rm -f $TARGETNAME + cp $TARBALL $TARGETNAME + + echo push $TARGETNAME + butler push $TARGETNAME $ITCH_CHANNEL:linux-x86_64 + +else + echo "No source tarball found" + exit 1 +fi diff --git a/publish.sh b/publish.sh deleted file mode 100755 index 472eb7e..0000000 --- a/publish.sh +++ /dev/null @@ -1,35 +0,0 @@ - -ITCH_CHANNEL=snamellit/Bloatrunner - -if [[ ! -f Makefile ]]; then - make distclean -fi - -./bootstrap.sh -./configure GUILE=$(which guile) -make -j16 -make dist - -SOURCETAR=$(ls bloatrunner-*.tar.gz | head -n 1) - -if [ -f "$SOURCETAR" ]; then - echo "Found source tarball $SOURCE" - BASENAME=$(basename $SOURCETAR .tar.gz) - echo releasing $BASENAME - - butler push $SOURCETAR $ITCH_CHANNEL:source - - TARBALL=$(guix pack -R -Sbloatrunner=bin -L .guix/modules bloatrunner) - echo created $TARBALL - TARGETNAME=/tmp/$BASENAME-linux-x86_64.tar.gz - echo copy $TARBALL to $TARGETNAME - rm -f $TARGETNAME - cp $TARBALL $TARGETNAME - - echo push $TARGETNAME - butler push $TARGETNAME $ITCH_CHANNEL:linux-x86_64 - -else - echo "No source tarball found" - exit 1 -fi