Skip to content
Open
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
30 changes: 30 additions & 0 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Builds use the Sonatina codegen pipeline and generate EVM bytecode directly.

```
fe build [--standalone] [--contract <name>] [--optimize <level>] [--out-dir <dir>] [--report [--report-out <out>] [--report-failed-only]] [path]
fe build --from-metadata <PATH|-> [--contract <name>] [--optimize <level>] [--out-dir <dir>] [--emit <artifacts>]
```

If `path` is omitted, it defaults to `.`.
Expand Down Expand Up @@ -234,6 +235,35 @@ Filenames are “sanitized” from contract names:

This sanitization is also what the workspace collision check uses.

### Rebuilding from metadata: `--from-metadata`

`fe build --from-metadata <PATH|->` rebuilds a contract from a `<Contract>.metadata.json`
recompilation input (as produced by `--emit metadata`) instead of a source tree. `-` reads the
JSON from stdin, so external toolchains can pipe a synthesized metadata document into a single
`fe build` invocation. All diagnostics go to stderr.

Behavior:

- The recorded project (all `sources`, one regenerated `fe.toml` per `settings.ingots[]` entry) is
materialized into a temporary directory and built through the normal ingot build path; the
bundled `std`/`core` are provided by the compiler.
- **Contract selection**: defaults to the contract recorded in `settings.compilationTarget`;
`--contract <name>` overrides it.
- **Optimizer level**: defaults to `settings.optimizer.level`; an explicit `-O`/`--optimize` wins,
with a warning on stderr that the rebuilt bytecode will not match the verified artifact.
- **Arithmetic**: the per-ingot effective `arithmetic` values from the metadata are applied via
the regenerated `fe.toml` files (`dependency-arithmetic` is deliberately not re-applied; the
metadata records post-forcing values).
- **Version check**: if `compiler.version` differs from the running compiler, a warning is printed
to stderr (no abort); exact bytecode reproduction is only guaranteed with the same version.
- **Output**: artifacts are selected with `--emit` as usual and written to `--out-dir`, which
defaults to `./out` (relative to the current working directory, since there is no project
directory to anchor to).

Errors (exit code 1): unreadable input, invalid JSON, `language != "Fe"`, missing `sources`, or a
missing/rootless `settings.ingots`. Combining `--from-metadata` with the `[path]` argument,
`--ingot`, `--standalone`, or `--report` is a CLI usage error (exit code 2).

### Reports: `--report`

`fe build` can optionally write a `.tar.gz` debugging report (useful for sharing failures):
Expand Down
5 changes: 1 addition & 4 deletions crates/common/src/file/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ impl Workspace {

#[salsa::tracked]
pub fn get_relative_path(self, db: &dyn InputDb, base: Url, file: File) -> Option<Utf8PathBuf> {
let file_url = match self.paths(db).get(&file) {
Some(url) => url.clone(),
None => return None,
};
let file_url = self.get_path(db, file)?;
base.make_relative(&file_url).map(Utf8PathBuf::from)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/fe-web/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ impl DocIndex {
// Look up the trait URL
let trait_url = lookup_trait(&trait_items, &trait_impl.trait_name)
.map(|p| format!("{}/trait", p))
.unwrap_or_else(|| format!("{}/trait", &trait_impl.trait_name));
.unwrap_or_else(|| format!("{}/trait", trait_impl.trait_name));

// Use the target item's path and kind for the type URL
let type_url = format!("{}/{}", item.path, item.kind.as_str());
Expand Down
5 changes: 2 additions & 3 deletions crates/fe/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,9 @@ fn std_sol_compat_abi_type(
// Match Uint{N} or Int{N} where N is a valid Solidity bit width (8..=256, multiple of 8)
let (prefix, digits) = if let Some(rest) = name.strip_prefix("Uint") {
("uint", rest)
} else if let Some(rest) = name.strip_prefix("Int") {
("int", rest)
} else {
return None;
let rest = name.strip_prefix("Int")?;
("int", rest)
};

let bits: u16 = digits.parse().ok()?;
Expand Down
Loading
Loading