Skip to content

Commit

Permalink
Merge branch 'master' into six
Browse files Browse the repository at this point in the history
  • Loading branch information
aiuto authored Oct 4, 2024
2 parents a2485ed + e5ab94b commit 736ff7f
Show file tree
Hide file tree
Showing 86 changed files with 483 additions and 4,596 deletions.
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ genrule(
"//third_party:rules_jvm_external_6.0.patch",
"//third_party/protobuf:BUILD",
"//third_party/protobuf:remove_rules_rust.patch",
"//third_party/protobuf:add_python_loads.patch",
],
outs = ["MODULE.bazel.lock.dist"],
cmd = " && ".join([
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ archive_override(
# Temporarily patch out rules_rust stuff from protobuf. Not just because we don't need it,
# but also because it introduces huge dependency bloat: rules_rust -> aspect_rules_js ->
# aspect_rules_lint -> rules_buf.
patches = ["//third_party/protobuf:remove_rules_rust.patch"],
patches = ["//third_party/protobuf:remove_rules_rust.patch", "//third_party/protobuf:add_python_loads.patch"],
strip_prefix = "protobuf-3b62052186d39775090fb074adcba078ea622f54",
urls = ["https://github.com/protocolbuffers/protobuf/archive/3b62052186d39775090fb074adcba078ea622f54.zip"],
)
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ rule_size_test(
# WARNING: Only adjust the number in `expect` if you are intentionally
# adding or removing embedded tools. Know that the more embedded tools there
# are in Bazel, the bigger the binary becomes and the slower Bazel starts.
expect = 421,
expect = 445,
margin = 5, # percentage
)

Expand Down Expand Up @@ -604,7 +604,6 @@ filegroup(
"@rules_java//:WORKSPACE",
"@rules_license//:WORKSPACE",
"@rules_pkg//:WORKSPACE",
"@rules_proto//proto:defs",
"@rules_python//:WORKSPACE",
"@rules_testing//:LICENSE",
] + select({
Expand Down
1 change: 0 additions & 1 deletion src/MODULE.tools
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
module(name = "bazel_tools")

bazel_dep(name = "rules_license", version = "0.0.7")
bazel_dep(name = "rules_proto", version = "6.0.2")

bazel_dep(name = "buildozer", version = "7.1.2")
bazel_dep(name = "platforms", version = "0.0.10")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ private List<RuleFamily> filterRuleFamilies(
List<RuleFamily> ruleFamilies = new ArrayList<>(ruleFamilyNames.size());
for (String name : ruleFamilyNames) {
ListMultimap<RuleType, RuleDocumentation> ruleTypeMap = ruleMapping.get(name);
ruleFamilies.add(new RuleFamily(ruleTypeMap, name, familySummary.get(name).toString()));
ruleFamilies.add(
new RuleFamily(
ruleTypeMap, name, familySummary.getOrDefault(name, new StringBuilder()).toString()));
}
return ruleFamilies;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/actions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/worker:worker_key",
"//src/main/java/com/google/devtools/build/lib/worker:worker_pool",
"//src/main/java/com/google/devtools/build/lib/worker:worker_process_status",
"//src/main/protobuf:failure_details_java_proto",
"//third_party:auto_value",
"//third_party:error_prone_annotations",
"//third_party:flogger",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public static FilesetOutputSymlink createAlreadyRelativized(
HasDigest metadata,
boolean isRelativeToExecRoot,
@Nullable PathFragment enclosingTreeArtifactExecPath) {
checkArgument(!name.isEmpty(), "Empty symlink name pointing to %s", target);
checkArgument(!target.isEmpty(), "Empty symlink target for %s", name);
return new AutoValue_FilesetOutputSymlink(
name, target, metadata, isRelativeToExecRoot, enclosingTreeArtifactExecPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.devtools.build.lib.profiler.AutoProfiler;
import com.google.devtools.build.lib.profiler.Profiler;
import com.google.devtools.build.lib.profiler.ProfilerTask;
import com.google.devtools.build.lib.server.FailureDetails;
import com.google.devtools.build.lib.worker.Worker;
import com.google.devtools.build.lib.worker.WorkerKey;
import com.google.devtools.build.lib.worker.WorkerPool;
Expand All @@ -38,7 +39,6 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -368,14 +368,16 @@ record ResourceRequest(
*/
public ResourceHandle acquireResources(
ActionExecutionMetadata owner, ResourceSet resources, ResourcePriority priority)
throws InterruptedException, IOException {
throws InterruptedException, IOException, ExecException {
Preconditions.checkNotNull(
resources, "acquireResources called with resources == NULL during %s", owner);
Preconditions.checkState(
!threadHasResources(), "acquireResources with existing resource lock during %s", owner);

ResourceLatch resourceLatch = null;

// Validate requested resources exist before creating a request.
assertResourcesTracked(resources);
ResourceRequest request =
new ResourceRequest(owner, resources, priority, requestIdGenerator.getAndIncrement());

Expand Down Expand Up @@ -590,12 +592,24 @@ private synchronized void processWaitingRequests(Deque<WaitingRequest> requests)
}

/** Throws an exception if requested extra resource isn't being tracked */
private void assertResourcesTracked(ResourceSet resources) throws NoSuchElementException {
private void assertResourcesTracked(ResourceSet resources) throws ExecException {
for (Map.Entry<String, Double> resource : resources.getResources().entrySet()) {
String key = resource.getKey();
if (!availableResources.getResources().containsKey(key)) {
throw new NoSuchElementException(
"Resource " + key + " is not tracked in this resource set.");
StringBuilder message = new StringBuilder();
message.append("Resource ");
message.append(key);
message.append(" is not being tracked by the resource manager.");
message.append(" Available resources are: ");
message.append(String.join(", ", availableResources.getResources().keySet()));
throw new UserExecException(
FailureDetails.FailureDetail.newBuilder()
.setMessage(message.toString())
.setLocalExecution(
FailureDetails.LocalExecution.newBuilder()
.setCode(FailureDetails.LocalExecution.Code.UNTRACKED_RESOURCE)
.build())
.build());
}
}
}
Expand Down Expand Up @@ -625,10 +639,6 @@ synchronized boolean areResourcesAvailable(ResourceSet resources) {
return false;
}

// We test for tracking of extra resources whenever acquired and throw an
// exception before acquiring any untracked resource.
assertResourcesTracked(resources);

if (usedResources.isEmpty() && usedLocalTestCount == 0) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.devtools.build.lib.analysis.config.transitions.NoConfigTransition;
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.packages.RuleClass.ToolchainResolutionMode;
import com.google.devtools.build.lib.packages.Types;
import com.google.devtools.build.lib.util.FileTypeSet;
Expand Down Expand Up @@ -72,6 +73,9 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
public Metadata getMetadata() {
return RuleDefinition.Metadata.builder()
.name(ConstraintConstants.ENVIRONMENT_RULE)
// Not allowed in symbolic macros: lazy expansion of symbolic macros could hide environment
// targets from environment groups.
.type(RuleClassType.BUILD_ONLY)
.ancestors(BaseRuleClasses.NativeBuildRule.class)
.factoryClass(Environment.class)
.build();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/util:abrupt_exit_exception",
"//src/main/java/com/google/devtools/build/lib/util:detailed_exit_code",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/protobuf:failure_details_java_proto",
"//third_party:guava",
"//third_party:jsr305",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.google.devtools.build.lib.util.AbruptExitException;
import com.google.devtools.build.lib.util.DetailedExitCode;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.io.IOException;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -94,11 +95,10 @@ private void initOutputs(CommandEnvironment env) throws IOException {
return;
}

Path workingDirectory = env.getWorkingDirectory();
Path outputBase = env.getOutputBase();

if (executionOptions.executionLogCompactFile != null) {
outputPath = workingDirectory.getRelative(executionOptions.executionLogCompactFile);
outputPath = getAbsolutePath(executionOptions.executionLogCompactFile, env);

try {
spawnLogContext =
Expand All @@ -121,10 +121,10 @@ private void initOutputs(CommandEnvironment env) throws IOException {

if (executionOptions.executionLogBinaryFile != null) {
encoding = Encoding.BINARY;
outputPath = workingDirectory.getRelative(executionOptions.executionLogBinaryFile);
outputPath = getAbsolutePath(executionOptions.executionLogBinaryFile, env);
} else if (executionOptions.executionLogJsonFile != null) {
encoding = Encoding.JSON;
outputPath = workingDirectory.getRelative(executionOptions.executionLogJsonFile);
outputPath = getAbsolutePath(executionOptions.executionLogJsonFile, env);
}

// Use a well-known temporary path to avoid accumulation of potentially large files in /tmp
Expand All @@ -144,6 +144,25 @@ private void initOutputs(CommandEnvironment env) throws IOException {
}
}

/**
* If the given path is absolute path, leave it as it is. If the given path is a relative path, it
* is relative to the current working directory. If the given path starts with '%workspace%, it is
* relative to the workspace root, which is the output of `bazel info workspace`.
*
* @return Absolute Path
*/
private Path getAbsolutePath(PathFragment path, CommandEnvironment env) {
String pathString = path.getPathString();
if (env.getWorkspace() != null) {
pathString = pathString.replace("%workspace%", env.getWorkspace().getPathString());
}
if (!PathFragment.isAbsolute(pathString)) {
return env.getWorkingDirectory().getRelative(pathString);
}

return env.getRuntime().getFileSystem().getPath(pathString);
}

@Override
public void registerActionContexts(
ModuleActionContextRegistry.Builder registryBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ gen_workspace_stanza(
"rules_cc", # For auto-load cc rules symbols
"rules_python", # For auto-load python rules symbols
"rules_license", # for license attestations
"rules_proto",
],
use_maybe = 1,
visibility = ["//:__pkg__"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.ActionEnvironment;
import com.google.devtools.build.lib.analysis.BaseRuleClasses;
import com.google.devtools.build.lib.analysis.BaseRuleClasses.EmptyRule;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.RuleSet;
import com.google.devtools.build.lib.analysis.PackageSpecificationProvider;
Expand All @@ -36,10 +35,7 @@
import com.google.devtools.build.lib.analysis.config.RequiresOptions;
import com.google.devtools.build.lib.bazel.BazelConfiguration;
import com.google.devtools.build.lib.bazel.repository.LocalConfigPlatformRule;
import com.google.devtools.build.lib.bazel.rules.python.BazelPyBinaryRule;
import com.google.devtools.build.lib.bazel.rules.python.BazelPyBuiltins;
import com.google.devtools.build.lib.bazel.rules.python.BazelPyRuleClasses;
import com.google.devtools.build.lib.bazel.rules.python.BazelPyTestRule;
import com.google.devtools.build.lib.bazel.rules.python.BazelPythonConfiguration;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.packages.PackageCallable;
Expand All @@ -53,7 +49,6 @@
import com.google.devtools.build.lib.rules.platform.PlatformRules;
import com.google.devtools.build.lib.rules.proto.BazelProtoCommon;
import com.google.devtools.build.lib.rules.proto.ProtoConfiguration;
import com.google.devtools.build.lib.rules.python.PyRuntimeRule;
import com.google.devtools.build.lib.rules.python.PythonConfiguration;
import com.google.devtools.build.lib.rules.repository.CoreWorkspaceRules;
import com.google.devtools.build.lib.rules.repository.NewLocalRepositoryRule;
Expand Down Expand Up @@ -316,13 +311,6 @@ public void init(ConfiguredRuleClassProvider.Builder builder) {
builder.addConfigurationFragment(PythonConfiguration.class);
builder.addConfigurationFragment(BazelPythonConfiguration.class);

builder.addRuleDefinition(new BazelPyRuleClasses.PyBaseRule());
builder.addRuleDefinition(new BazelPyRuleClasses.PyBinaryBaseRule());
builder.addRuleDefinition(new EmptyRule("py_library") {});
builder.addRuleDefinition(new BazelPyBinaryRule());
builder.addRuleDefinition(new BazelPyTestRule());
builder.addRuleDefinition(new PyRuntimeRule());

// This symbol is overridden by exports.bzl
builder.addBzlToplevel(
"py_internal",
Expand All @@ -333,7 +321,8 @@ public void init(ConfiguredRuleClassProvider.Builder builder) {

try {
builder.addWorkspaceFileSuffix(
ResourceFileLoader.loadResource(BazelPyBinaryRule.class, "python.WORKSPACE"));
ResourceFileLoader.loadResource(
BazelPythonConfiguration.class, "python.WORKSPACE"));
} catch (IOException e) {
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,15 @@ public static final class BazelBuildGraveyardOptions extends BuildGraveyardOptio
+ " https://blog.bazel.build/2023/11/15/android-platforms.html for details and"
+ " migration directions";

@Option(
name = "android_sdk",
defaultValue = "",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN},
help = "No-op",
deprecationWarning = ANDROID_FLAG_DEPRECATION)
public String sdk;

@Option(
name = "android_cpu",
defaultValue = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void init(ConfiguredRuleClassProvider.Builder builder) {
builder.addConfigurationFragment(AppleConfiguration.class);
// j2objc shouldn't be here!
builder.addConfigurationFragment(J2ObjcConfiguration.class);
builder.addRuleDefinition(new EmptyRule("j2objc_library") {});

builder.addRuleDefinition(new EmptyRule("objc_import") {});
builder.addRuleDefinition(new EmptyRule("objc_library") {});
Expand Down
Loading

0 comments on commit 736ff7f

Please sign in to comment.