Skip to content

Commit bec2f5c

Browse files
author
kalm
committed
explorerd: improve cross-platform native contract bundling, add witness proof files
This commit replaces the GNU tar-specific `--transform` flag with a more portable solution, ensuring contract bundling works correctly on both Linux and BSD/macOS systems. It also includes witness proof JSON files in the native contract source code. Summary of Updates - Removed dependency on the GNU-specific `--transform` option - Specified PAX format explicitly (`--format=pax`) for better cross-platform compatibility - Refactored to use a temporary directory structure that mirrors the desired archive layout before generating tar files - Included proof witness JSON files as part of the native contract bundling
1 parent 0772c82 commit bec2f5c

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

bin/explorer/explorerd/Makefile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,25 @@ uninstall:
7171

7272
# Bundle native contract sources and their ZK proofs
7373
bundle_contracts_src:
74-
@mkdir -p $(CURDIR)/native_contracts_src
75-
@(cd ../../../src && \
76-
tar -cf $(CURDIR)/native_contracts_src/deployooor_contract_src.tar -C contract/deployooor/src --transform 's,^./,,' . && \
77-
tar -cf $(CURDIR)/native_contracts_src/dao_contract_src.tar -C contract/dao/src --transform 's,^./,,' . 2>/dev/null && \
78-
find contract/dao/proof -name '*.zk' -exec tar -rf $(CURDIR)/native_contracts_src/dao_contract_src.tar --transform 's,^.*proof/,proof/,' {} + && \
79-
tar -cf $(CURDIR)/native_contracts_src/money_contract_src.tar -C contract/money/src --transform 's,^./,,' . && \
80-
find contract/money/proof -name '*.zk' -exec tar -rf $(CURDIR)/native_contracts_src/money_contract_src.tar --transform 's,^.*proof/,proof/,' {} + \
81-
)
74+
@PROJECT_ROOT=$$(pwd)/$(PROJECT_ROOT); \
75+
CONTRACT_SRC_DIR="$$PROJECT_ROOT/src/contract"; \
76+
CONTRACTS="deployooor money dao"; \
77+
set -e; \
78+
mkdir -p native_contracts_src/tmp; \
79+
trap "rm -rf native_contracts_src/tmp" 0 1 2 15; \
80+
for contract in $$CONTRACTS; do \
81+
mkdir -p native_contracts_src/tmp/$$contract; \
82+
cp -R "$$CONTRACT_SRC_DIR/$$contract/src/"* "native_contracts_src/tmp/$$contract"; \
83+
if [ -d "$$CONTRACT_SRC_DIR/$$contract/proof" ]; then \
84+
mkdir -p native_contracts_src/tmp/$$contract/proof; \
85+
find "$$CONTRACT_SRC_DIR/$$contract/proof" -type f ! -name '*.bin' -exec cp \{\} native_contracts_src/tmp/$$contract/proof/ \; ; \
86+
if find "native_contracts_src/tmp/$$contract/proof" -name '*.json' | grep -q .; then \
87+
mkdir -p "native_contracts_src/tmp/$$contract/proof/witness"; \
88+
mv native_contracts_src/tmp/$$contract/proof/*.json "native_contracts_src/tmp/$$contract/proof/witness"; \
89+
fi; \
90+
fi; \
91+
(cd native_contracts_src/tmp/$$contract && tar --format=pax -cf ../../$${contract}_contract_src.tar *); \
92+
done;
8293

8394
# Start explorer on darkfid localnet
8495
start-localnet: check-minerd

0 commit comments

Comments
 (0)