-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reorganize `fud2` directory * add tool metadata * fix location for README * reorg driver files * extra some setup into functions * create `fud-core` crate * update desc * add lisc * bump version
- Loading branch information
1 parent
e461ede
commit e8a4aa1
Showing
16 changed files
with
221 additions
and
135 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
[package] | ||
name = "fud2" | ||
version.workspace = true | ||
name = "fud" | ||
version = "0.0.2" | ||
edition.workspace = true | ||
authors.workspace = true | ||
license-file.workspace = true | ||
repository.workspace = true | ||
homepage.workspace = true | ||
|
||
keywords = ["build-tool"] | ||
readme = "README.md" | ||
categories = ["build-tool"] | ||
description = "Compiler driver for the Calyx infrastructure" | ||
|
||
[dependencies] | ||
fake = { path = "fake" } | ||
fud-core = { path = "fud-core", version = "0.0.2" } | ||
anyhow.workspace = true | ||
|
||
[[bin]] | ||
name = "fud2" | ||
path = "src/main.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# `fud`: The Calyx Build Tool | ||
|
||
Reimplementation of the [fud][] compiler driver for Calyx. | ||
|
||
### Installation | ||
|
||
To install from source, run the following from `calyx/fud2`: | ||
``` | ||
cargo install --path . | ||
``` | ||
|
||
This will install the binary `fud2` to the default `cargo` binary location. | ||
|
||
### Configuration | ||
|
||
The minimal required configuration requires setting the `calyx.base` key so that `fud` knows where the Calyx compiler is. Open the configuration file by running: | ||
``` | ||
fud edit-config | ||
``` | ||
|
||
Add the path to the location of the Calyx compiler: | ||
```toml | ||
[calyx] | ||
base = "<path to calyx repo>" | ||
``` | ||
|
||
[fud]: https://docs.calyxir.org/fud/index.html |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::run; | ||
use cranelift_entity::entity_impl; | ||
|
||
/// A State is a type of file that Operations produce or consume. | ||
pub struct State { | ||
/// The name of the state, for the UI. | ||
pub name: String, | ||
|
||
/// The file extensions that this state can be represented by. | ||
/// | ||
/// The first extension in the list is used when generating a new filename for the state. If | ||
/// the list is empty, this is a "pseudo-state" that doesn't correspond to an actual file. | ||
/// Pseudo-states can only be final outputs; they are appropraite for representing actions that | ||
/// interact directly with the user, for example. | ||
pub extensions: Vec<String>, | ||
} | ||
|
||
impl State { | ||
/// Check whether a filename extension indicates this state. | ||
pub fn ext_matches(&self, ext: &str) -> bool { | ||
self.extensions.iter().any(|e| e == ext) | ||
} | ||
|
||
/// Is this a "pseudo-state": doesn't correspond to an actual file, and must be an output state? | ||
pub fn is_pseudo(&self) -> bool { | ||
self.extensions.is_empty() | ||
} | ||
} | ||
|
||
/// A reference to a State. | ||
#[derive(Copy, Clone, PartialEq, Eq, Hash)] | ||
pub struct StateRef(u32); | ||
entity_impl!(StateRef, "state"); | ||
|
||
/// An Operation transforms files from one State to another. | ||
pub struct Operation { | ||
pub name: String, | ||
pub input: StateRef, | ||
pub output: StateRef, | ||
pub setups: Vec<SetupRef>, | ||
pub emit: Box<dyn run::EmitBuild>, | ||
} | ||
|
||
/// A reference to an Operation. | ||
#[derive(Copy, Clone, PartialEq, Eq, Hash)] | ||
pub struct OpRef(u32); | ||
entity_impl!(OpRef, "op"); | ||
|
||
/// A Setup runs at configuration time and produces Ninja machinery for Operations. | ||
pub struct Setup { | ||
pub name: String, | ||
pub emit: Box<dyn run::EmitSetup>, | ||
} | ||
|
||
/// A reference to a Setup. | ||
#[derive(Copy, Clone, PartialEq, Eq, Hash)] | ||
pub struct SetupRef(u32); | ||
entity_impl!(SetupRef, "setup"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
mod data; | ||
mod driver; | ||
mod request; | ||
|
||
pub use data::{OpRef, SetupRef, StateRef}; | ||
pub(super) use data::{Operation, Setup, State}; | ||
pub use driver::{Driver, DriverBuilder, Plan}; | ||
pub use request::Request; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use super::{OpRef, StateRef}; | ||
use camino::Utf8PathBuf; | ||
|
||
/// A request to the Driver directing it what to build. | ||
#[derive(Debug)] | ||
pub struct Request { | ||
/// The input format. | ||
pub start_state: StateRef, | ||
|
||
/// The output format to produce. | ||
pub end_state: StateRef, | ||
|
||
/// The filename to read the input from, or None to read from stdin. | ||
pub start_file: Option<Utf8PathBuf>, | ||
|
||
/// The filename to write the output to, or None to print to stdout. | ||
pub end_file: Option<Utf8PathBuf>, | ||
|
||
/// A sequence of operators to route the conversion through. | ||
pub through: Vec<OpRef>, | ||
|
||
/// The working directory for the build. | ||
pub workdir: Utf8PathBuf, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pub mod cli; | ||
pub mod config; | ||
pub mod exec; | ||
pub mod run; | ||
pub mod utils; | ||
|
||
pub use exec::{Driver, DriverBuilder}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use camino::{Utf8Path, Utf8PathBuf}; | ||
use pathdiff::diff_utf8_paths; | ||
|
||
/// Get a version of `path` that works when the working directory is `base`. This is | ||
/// opportunistically a relative path, but we can always fall back to an absolute path to make sure | ||
/// the path still works. | ||
pub fn relative_path(path: &Utf8Path, base: &Utf8Path) -> Utf8PathBuf { | ||
match diff_utf8_paths(path, base) { | ||
Some(p) => p, | ||
None => path | ||
.canonicalize_utf8() | ||
.expect("could not get absolute path"), | ||
} | ||
} |
Oops, something went wrong.