star-build

Automation tool for project installation
git clone git://git.meso-star.fr/star-build.git
Log | Files | Refs | README | LICENSE

commit 6253b2af04e210b965f28f1852bcd6d13e97f73a
parent 786d25e330044de75e854f7113163836602c0119
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sat, 20 May 2023 21:18:24 +0200

Add a trailing '@' to variable names in template files

The variable names are now surrounded by two '@' characters. This
ensures that the variable to be substituted is the right one and not
another variable whose name starts with the same prefix.

Diffstat:
Mbuild.sh | 16++++++++--------
Mgit.mk.in | 44++++++++++++++++++++++----------------------
Mspkg.mk.in | 30+++++++++++++++---------------
3 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/build.sh b/build.sh @@ -24,11 +24,11 @@ git_repo() { sed\ - -e "s#@NAME#${name}#g"\ - -e "s#@URL#${url}#g"\ - -e "s#@TAG#${tag}#g"\ - -e "s#@DEP#${dep}#g"\ - -e "s#@OPT#${opt}#g"\ + -e "s#@NAME@#${name}#g"\ + -e "s#@URL@#${url}#g"\ + -e "s#@TAG@#${tag}#g"\ + -e "s#@DEP@#${dep}#g"\ + -e "s#@OPT@#${opt}#g"\ git.mk.in # Reset variables @@ -49,9 +49,9 @@ bin_spkg() path="$(echo ${url%/*})" sed\ - -e "s#@NAME#${name}#g"\ - -e "s#@ARCH#${arch}#g"\ - -e "s#@PATH#${path}#g"\ + -e "s#@NAME@#${name}#g"\ + -e "s#@ARCH@#${arch}#g"\ + -e "s#@PATH@#${path}#g"\ spkg.mk.in # Reset variables diff --git a/git.mk.in b/git.mk.in @@ -1,37 +1,37 @@ -@NAME: build_@NAME prefix - @cd -- @NAME_dir &&\ - $(MAKE) PREFIX="$$(cat ../.prefix)" @OPT install +@NAME@: build_@NAME@ prefix + @cd -- @NAME@_dir &&\ + $(MAKE) PREFIX="$$(cat ../.prefix)" @OPT@ install # Delete the dependency file to force their regeneration. This is necessary # because the .prefix file may have been updated and therefore the dependency # files may be outdated. -build_@NAME: @DEP fetch_@NAME prefix - @cd -- @NAME_dir &&\ +build_@NAME@: @DEP@ fetch_@NAME@ prefix + @cd -- @NAME@_dir &&\ rm -f $$(find src -name "*.d") &&\ - PKG_CONFIG_PATH="$$(cat ../.prefix)/lib/pkgconfig/" $(MAKE) @OPT + PKG_CONFIG_PATH="$$(cat ../.prefix)/lib/pkgconfig/" $(MAKE) @OPT@ -@NAME_dir: - @git clone @URL $@ +@NAME@_dir: + @git clone @URL@ $@ -fetch_@NAME: @NAME_dir - @cd -- @NAME_dir &&\ +fetch_@NAME@: @NAME@_dir + @cd -- @NAME@_dir &&\ git fetch origin &&\ git checkout -B star-build &&\ - git reset --hard @TAG + git reset --hard @TAG@ -clean_@NAME: - @if [ -d @NAME_dir ]; then\ - cd -- @NAME_dir && make clean;\ +clean_@NAME@: + @if [ -d @NAME@_dir ]; then\ + cd -- @NAME@_dir && make clean;\ fi -uninstall_@NAME: - @if [ -d @NAME_dir ]; then \ - cd -- @NAME_dir && make PREFIX="$$(cat ../.prefix)" uninstall; \ +uninstall_@NAME@: + @if [ -d @NAME@_dir ]; then \ + cd -- @NAME@_dir && make PREFIX="$$(cat ../.prefix)" uninstall; \ fi -distclean_@NAME: - @rm -rf @NAME_dir +distclean_@NAME@: + @rm -rf @NAME@_dir -clean_all: clean_@NAME -distclean_all: distclean_@NAME -uninstall_all: uninstall_@NAME +clean_all: clean_@NAME@ +distclean_all: distclean_@NAME@ +uninstall_all: uninstall_@NAME@ diff --git a/spkg.mk.in b/spkg.mk.in @@ -1,21 +1,21 @@ -@NAME: @ARCH.tgz @ARCH.sha512sum prefix - @if ! cmp @ARCH.sha512sum "$$(cat .prefix)/share/spkg/@ARCH.sha512sum" > /dev/null 2>&1; then\ - sha512sum -c @ARCH.sha512sum;\ - tar -xvf @ARCH.tgz -C $$(cat .prefix);\ - $(SHELL) "$$(cat .prefix)/share/spkg/@NAME.sh" install "$$(cat .prefix)";\ - cp @ARCH.sha512sum "$$(cat .prefix)/share/spkg/";\ +@NAME@: @ARCH@.tgz @ARCH@.sha512sum prefix + @if ! cmp @ARCH@.sha512sum "$$(cat .prefix)/share/spkg/@ARCH@.sha512sum" > /dev/null 2>&1; then\ + sha512sum -c @ARCH@.sha512sum;\ + tar -xvf @ARCH@.tgz -C $$(cat .prefix);\ + $(SHELL) "$$(cat .prefix)/share/spkg/@NAME@.sh" install "$$(cat .prefix)";\ + cp @ARCH@.sha512sum "$$(cat .prefix)/share/spkg/";\ fi -@ARCH.sha512sum @ARCH.tgz: - curl -O "@PATH/$@" +@ARCH@.sha512sum @ARCH@.tgz: + curl -O "@PATH@/$@" -uninstall_@NAME: - @if [ -f "$$(cat .prefix)/share/spkg/@NAME.sh" ]; then \ - $(SHELL) "$$(cat .prefix)/share/spkg/@NAME.sh" uninstall "$(cat .prefix)"; \ +uninstall_@NAME@: + @if [ -f "$$(cat .prefix)/share/spkg/@NAME@.sh" ]; then \ + $(SHELL) "$$(cat .prefix)/share/spkg/@NAME@.sh" uninstall "$(cat .prefix)"; \ fi -distclean_@NAME: - rm -rf @ARCH.tgz @ARCH.sha512sum +distclean_@NAME@: + rm -rf @ARCH@.tgz @ARCH@.sha512sum -distclean_all: distclean_@NAME -uninstall_all: uninstall_@NAME +distclean_all: distclean_@NAME@ +uninstall_all: uninstall_@NAME@