Bladeren bron

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
kalm 1 jaar geleden
bovenliggende
commit
bec2f5c55e
1 gewijzigde bestanden met toevoegingen van 19 en 8 verwijderingen
  1. 19 8
      bin/explorer/explorerd/Makefile

+ 19 - 8
bin/explorer/explorerd/Makefile

@@ -71,14 +71,25 @@ uninstall:
 
 # Bundle native contract sources and their ZK proofs
 bundle_contracts_src:
-	@mkdir -p $(CURDIR)/native_contracts_src
-	@(cd ../../../src && \
-		tar -cf $(CURDIR)/native_contracts_src/deployooor_contract_src.tar -C contract/deployooor/src --transform 's,^./,,' . && \
-		tar -cf $(CURDIR)/native_contracts_src/dao_contract_src.tar -C contract/dao/src --transform 's,^./,,' . 2>/dev/null && \
-		find contract/dao/proof -name '*.zk' -exec tar -rf $(CURDIR)/native_contracts_src/dao_contract_src.tar --transform 's,^.*proof/,proof/,' {} + && \
-		tar -cf $(CURDIR)/native_contracts_src/money_contract_src.tar -C contract/money/src --transform 's,^./,,' . && \
-		find contract/money/proof -name '*.zk' -exec tar -rf $(CURDIR)/native_contracts_src/money_contract_src.tar --transform 's,^.*proof/,proof/,' {} + \
-	)
+	@PROJECT_ROOT=$$(pwd)/$(PROJECT_ROOT); \
+	CONTRACT_SRC_DIR="$$PROJECT_ROOT/src/contract"; \
+	CONTRACTS="deployooor money dao"; \
+	set -e; \
+	mkdir -p native_contracts_src/tmp; \
+	trap "rm -rf native_contracts_src/tmp" 0 1 2 15; \
+	for contract in $$CONTRACTS; do \
+		mkdir -p native_contracts_src/tmp/$$contract; \
+        cp -R "$$CONTRACT_SRC_DIR/$$contract/src/"* "native_contracts_src/tmp/$$contract"; \
+		if [ -d "$$CONTRACT_SRC_DIR/$$contract/proof" ]; then \
+			mkdir -p native_contracts_src/tmp/$$contract/proof; \
+			find "$$CONTRACT_SRC_DIR/$$contract/proof" -type f ! -name '*.bin' -exec cp \{\} native_contracts_src/tmp/$$contract/proof/ \; ; \
+			if find "native_contracts_src/tmp/$$contract/proof" -name '*.json' | grep -q .; then \
+                mkdir -p "native_contracts_src/tmp/$$contract/proof/witness"; \
+                mv native_contracts_src/tmp/$$contract/proof/*.json "native_contracts_src/tmp/$$contract/proof/witness"; \
+            fi; \
+		fi; \
+		(cd native_contracts_src/tmp/$$contract && tar --format=pax -cf ../../$${contract}_contract_src.tar *); \
+	done;
 
 # Start explorer on darkfid localnet
 start-localnet: check-minerd