Skip to content

Commit 6d53869

Browse files
committed
Update README
1 parent 7cf0d6a commit 6d53869

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,22 @@ $ make DESTINATION=crates # generate a crat
153153
$ make generate TEMPLATE=c-wrapper-crate DESTINATION=crates # generate a crate in crates folder, but use c-wrapper-crate template
154154
```
155155

156+
Ready-to-use templates have been put together for different use cases:
157+
158+
* `contract`: default contract template you should use if no special requirements are neeeded.
159+
* `atomics-contract`: a contract template that supports atomic builtins without requiring RISC-V A extension. This template allows you to use `log`, `bytes` crate or other code that might deal with atomics before CKB2023.
160+
* `stack-reorder-contract`: a contract template that adjusts memory layout so stack lives at lower address, and heap lives at higher address. This way a program would explicitly signal errors when stack space is fully use.
161+
* `c-wrapper-crate`: a crate template that shows how to glue C code in a Rust crate for CKB's contract usage.
162+
* `x64-simulator-crate`: a crate template that contains Rust-only code, but usees [ckb-x64-simulator](https://github.com/nervosnetwork/ckb-x64-simulator) for tests.
163+
164+
Certain template might require external modules to be available, for example:
165+
166+
* All C code would require [ckb-c-stdlib](https://github.com/nervosnetwork/ckb-c-stdlib): `git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib`
167+
* `atomics-contract` requires [lib-dummy-atomics](https://github.com/xxuejie/lib-dummy-atomics): `git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics`
168+
* `stack-reorder-contract` requires [ckb-stack-reorg-bootloader](https://github.com/xxuejie/ckb-stack-reorg-bootloader): `git submodule add https://github.com/xxuejie/ckb-stack-reorg-bootloader deps/ckb-stack-reorg-bootloader`
169+
170+
In future versions, we might leverage [cargo-generate hooks](https://cargo-generate.github.io/cargo-generate/templates/scripting.html) to add submodules automatically, but for now, manual steps are required.
171+
156172
### Build & Test
157173

158174
Note that when you supply the contract crate name, our `Makefile` will be smart enough to automatically insert the crate in to `Cargo.toml` file, so you don't have to edit it manually.

cargo-generate.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
[template]
22
sub_templates = [
3-
"contract",
3+
# Entrypoint templates
4+
"workspace",
45
"standalone-contract",
6+
# Contract templates in workspace
7+
"contract",
58
"atomics-contract",
69
"stack-reorder-contract",
10+
# Dependency crate templates
711
"c-wrapper-crate",
812
"x64-simulator-crate",
9-
"workspace",
1013
]

0 commit comments

Comments
 (0)