Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick update of ARCHITECTURE.md #1339

Merged
merged 1 commit into from
Jun 6, 2024
Merged
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
37 changes: 23 additions & 14 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ flowchart TD
subgraph BUILTIN_CMDS ["Built-in commands"]
direction LR
BLD[scarb build]
CLN[scarb clean]
CHK[scarb check]
UPD[scarb update]
FTH[scarb fetch]
FMT[scarb fmt]
RUN[scarb run]
CLN[scarb clean]
CAC[scarb cache]
NEW[scarb init/new]
UPD[scarb add/rm/update]
PUB[scarb package/publish]
MET[scarb metadata]
CMD[scarb commands]
MAN[scarb manifest-path]
end
subgraph EXT_CMDS ["External subcommands system"]
direction LR
CAIRO_LS["Cairo Language Server"]
CAIRO_RUN["scarb run"]
SCARB_DOC["scarb doc"]
SNFORGE["scarb test\n(can redirect to either snforge,\ncairo-test or other runner)"]
end
```
Expand Down Expand Up @@ -74,12 +80,14 @@ classDiagram
- compilers
}
class CairoPluginRepository {
- compiler macro plugins
- built-in compiler macro plugins
}
class StarknetContractCompiler {
}
class LibCompiler {
}
class TestCompiler {
}
class Workspace~'c~ {
+ members() Iter~Package~
}
Expand Down Expand Up @@ -107,10 +115,12 @@ classDiagram
+ String name
+ VersionReq
+ SourceId
+ DepKind
}
class Target {
+ TargetKind
+ String name
+ Optional group_id
+ BTreeMap<String, *> params
}
class CompilationUnit {
Expand Down Expand Up @@ -144,6 +154,7 @@ classDiagram
CompilationUnit ..> Target : is created from
CodegenRepository *-- StarknetContractCompiler
CodegenRepository *-- LibCompiler
CodegenRepository *-- TestCompiler
```

### Sources and the internal registry
Expand All @@ -158,15 +169,15 @@ classDiagram
}
class PathSource
class GitSource
class StandardLibSource
class RegistrySource {
<<Future>>
class RegistrySource
class StandardLibSource {
/embedded/
}

PathSource ..|> Source
GitSource ..|> Source
StandardLibSource ..|> Source
RegistrySource ..|> Source
StandardLibSource ..|> Source
```

A _source_ is an object that finds and downloads remote packages based on names and versions.
Expand All @@ -176,10 +187,9 @@ There are various `Source` implementation for different methods of downloading p
1. `PathSource` simply provides an ability to operate on packages from local file system.
2. `GitSource` downloads packages from Git repositories.
3. `RegistrySource` downloads packages from package registries.
4. `StandardLibSource` unpacks packages embedded into the Scarb binary itself.
4. And more...

**CURRENTLY ONLY PATH AND GIT SOURCES ARE IMPLEMENTED.**

The `Registry` object gathers all `Source` objects in a single mapping, and provides a unified interface for querying
_any_ package, no matter of its source.

Expand All @@ -202,9 +212,7 @@ internally.

### Lockfile

**THIS IS NOT IMPLEMENTED YET.**

TODO(mkaput): Write this section.
See Scarb documentation.

## Scarb Compiler

Expand Down Expand Up @@ -274,10 +282,11 @@ Plugins appropriate to be used for building a specific package are applied to th
When using Scarb as a library, Cairo plugins can be defined with configuration builder.
If not specified otherwise, Scarb comes with predefined StarkNet Cairo plugin, that can be used for StarkNet contracts
compilation.
In the future, Scarb will also provide a way to define Cairo plugins as package dependencies.

**The mechanism for requiring Cairo plugins as package dependencies or compiling them in Scarb runtime is not implemented yet.**
### Procedural Macros

Procedural macros provide a mechanism for defining custom macros as package dependencies.
The package with macro source code definition will be pulled and compiled by Scarb.
Please see [the design document](design/01-proc-macro.md) for more information.

### RootDatabase management within the compiler
Expand Down
Loading