Skip to content

Commit 1c886bd

Browse files
alanzmeta-codesync[bot]
authored andcommitted
buck: improve target classification for prelude vs third-party
Summary: This diff operated in the context of the buck project model. Up to now, the buck erlang prelude files had not been updated to be eqwalizer error-free. They are now fully eqwalized. Part of the internal usage is to tweak both the common test prelude files and our internal source, and so it is convenient to report eqwalizer diagnostics, via `elp eqwalize-all` for these as well. The buck project model has historically classified the prelude files as third-party, which maps them to a `TargetType::Dep`, and so eqwalizer does not process them. This diff changes the logic, so that if any of the `.elp.toml` included targets for a project include a buck prelude target, then it will classify all prelude target files as `TargetType::App` instead. This has the result of ensuring that they are processed for `elp eqwalize-all` of that project. Reviewed By: jcpetruzza Differential Revision: D85761256 fbshipit-source-id: 39a8a56870662d8c148f5a646c7ae63a262693a4
1 parent aa9a4fc commit 1c886bd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

crates/project_model/src/buck.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -717,17 +717,17 @@ fn load_buck_targets_bxl(
717717

718718
let mut used_deps = FxHashSet::default();
719719

720-
let targets_include_only_prelude = buck_config
720+
let targets_include_prelude = buck_config
721721
.included_targets
722722
.iter()
723-
.all(|t| t.starts_with("prelude//"));
723+
.any(|t| t.starts_with("prelude//"));
724724
for (name, buck_target) in &buck_targets {
725725
if let Ok(target) = make_buck_target(
726726
root,
727727
name,
728728
buck_target,
729729
buck_config.build_deps,
730-
targets_include_only_prelude,
730+
targets_include_prelude,
731731
&mut dep_path,
732732
&mut target_info,
733733
) {
@@ -748,7 +748,7 @@ fn make_buck_target(
748748
name: &String,
749749
target: &BuckTarget,
750750
build_deps: bool,
751-
targets_include_only_prelude: bool,
751+
targets_include_prelude: bool,
752752
dep_path: &mut FxHashMap<String, AbsPathBuf>,
753753
target_info: &mut TargetInfo,
754754
) -> Result<Target> {
@@ -763,7 +763,7 @@ fn make_buck_target(
763763
(src, TargetType::ErlangTest, false, None)
764764
} else {
765765
let mut private_header = false;
766-
let target_type = compute_target_type(name, target, targets_include_only_prelude);
766+
let target_type = compute_target_type(name, target, targets_include_prelude);
767767
let mut src_files = vec![];
768768
for src in &target.srcs {
769769
let src = json::canonicalize(buck_path_to_abs_path(root, src).unwrap())?;
@@ -816,11 +816,11 @@ fn make_buck_target(
816816
fn compute_target_type(
817817
name: &TargetFullName,
818818
target: &BuckTarget,
819-
targets_include_only_prelude: bool,
819+
targets_include_prelude: bool,
820820
) -> TargetType {
821821
// Check if we are trying to work on the prelude itself
822-
let is_prelude_dep = !targets_include_only_prelude && (name.starts_with("prelude//"));
823-
if is_prelude_dep || name.contains("//third-party") {
822+
let is_prelude_as_third_party = !targets_include_prelude && name.starts_with("prelude//");
823+
if is_prelude_as_third_party || name.contains("//third-party") {
824824
TargetType::ThirdParty
825825
} else {
826826
let test_utils = target.labels.contains("test_utils");

0 commit comments

Comments
 (0)