diff --git a/README.md b/README.md index 4b8dd77..22de89c 100644 --- a/README.md +++ b/README.md @@ -238,3 +238,20 @@ $ make clippy The template is tailored built for usage outside of workspace, typically, it is not expected to be used inside a workspace. Feel free to compare it with the default `contract` workspace for differences. This standalone template also has its own test setup, where in a workspace, a dedicated `tests` crate will handle most of the testing work. + +### Native Simulator debug + +The `generate-native-simulator` command in the `Makefile` generates a native simulator. It **requires** the `CRATE` parameter to specify an existing subproject. If the parameter is missing or invalid, the command will fail. + +```bash +make generate-native-simulator CRATE= +``` + +To generate a simulator for the `example_crate` subproject: + +```bash +make generate-native-simulator CRATE=example_crate +``` + +- The `CRATE` parameter must refer to a subproject. +- Missing subprojects will cause the command to fail. diff --git a/workspace/Makefile b/workspace/Makefile index bfbe163..6cd1398 100644 --- a/workspace/Makefile +++ b/workspace/Makefile @@ -127,12 +127,20 @@ generate: generate-native-simulator: @set -eu; \ + if [ -z "$(CRATE)" ]; then \ + echo "Error: Must have CRATE="; \ + exit 1; \ + fi; \ mkdir -p native-simulators; \ cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) native-simulator \ -n $(CRATE)-sim \ --destination native-simulators; \ sed '/@@INSERTION_POINT@@/s/$$/\n "native-simulators\/$(CRATE)-sim",/' Cargo.toml > Cargo.toml.new; \ - mv Cargo.toml.new Cargo.toml; + mv Cargo.toml.new Cargo.toml; \ + if [ ! -f "contracts/$(CRATE)/Cargo.toml" ]; then \ + echo "Warning: This is a non-existent contract and needs to be processed manually"; \ + echo " Otherwise compilation may fail."; \ + fi; prepare: rustup target add riscv64imac-unknown-none-elf