-
Notifications
You must be signed in to change notification settings - Fork 0
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
Initial implementation #1
base: main
Are you sure you want to change the base?
Conversation
4dee329
to
019ff72
Compare
cross-llvm is a tool for easy cross (but also native) builds using LLVM (clang, Rust). It consists of: - Container images which provide the toolchains for each target. - A CLI tool, which is a wrapper about a container engine (Docker, podman) and allows easy execution of the toolchain. Provided container images can be used with https://github.com/cross-rs/cross
Command which executes `clang` in a containerized cross environment.
Cross wrappers for musl containers are already provided by crossdev[0]. To achieve the save effect on Debian containers, create similar wrappers.
uuid = { version = "1.10", features = ["v4"] } | ||
which = "6.0" | ||
|
||
cross-llvm = { path = "cross-llvm" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why list this here?
uuid = { workspace = true } | ||
which = { workspace = true } | ||
|
||
cross-llvm = { workspace = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the path?
#[error("containerized builds are not supported for target {0}")] | ||
UnsupportedTarget(String), | ||
#[error("failed to build a container image")] | ||
ContainerImageBuild, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this include a source error?
ditto below
container_engine: Option<ContainerEngine>, | ||
|
||
/// Do not use existing cached images for the container build. Build from | ||
/// the start with a new set of cached layers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inconsistent punctuation
#[arg(short, long = "tag", name = "tag")] | ||
tags: Vec<OsString>, | ||
|
||
/// Target triple (optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need to say optional? doesn't clap do the right thing based on the type?
|
||
pub fn clang(args: RunArgs) -> anyhow::Result<()> { | ||
let triple: Triple = match args.target { | ||
Some(ref target) => target.clone().into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need to clone it? you have it by value. looks like it's because run_container wants the same argument; split the struct and use #[arg(flatten)]
let mut container = Command::new(container_engine.to_string()); | ||
container | ||
.args([ | ||
OsStr::new("run"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing here, overusing OsStr::new imo. you can mostly use &str literals
]) | ||
.args(cmd_args) | ||
.args(cmd) | ||
.stdin(Stdio::inherit()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why inherit stdin? again i think we should capture stdio here for a semblance of discipline
|
||
#[derive(Debug, Error)] | ||
pub enum CrossLlvmError { | ||
#[error("no supported container engine (docker, podman) was found")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
odd to enumerate the options at a distance
|
||
#[derive(Parser)] | ||
pub struct RunArgs { | ||
/// Container engine (if not provided, is going to be autodetected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting dejavu here
cross-llvm is a tool for easy cross (but also native) builds using LLVM (clang, Rust).
It consists of:
Provided container images can be used:
cross-llvm
CLI.