Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<subproject_name>
```

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.
10 changes: 9 additions & 1 deletion workspace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,20 @@ generate:

generate-native-simulator:
@set -eu; \
if [ -z "$(CRATE)" ]; then \
echo "Error: Must have CRATE=<Contract Name>"; \
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
Expand Down
Loading