use relative paths for assets

This commit is contained in:
Peter Tillemans 2024-05-25 13:19:31 +02:00
parent e71b0bb158
commit 548cddc89d
6 changed files with 52 additions and 43 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@
/gnu/
/bloatrunner
/*.tar.gz
publish

View file

@ -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

View file

@ -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 )

View file

@ -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 ))))))

36
publish.in Normal file
View file

@ -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

View file

@ -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