From 64c39db54a94c8340ecbff54adb8e0204811e0a2 Mon Sep 17 00:00:00 2001 From: maciektr Date: Wed, 10 Jul 2024 13:05:43 +0200 Subject: [PATCH] Update website docs (#1433) --- extensions/scarb-cairo-test/src/main.rs | 2 +- website/.vitepress/config.mjs | 1 + website/docs/extensions/expand.md | 22 ++++++++++++++++++++++ website/docs/reference/manifest.md | 18 +++++++++++++++--- 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 website/docs/extensions/expand.md diff --git a/extensions/scarb-cairo-test/src/main.rs b/extensions/scarb-cairo-test/src/main.rs index c030c2314..f2d949132 100644 --- a/extensions/scarb-cairo-test/src/main.rs +++ b/extensions/scarb-cairo-test/src/main.rs @@ -35,7 +35,7 @@ struct Args { /// Choose test kind to run. #[arg(short, long)] - pub test_kind: Option, + test_kind: Option, /// Whether to print resource usage after each test. #[arg(long, default_value_t = false)] diff --git a/website/.vitepress/config.mjs b/website/.vitepress/config.mjs index e824d4dba..af575feee 100644 --- a/website/.vitepress/config.mjs +++ b/website/.vitepress/config.mjs @@ -41,6 +41,7 @@ const sidebar = { ], }, p("Language server", "/docs/extensions/cairo-language-server"), + p("Expand", "/docs/extensions/expand"), ], }, { diff --git a/website/docs/extensions/expand.md b/website/docs/extensions/expand.md new file mode 100644 index 000000000..caf246243 --- /dev/null +++ b/website/docs/extensions/expand.md @@ -0,0 +1,22 @@ +# Expand + +`scarb expand` is a tool that makes debugging macros in Scarb easier. + +Before the actual compilation of your Cairo code, the Cairo compiler runs multiple pre-processing steps on it (these are +usually called plugins). +Each of these steps takes parsed Cairo code as an input, modifies it and returns modified Cairo code back to the +compiler. + +This can often implement code generation, optimizations, or other transformations. +For instance, derives for Cairo structs can be implemented this way, or some boilerplate code can be generated. +This is also used in Cairo compiler to implement conditional compilation with `cfg` attributes. +Blocks of code under disabled `cfg` sets will be removed at this phase. + +While preprocessing is useful for making the programmers code shorter and easier to reason about, it can also make +debugging harder. +Because of the preprocessing, Cairo code that is **actually** compiled can be different from the one you see in your +editor. + +To help with debugging your code in such cases, you can use `scarb expand` command, which runs all preprocessing steps +on your package and return expanded Cairo code. +The expanded Cairo is saved as a file in your target directory. diff --git a/website/docs/reference/manifest.md b/website/docs/reference/manifest.md index 8ea28b911..969f829cf 100644 --- a/website/docs/reference/manifest.md +++ b/website/docs/reference/manifest.md @@ -277,6 +277,18 @@ enable-gas = false This flag cannot be disabled while compiling the `starknet-contract` target. +### `inlining-strategy` + +This field is responsible for setting the inlining strategy to be used by compiler when building the package. +The possible values are `default` or `avoid`. +If `avoid` strategy is set, the compiler will only inline function annotated with `#[inline(always)]` attribute. + +> [!WARNING] +> Using the `avoid` strategy may result in a slower execution of the compiled code and significantly larger artefacts +> size. +> Please use with caution, only if your tooling requires that. +> You can use profile settings overwriting, for more granular control of which builds use the avoid strategy. + ### `unstable-add-statements-functions-debug-info` > [!WARNING] @@ -285,9 +297,9 @@ This flag cannot be disabled while compiling the `starknet-contract` target. > It may slow down the compilation - it is advised not to use it for other purposes than mentioned in > [cairo-profiler](https://github.com/software-mansion/cairo-profiler) documentation. -If enabled, during the project compilation Scarb will a add mapping between Sierra statement indexes and vectors of fully -qualified paths of Cairo functions to debug info. A statement index maps to a vector consisting of a function which -caused the statement to be generated and all functions that were inlined or generated along the way. +If enabled, during the project compilation Scarb will a add mapping between Sierra statement indexes and vectors of +fully qualified paths of Cairo functions to debug info. A statement index maps to a vector consisting of a function +which caused the statement to be generated and all functions that were inlined or generated along the way. By default, this flag is disabled. ```toml