From dbaa42c1ff65aca8c32baaafc9c0642f30ebe1ae Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Tue, 5 Nov 2019 01:16:59 +0100 Subject: [PATCH] ${type}.prelude, improved crystal.zsh --- build.zsh.in | 8 ++++++++ build/crystal.zsh | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/build.zsh.in b/build.zsh.in index 64e4d81..80081ee 100644 --- a/build.zsh.in +++ b/build.zsh.in @@ -231,6 +231,14 @@ function main { : > $Makefile + for target in ${targets[@]}; do + local _type=${type[$target]} + + if exists ${_type}.prelude; then + ${_type}.prelude + fi + done + if [[ -n "$package" && -n "$version" ]]; then export package version diff --git a/build/crystal.zsh b/build/crystal.zsh index 966ce40..01077f7 100644 --- a/build/crystal.zsh +++ b/build/crystal.zsh @@ -1,8 +1,23 @@ +function crystal.prelude { + local has_crflags=false + + for variable value in ${variables[@]}; do + if [[ "$variable" == "CRFLAGS" ]]; then + has_crflags=true + break + fi + done + + if ! $has_crflags; then + variables+=(CRFLAGS "--release") + fi +} + function crystal.build { write "${target}: ${src[@]} ${depends[$target]} $(dirdep $target)" write "\t@echo '${fg_bold[magenta]} CR > ${fg_bold[white]}$target${reset_color}'" - write "\t${Q}crystal build ${crflags[$target]:---release} \$(CRFLAGS) ${src[@]} -o '${target}'" + write "\t${Q}crystal build ${crflags[$target]} \$(CRFLAGS) ${src[@]} -o '${target}'" write "\n" }