diff --git a/rebar.config b/rebar.config index fa815e5..4b02c10 100644 --- a/rebar.config +++ b/rebar.config @@ -6,8 +6,6 @@ {ref, "0288719ae1"}}} ]}. -{post_hooks, [{compile, "./zompify.sh"}]}. - {xref_checks, [undefined_function_calls, undefined_functions, locals_not_used, deprecated_function_calls, deprecated_functions]}. diff --git a/src/gmmpp_msgs.erl b/src/gmmpp_msgs.erl index 09843af..23913d9 100644 --- a/src/gmmpp_msgs.erl +++ b/src/gmmpp_msgs.erl @@ -334,7 +334,7 @@ valid_(pos_int, I) -> pos_integer(I); valid_(string, S) -> is_binary(S); valid_(boolean, B) -> is_boolean(B); valid_(contract, Id) -> ok_tuple(gmser_api_encoder:safe_decode(contract_pubkey, Id)); -valid_(type, T) -> lists:member(T, [miner, monitor]); +valid_(type, T) -> lists:member(T, [worker, monitor]); valid_(solutions, S) -> lists:all(fun(#{nonce := N, evidence := Evd}) -> valid_(pos_int, N), valid_({list, pos_int}, Evd) diff --git a/zompify.sh b/zompify.sh index 3c56b80..66aca1c 100755 --- a/zompify.sh +++ b/zompify.sh @@ -2,11 +2,41 @@ set -e APP=$(basename "$PWD") + SRC="_build/default/lib/$APP" DST="$PWD/_build/zomp/lib/$APP" +IGNORE_FILE="zomp.ignore" + mkdir -p "$DST" -find "$SRC" -type l ! -exec test -e {} \; -delete -cp -aR -L "$SRC/." "$DST/" + +# Remove broken symlinks +find "$SRC" -type l ! -exec test -e {} \; -delete || true + +# Build ignore matcher +IGNORE_TEMP=$(mktemp) +trap "rm -f $IGNORE_TEMP" EXIT + +# Expand globs in zomp.ignore to patterns suitable for grep +if [ -e "$IGNORE_FILE" ]; then + grep -v '^\s*#' "$IGNORE_FILE" | sed 's#/#\\/#g' | sed 's/\./\\./g' | sed 's/\*/.*/g' > "$IGNORE_TEMP" +fi + +# Copy Git-tracked and Zomp-allowed files +git ls-files -z | while IFS= read -r -d '' file; do + # Skip if ignored + echo "$file" | grep -Eq -f "$IGNORE_TEMP" && continue + # Only copy if file exists in the build dir + if [ -e "$SRC/$file" ]; then + mkdir -p "$DST/$(dirname "$file")" + cp -a "$SRC/$file" "$DST/$file" + fi +done + +rm "$IGNORE_TEMP" + +# Copy metadata cp "$PWD/zomp.meta" "$DST/" -cp "$PWD/Emakefile" "$DST" -rm "$DST"/ebin/*.beam +cp "$PWD/Emakefile" "$DST/" + +# Clean up beam files just in case +[ -d "$DST/ebin" ] && find "$DST/ebin" -name '*.beam' -exec rm -f {} + || true