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

Deduplicate error messages #296

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
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
22 changes: 17 additions & 5 deletions plrust/src/user_crate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,20 @@ impl FnBuild {
cross_compilation_target: Option<CrossCompilationTarget>,
) -> eyre::Result<(FnLoad, Output)> {
let mut command = cargo(cargo_target_dir, cross_compilation_target)?;
set_plrustc_vars(&mut command, self, cargo_target_dir)?;
let user_crate_name = self.user_crate_name();
set_plrustc_vars(
&mut command,
&user_crate_name,
&self.crate_dir,
cargo_target_dir,
)?;

command.current_dir(&self.crate_dir);
command.arg("rustc");
command.arg("--release");
command.arg("--target");
command.arg(&target_triple);
command.arg("--features");
command.arg("build_opened");

let output = command.output().wrap_err("`cargo` execution failure")?;

Expand Down Expand Up @@ -189,9 +196,14 @@ fn path2string(p: &Path) -> eyre::Result<String> {
Ok(pathstr.to_owned())
}

fn set_plrustc_vars(command: &mut Command, build: &FnBuild, target_dir: &Path) -> eyre::Result<()> {
command.env("PLRUSTC_USER_CRATE_NAME", build.user_crate_name());
let crate_dir_str = path2string(&build.crate_dir)?;
pub(super) fn set_plrustc_vars(
command: &mut Command,
user_crate_name: &str,
crate_dir: &Path,
target_dir: &Path,
) -> eyre::Result<()> {
command.env("PLRUSTC_USER_CRATE_NAME", user_crate_name);
let crate_dir_str = path2string(crate_dir)?;
let target_dir_str = path2string(target_dir)?;

// TODO: Allow extra dirs via a GUC? Support excluding dirs?
Expand Down
Loading