Skip to content

Commit 73cbb47

Browse files
authored
Add instructions and error messages about generate-native-simulator (#21)
1 parent 81e813d commit 73cbb47

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,20 @@ $ make clippy
238238
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.
239239

240240
This standalone template also has its own test setup, where in a workspace, a dedicated `tests` crate will handle most of the testing work.
241+
242+
### Native Simulator debug
243+
244+
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.
245+
246+
```bash
247+
make generate-native-simulator CRATE=<subproject_name>
248+
```
249+
250+
To generate a simulator for the `example_crate` subproject:
251+
252+
```bash
253+
make generate-native-simulator CRATE=example_crate
254+
```
255+
256+
- The `CRATE` parameter must refer to a subproject.
257+
- Missing subprojects will cause the command to fail.

workspace/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,20 @@ generate:
127127

128128
generate-native-simulator:
129129
@set -eu; \
130+
if [ -z "$(CRATE)" ]; then \
131+
echo "Error: Must have CRATE=<Contract Name>"; \
132+
exit 1; \
133+
fi; \
130134
mkdir -p native-simulators; \
131135
cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) native-simulator \
132136
-n $(CRATE)-sim \
133137
--destination native-simulators; \
134138
sed '/@@INSERTION_POINT@@/s/$$/\n "native-simulators\/$(CRATE)-sim",/' Cargo.toml > Cargo.toml.new; \
135-
mv Cargo.toml.new Cargo.toml;
139+
mv Cargo.toml.new Cargo.toml; \
140+
if [ ! -f "contracts/$(CRATE)/Cargo.toml" ]; then \
141+
echo "Warning: This is a non-existent contract and needs to be processed manually"; \
142+
echo " Otherwise compilation may fail."; \
143+
fi;
136144

137145
prepare:
138146
rustup target add riscv64imac-unknown-none-elf

0 commit comments

Comments
 (0)