From 926ec7a6b85e6e3f7335a8c5ddcccd51937ee2d8 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Fri, 8 Sep 2023 23:32:10 +0200 Subject: added a build configuration step --- confninja.sh | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 confninja.sh (limited to 'confninja.sh') diff --git a/confninja.sh b/confninja.sh new file mode 100644 index 0000000..f1507a0 --- /dev/null +++ b/confninja.sh @@ -0,0 +1,109 @@ +set -eu + +cat <<'END' +# File generated by confninja.sh; DO NOT EDIT! + +ninja_required_version = 1.11 + +rule cargo + command = cd $extractrs_dir && cargo build $rust_mode && cp $rs_bin ../bin + description = CARGO $out + +rule scss + command = sass --load-path=node_modules/ $scss_mode $in $out + description = SCSS $out + +rule bundle + command = esbuild --bundle $bundle_mode --outfile=$out $in + description = BUNDLE $out + +rule dist + command = tar --posix --zstd -cf $out $in + description = DIST $out + +rule cpy + command = cp $in $out + description = CPY $out + +rule perltest + command = prove -l t/ + description = PERLTEST + +rule configure + command = ./configure $confargs + description = CONFIGURE + generator = 1 + +build test: perltest +END + +echo "confargs = $CONFARGS" +echo "build build.ninja lib/JWebmail/Config.pm: configure configure confninja.sh lib/JWebmail/Config.pm.in MANIFEST" + +case "$JWM_MODE" in + (development) + echo 'bundle_mode = --sourcemap' + echo 'rs_bin = target/debug/jwebmail-extract' + ;; + (production) + echo 'bundle_mode = --minify' + echo 'sass_mode = --style=compress --no-source-maps' + echo 'rust_mode = --release --target x86_64-unknown-linux-musl' + echo 'rs_bin = target/x86_64-unknown-linux-musl/release/jwebmail-extract' + ;; +esac + +case "$MAILDIR_EXTRACTOR_NAME" in + (extractrs) + echo "extractrs_dir = $JWM_EXTRACTRS_DIR" + printf '%s' 'build bin/jwebmail-extract: cargo' + FILES_RS='arguments.rs cmd.rs error.rs main.rs rfc822.rs cmd/count.rs cmd/folders.rs cmd/list.rs cmd/raw.rs' + for f in $FILES_RS + do + printf '%s' " \$extractrs_dir/src/$f" + done + echo + ;; +esac + +FILES_JS='src/displayheaders.js src/login_cram.js src/rendermail.js' +for f in $FILES_JS +do case "$JWM_MODE" in + (development) echo "build public/$f | public/$f.map: bundle $f";; + (production) echo "build public/$f: bundle $f";; +esac +done + +FILES_CSS='my_bulma' +for f in $FILES_CSS +do case "$JWM_MODE" in + (development) echo "build public/css/$f.css | public/css/$f.css.map: scss scss/$f.scss";; + (production) echo "build public/css/$f.css: scss scss/$f.scss";; +esac +done + +while read f +do [ -n "$f" ] && echo "build JWebmail-srcdist/$f: cpy $f" +done