Skip to content

Commit

Permalink
Add an event for source directory encountered in a build.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 437843565
  • Loading branch information
alexjski authored and copybara-github committed Mar 28, 2022
1 parent a4e30aa commit 33de02a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ private SkyValue createSourceValue(Artifact artifact, Environment env)
return new MissingArtifactValue(artifact);
}

if (fileValue.isDirectory()) {
env.getListener().post(SourceDirectoryEvent.create(artifact.getExecPath()));
}

if (!fileValue.isDirectory() || !TrackSourceDirectoriesFlag.trackSourceDirectories()) {
FileArtifactValue metadata;
try {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/google/devtools/build/lib/skyframe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,16 @@ java_library(
],
)

java_library(
name = "source_directory_event",
srcs = ["SourceDirectoryEvent.java"],
deps = [
"//src/main/java/com/google/devtools/build/lib/events",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//third_party:auto_value",
],
)

java_library(
name = "artifact_function",
srcs = ["ArtifactFunction.java"],
Expand All @@ -625,6 +635,7 @@ java_library(
":metadata_consumer_for_metrics",
":recursive_filesystem_traversal",
":runfiles_artifact_value",
":source_directory_event",
":track_source_directories_flag",
":tree_artifact_value",
"//src/main/java/com/google/devtools/build/lib/actions",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2015 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.devtools.build.lib.skyframe;

import com.google.auto.value.AutoValue;
import com.google.devtools.build.lib.events.ExtendedEventHandler.ProgressLike;
import com.google.devtools.build.lib.vfs.PathFragment;

/** Event issued when a source directory is encountered in {@link ArtifactFunction}. */
@AutoValue
public abstract class SourceDirectoryEvent implements ProgressLike {
public abstract PathFragment execPath();

public static SourceDirectoryEvent create(PathFragment execPath) {
return new AutoValue_SourceDirectoryEvent(execPath);
}
}

0 comments on commit 33de02a

Please sign in to comment.