Skip to content

Commit

Permalink
Separate compilation artifacts by toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Nov 5, 2021
1 parent 9295c1d commit 28f3691
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion dylint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![deny(clippy::panic)]

use anyhow::{anyhow, bail, ensure, Context, Result};
use cargo_metadata::MetadataCommand;
use dylint_internal::env::{self, var};
use lazy_static::lazy_static;
use std::{
Expand Down Expand Up @@ -428,9 +429,11 @@ fn check(
let clippy_disable_docs_links = clippy_disable_docs_links()?;

for (toolchain, paths) in resolved {
let target_dir = target_dir(opts, toolchain)?;
let target_dir_str = target_dir.to_string_lossy();
let driver = driver_builder::get(opts, toolchain)?;
let dylint_libs = serde_json::to_string(&paths)?;
let mut args = vec![];
let mut args = vec!["--target-dir", &target_dir_str];
if let Some(path) = &opts.manifest_path {
args.extend(&["--manifest-path", path]);
}
Expand Down Expand Up @@ -470,6 +473,20 @@ fn check(
Ok(())
}

fn target_dir(opts: &Dylint, toolchain: &str) -> Result<PathBuf> {
let mut command = MetadataCommand::new();
if let Some(path) = &opts.manifest_path {
command.manifest_path(path);
}
let metadata = command.no_deps().exec()?;
Ok(metadata
.target_directory
.join("dylint")
.join("target")
.join(toolchain)
.into())
}

fn flatten_toolchain_map(toolchain_map: &ToolchainMap) -> Vec<(String, PathBuf)> {
toolchain_map
.iter()
Expand Down
1 change: 1 addition & 0 deletions dylint/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ fn target_dir(metadata: &Metadata, package_root: &Path, _package_id: PackageId)
Ok(metadata
.target_directory
.join("dylint")
.join("libraries")
.join(toolchain)
// .join(pkg_dir(package_root, package_id))
.into())
Expand Down

0 comments on commit 28f3691

Please sign in to comment.