diff --git a/MODULE.bazel b/MODULE.bazel index dd3094f00effb9..f7ad0d88a95817 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -12,7 +12,7 @@ bazel_dep(name = "rules_license", version = "0.0.3") bazel_dep(name = "bazel_skylib", version = "1.2.0") bazel_dep(name = "protobuf", version = "3.19.6", repo_name = "com_google_protobuf") bazel_dep(name = "grpc", version = "1.47.0", repo_name = "com_github_grpc_grpc") -bazel_dep(name = "platforms", version = "0.0.5") +bazel_dep(name = "platforms", version = "0.0.7") bazel_dep(name = "rules_pkg", version = "0.7.0") bazel_dep(name = "stardoc", version = "0.5.0", repo_name = "io_bazel_skydoc") bazel_dep(name = "zstd-jni", version = "1.5.2-3") diff --git a/distdir_deps.bzl b/distdir_deps.bzl index 712d75cffa8acd..4598ea7803e94c 100644 --- a/distdir_deps.bzl +++ b/distdir_deps.bzl @@ -25,16 +25,17 @@ DIST_DEPS = { # ######################################## "platforms": { - "archive": "platforms-0.0.5.tar.gz", - "sha256": "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407", + "archive": "platforms-0.0.7.tar.gz", + "sha256": "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51", "urls": [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", ], "used_in": [ "additional_distfiles", "test_WORKSPACE_files", ], + "package_version": "0.0.7", }, "bazelci_rules": { "archive": "bazelci_rules-1.0.0.tar.gz", diff --git a/scripts/release/relnotes.py b/scripts/release/relnotes.py index da3c9fe1ad0678..a90c4335855083 100644 --- a/scripts/release/relnotes.py +++ b/scripts/release/relnotes.py @@ -26,7 +26,14 @@ def git(*args): list(args)).decode("utf-8").strip().split("\n") -def extract_relnotes(commit_message_lines, is_major_release): +def extract_pr_title(commit_message_lines): + """Extracts first line from commit message (passed in as a list of lines).""" + return re.sub( + r"\[\d+\.\d+\.\d\]\s?", "", commit_message_lines[0].strip() + ) + + +def extract_relnotes(commit_message_lines): """Extracts relnotes from a commit message (passed in as a list of lines).""" relnote_lines = [] in_relnote = False @@ -45,18 +52,7 @@ def extract_relnotes(commit_message_lines, is_major_release): relnote = " ".join(relnote_lines) relnote_lower = relnote.strip().lower().rstrip(".") if relnote_lower == "n/a" or relnote_lower == "none" or not relnote_lower: - if is_major_release: - return None - relnote = re.sub( - r"\[\d+\.\d+\.\d\]\s?", "", commit_message_lines[0].strip() - ) - else: - issue_id = re.search( - r"\(\#[0-9]+\)$", commit_message_lines[0].strip().split()[-1] - ) - if issue_id: - relnote = relnote + " " + issue_id.group(0).strip() - + return None return relnote @@ -78,7 +74,9 @@ def get_relnotes_between(base, head, is_major_release): rolled_back_commits.add(m[1]) # The rollback commit itself is also skipped. continue - relnote = extract_relnotes(lines, is_major_release) + relnote = ( + extract_relnotes(lines) if is_major_release else extract_pr_title(lines) + ) if relnote is not None: relnotes.append(relnote) return relnotes diff --git a/src/MODULE.tools b/src/MODULE.tools index b82be48982cb08..65937922ecfa73 100644 --- a/src/MODULE.tools +++ b/src/MODULE.tools @@ -6,7 +6,7 @@ bazel_dep(name = "rules_license", version = "0.0.3") bazel_dep(name = "rules_proto", version = "4.0.0") bazel_dep(name = "rules_python", version = "0.4.0") -bazel_dep(name = "platforms", version = "0.0.4") +bazel_dep(name = "platforms", version = "0.0.7") bazel_dep(name = "protobuf", version = "3.19.6", repo_name = "com_google_protobuf") bazel_dep(name = "zlib", version = "1.2.13") diff --git a/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm b/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm index 38d7385cf630cd..fb745de8d49aab 100644 --- a/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm +++ b/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm @@ -33,7 +33,7 @@ #end
  • AppEngine
  • -
  • Apple (Swift, iOS, macOS, tvOS, watchOS)
  • +
  • Apple (Swift, iOS, macOS, tvOS, visionOS, watchOS)
  • C#
  • D
  • Docker
  • diff --git a/src/main/java/com/google/devtools/build/docgen/templates/be/be-toc.vm b/src/main/java/com/google/devtools/build/docgen/templates/be/be-toc.vm index bb0d01f416fbea..3821dc6d00fbc6 100644 --- a/src/main/java/com/google/devtools/build/docgen/templates/be/be-toc.vm +++ b/src/main/java/com/google/devtools/build/docgen/templates/be/be-toc.vm @@ -20,7 +20,7 @@ toc: - title: AppEngine path: https://github.com/bazelbuild/rules_appengine status: external - - title: Apple (Swift, iOS, macOS, tvOS, watchOS) + - title: Apple (Swift, iOS, macOS, tvOS, visionOS, watchOS) path: https://github.com/bazelbuild/rules_apple status: external - title: C# diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java index 43d34f565f99ff..c2c1cfe9b46736 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java @@ -28,6 +28,7 @@ import com.google.common.collect.Interner; import com.google.common.collect.Iterables; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.collect.Sets; import com.google.devtools.build.lib.actions.AbstractAction; import com.google.devtools.build.lib.actions.ActionContinuationOrResult; import com.google.devtools.build.lib.actions.ActionEnvironment; @@ -683,7 +684,6 @@ public static class Builder { private final List outputs = new ArrayList<>(); private final List inputRunfilesSuppliers = new ArrayList<>(); private ResourceSetOrBuilder resourceSetOrBuilder = AbstractAction.DEFAULT_RESOURCE_SET; - private ActionEnvironment actionEnvironment = null; private ImmutableMap environment = ImmutableMap.of(); private ImmutableSet inheritedEnvironment = ImmutableSet.of(); private ImmutableMap executionInfo = ImmutableMap.of(); @@ -717,7 +717,6 @@ public Builder(Builder other) { this.outputs.addAll(other.outputs); this.inputRunfilesSuppliers.addAll(other.inputRunfilesSuppliers); this.resourceSetOrBuilder = other.resourceSetOrBuilder; - this.actionEnvironment = other.actionEnvironment; this.environment = other.environment; this.executionInfo = other.executionInfo; this.isShellCommand = other.isShellCommand; @@ -762,12 +761,31 @@ public SpawnAction build(ActionOwner owner, BuildConfigurationValue configuratio result.addCommandLine(pair); } CommandLines commandLines = result.build(); - ActionEnvironment env = - actionEnvironment != null - ? actionEnvironment - : useDefaultShellEnvironment - ? configuration.getActionEnvironment() - : ActionEnvironment.create(environment, inheritedEnvironment); + ActionEnvironment env; + if (useDefaultShellEnvironment && environment != null) { + // Inherited variables override fixed variables in ActionEnvironment. Since we want the + // fixed part of the action-provided environment to override the inherited part of the + // user-provided environment, we have to explicitly filter the inherited part. + var userFilteredInheritedEnv = + ImmutableSet.copyOf( + Sets.difference( + configuration.getActionEnvironment().getInheritedEnv(), environment.keySet())); + // Do not create a new ActionEnvironment in the common case where no vars have been filtered + // out. + if (userFilteredInheritedEnv.equals( + configuration.getActionEnvironment().getInheritedEnv())) { + env = configuration.getActionEnvironment(); + } else { + env = + ActionEnvironment.create( + configuration.getActionEnvironment().getFixedEnv(), userFilteredInheritedEnv); + } + env = env.withAdditionalFixedVariables(environment); + } else if (useDefaultShellEnvironment) { + env = configuration.getActionEnvironment(); + } else { + env = ActionEnvironment.create(environment, inheritedEnvironment); + } return buildSpawnAction( owner, commandLines, configuration.getCommandLineLimits(), configuration, env); } @@ -984,13 +1002,6 @@ public Builder setResources(ResourceSetOrBuilder resourceSetOrBuilder) { return this; } - /** Sets the action environment. */ - @CanIgnoreReturnValue - public Builder setEnvironment(ActionEnvironment actionEnvironment) { - this.actionEnvironment = actionEnvironment; - return this; - } - /** * Sets the map of environment variables. Do not use! This makes the builder ignore the 'default * shell environment', which is computed from the --action_env command line option. @@ -1075,6 +1086,18 @@ public Builder executeUnconditionally() { return this; } + /** + * Same as {@link #useDefaultShellEnvironment()}, but additionally sets the provided fixed + * environment variables, which take precedence over the variables contained in the default + * shell environment. + */ + @CanIgnoreReturnValue + public Builder useDefaultShellEnvironmentWithOverrides(Map environment) { + this.environment = ImmutableMap.copyOf(environment); + this.useDefaultShellEnvironment = true; + return this; + } + /** * Sets the executable path; the path is interpreted relative to the execution root, unless it's * a bare file name. diff --git a/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/PackageGroupConfiguredTarget.java b/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/PackageGroupConfiguredTarget.java index f2327eae22b61a..56291e51dabaa5 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/PackageGroupConfiguredTarget.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/PackageGroupConfiguredTarget.java @@ -14,15 +14,11 @@ package com.google.devtools.build.lib.analysis.configuredtargets; -import static net.starlark.java.eval.Module.ofInnermostEnclosingStarlarkFunction; - import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.analysis.Allowlist; import com.google.devtools.build.lib.analysis.FileProvider; import com.google.devtools.build.lib.analysis.PackageSpecificationProvider; import com.google.devtools.build.lib.analysis.TargetContext; import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; -import com.google.devtools.build.lib.cmdline.BazelModuleContext; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.collect.nestedset.NestedSet; @@ -32,12 +28,6 @@ import com.google.devtools.build.lib.packages.PackageSpecification.PackageGroupContents; import com.google.devtools.build.lib.packages.Provider; import javax.annotation.Nullable; -import net.starlark.java.annot.Param; -import net.starlark.java.annot.ParamType; -import net.starlark.java.annot.StarlarkMethod; -import net.starlark.java.eval.EvalException; -import net.starlark.java.eval.Starlark; -import net.starlark.java.eval.StarlarkThread; /** * Dummy ConfiguredTarget for package groups. Contains no functionality, since package groups are @@ -86,24 +76,4 @@ protected Info rawGetStarlarkProvider(Provider.Key providerKey) { protected Object rawGetStarlarkProvider(String providerKey) { return null; } - - @StarlarkMethod( - name = "isAvailableFor", - documented = false, - parameters = { - @Param( - name = "label", - allowedTypes = {@ParamType(type = Label.class)}) - }, - useStarlarkThread = true) - public boolean starlarkMatches(Label label, StarlarkThread starlarkThread) throws EvalException { - RepositoryName repository = - BazelModuleContext.of(ofInnermostEnclosingStarlarkFunction(starlarkThread)) - .label() - .getRepository(); - if (!"@_builtins".equals(repository.getNameWithAt())) { - throw Starlark.errorf("private API only for use by builtins"); - } - return Allowlist.isAvailableFor(packageSpecificationProvider.getPackageSpecifications(), label); - } } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkActionFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkActionFactory.java index ca8d46a9ce1671..b6058da30c971b 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkActionFactory.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkActionFactory.java @@ -671,15 +671,24 @@ private void registerStarlarkAction( } catch (IllegalArgumentException e) { throw Starlark.errorf("%s", e.getMessage()); } - if (envUnchecked != Starlark.NONE) { - builder.setEnvironment( - ImmutableMap.copyOf(Dict.cast(envUnchecked, String.class, String.class, "env"))); - } if (progressMessage != Starlark.NONE) { builder.setProgressMessageFromStarlark((String) progressMessage); } + + ImmutableMap env = null; + if (envUnchecked != Starlark.NONE) { + env = ImmutableMap.copyOf(Dict.cast(envUnchecked, String.class, String.class, "env")); + } if (Starlark.truth(useDefaultShellEnv)) { - builder.useDefaultShellEnvironment(); + if (env != null + && getSemantics() + .getBool(BuildLanguageOptions.INCOMPATIBLE_MERGE_FIXED_AND_DEFAULT_SHELL_ENV)) { + builder.useDefaultShellEnvironmentWithOverrides(env); + } else { + builder.useDefaultShellEnvironment(); + } + } else if (env != null) { + builder.setEnvironment(env); } RuleContext ruleContext = getRuleContext(); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java index eecf41a30ecd59..04907ba1d2da6c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java @@ -162,7 +162,7 @@ private static String moduleFileContent(String repositoryName) { "module(name = \"%s\")", // Try to keep this updated with the src/MODULE.tools file. (Due to MVS, even if this is // not kept up to date, we'll use the latest version anyhow) - "bazel_dep(name = \"platforms\", version = \"0.0.4\")"), + "bazel_dep(name = \"platforms\", version = \"0.0.7\")"), repositoryName); } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java index d11631b4556502..1285c1a2807f5c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java @@ -278,7 +278,7 @@ public class RepositoryOptions extends OptionsBase { @Option( name = "lockfile_mode", converter = LockfileMode.Converter.class, - defaultValue = "update", + defaultValue = "off", documentationCategory = OptionDocumentationCategory.BZLMOD, effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, help = diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java index 88cfe1b0f5e960..ccb470d373d1d0 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java @@ -15,10 +15,12 @@ import build.bazel.remote.execution.v2.Platform; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; import com.google.common.flogger.GoogleLogger; import com.google.common.hash.HashCode; import com.google.devtools.build.lib.actions.ActionContext; import com.google.devtools.build.lib.actions.ActionInput; +import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.MetadataProvider; @@ -100,6 +102,8 @@ public void logSpawn( builder.addEnvironmentVariablesBuilder().setName(var).setValue(env.get(var)); } + ImmutableSet toolFiles = spawn.getToolFiles().toSet(); + try { for (Map.Entry e : inputMap.entrySet()) { ActionInput input = e.getValue(); @@ -111,7 +115,15 @@ public void logSpawn( listDirectoryContents(inputPath, builder::addInputs, metadataProvider); } else { Digest digest = computeDigest(input, null, metadataProvider, xattrProvider); - builder.addInputsBuilder().setPath(input.getExecPathString()).setDigest(digest); + boolean isTool = + toolFiles.contains(input) + || (input instanceof TreeFileArtifact + && toolFiles.contains(((TreeFileArtifact) input).getParent())); + builder + .addInputsBuilder() + .setPath(input.getExecPathString()) + .setDigest(digest) + .setIsTool(isTool); } } } catch (IOException e) { diff --git a/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java b/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java index 2259ab5a68e7d5..469427b6f32856 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java +++ b/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java @@ -662,6 +662,19 @@ public final class BuildLanguageOptions extends OptionsBase { help = "If enabled, targets that have unknown attributes set to None fail.") public boolean incompatibleFailOnUnknownAttributes; + @Option( + name = "incompatible_merge_fixed_and_default_shell_env", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS, + effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + help = + "If enabled, actions registered with ctx.actions.run and ctx.actions.run_shell with both" + + " 'env' and 'use_default_shell_env = True' specified will use an environment" + + " obtained from the default shell environment by overriding with the values passed" + + " in to 'env'. If disabled, the value of 'env' is completely ignored in this case.") + public boolean incompatibleMergeFixedAndDefaultShellEnv; + @Option( name = "incompatible_disable_objc_library_transition", defaultValue = "false", @@ -765,6 +778,9 @@ public StarlarkSemantics toStarlarkSemantics() { EXPERIMENTAL_GET_FIXED_CONFIGURED_ACTION_ENV, experimentalGetFixedConfiguredEnvironment) .setBool(INCOMPATIBLE_FAIL_ON_UNKNOWN_ATTRIBUTES, incompatibleFailOnUnknownAttributes) + .setBool( + INCOMPATIBLE_MERGE_FIXED_AND_DEFAULT_SHELL_ENV, + incompatibleMergeFixedAndDefaultShellEnv) .setBool( INCOMPATIBLE_DISABLE_OBJC_LIBRARY_TRANSITION, incompatibleDisableObjcLibraryTransition) @@ -858,6 +874,8 @@ public StarlarkSemantics toStarlarkSemantics() { "-experimental_get_fixed_configured_action_env"; public static final String INCOMPATIBLE_FAIL_ON_UNKNOWN_ATTRIBUTES = "-incompatible_fail_on_unknown_attributes"; + public static final String INCOMPATIBLE_MERGE_FIXED_AND_DEFAULT_SHELL_ENV = + "-experimental_merge_fixed_and_default_shell_env"; public static final String INCOMPATIBLE_DISABLE_OBJC_LIBRARY_TRANSITION = "-incompatible_disable_objc_library_transition"; diff --git a/src/main/java/com/google/devtools/build/lib/remote/BUILD b/src/main/java/com/google/devtools/build/lib/remote/BUILD index 4dd5629f1b1a49..04a36e0b999904 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/BUILD +++ b/src/main/java/com/google/devtools/build/lib/remote/BUILD @@ -117,6 +117,7 @@ java_library( "//src/main/java/com/google/devtools/build/skyframe", "//src/main/java/com/google/devtools/common/options", "//src/main/protobuf:failure_details_java_proto", + "//src/main/protobuf:spawn_java_proto", "//third_party:auth", "//third_party:caffeine", "//third_party:flogger", diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java index c3545b669c338a..ecf8f50166b880 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java @@ -77,6 +77,7 @@ import com.google.devtools.build.lib.buildtool.buildevent.BuildInterruptedEvent; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.Reporter; +import com.google.devtools.build.lib.exec.Protos.CacheSalt; import com.google.devtools.build.lib.exec.SpawnInputExpander.InputWalker; import com.google.devtools.build.lib.exec.SpawnRunner.SpawnExecutionContext; import com.google.devtools.build.lib.exec.local.LocalEnvProvider; @@ -475,18 +476,16 @@ public MerkleTree uncachedBuildMerkleTreeVisitor( @Nullable private static ByteString buildSalt(Spawn spawn) { + CacheSalt.Builder saltBuilder = + CacheSalt.newBuilder().setMayBeExecutedRemotely(Spawns.mayBeExecutedRemotely(spawn)); + String workspace = spawn.getExecutionInfo().get(ExecutionRequirements.DIFFERENTIATE_WORKSPACE_CACHE); if (workspace != null) { - Platform platform = - Platform.newBuilder() - .addProperties( - Platform.Property.newBuilder().setName("workspace").setValue(workspace).build()) - .build(); - return platform.toByteString(); + saltBuilder.setWorkspace(workspace); } - return null; + return saltBuilder.build().toByteString(); } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java index 794df2293f98a1..55dc7595c95a6c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java @@ -192,6 +192,10 @@ public class AppleCommandLineOptions extends FragmentOptions { @VisibleForTesting public static final String DEFAULT_TVOS_SDK_VERSION = "9.0"; @VisibleForTesting static final String DEFAULT_IOS_CPU = "x86_64"; + /** The default visionOS CPU value. */ + public static final String DEFAULT_VISIONOS_CPU = + CPU.getCurrent() == CPU.AARCH64 ? "sim_arm64" : "x86_64"; + /** The default watchos CPU value. */ public static final String DEFAULT_WATCHOS_CPU = CPU.getCurrent() == CPU.AARCH64 ? "arm64" : "i386"; @@ -297,6 +301,16 @@ public class AppleCommandLineOptions extends FragmentOptions { + "is a universal binary containing all specified architectures.") public List iosMultiCpus; + @Option( + name = "visionos_cpus", + allowMultiple = true, + converter = CommaSeparatedOptionListConverter.class, + defaultValue = "null", + documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, + effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE, OptionEffectTag.LOADING_AND_ANALYSIS}, + help = "Comma-separated list of architectures for which to build Apple visionOS binaries.") + public List visionosCpus; + @Option( name = "watchos_cpus", allowMultiple = true, @@ -420,6 +434,10 @@ public DottedVersion getMinimumOsVersion() { case TVOS: option = tvosMinimumOs; break; + case VISIONOS: + // TODO: Replace with CppOptions.minimumOsVersion + option = DottedVersion.option(DottedVersion.fromStringUnchecked("1.0")); + break; case WATCHOS: option = watchosMinimumOs; break; diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java index dc7abdb202d7b8..beb2d9f2c000aa 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java @@ -115,6 +115,10 @@ public static AppleCpus create(AppleCommandLineOptions options, CoreOptions core (options.iosMultiCpus == null || options.iosMultiCpus.isEmpty()) ? ImmutableList.of(iosCpuFromCpu(coreOptions.cpu)) : ImmutableList.copyOf(options.iosMultiCpus); + ImmutableList visionosCpus = + (options.visionosCpus == null || options.visionosCpus.isEmpty()) + ? ImmutableList.of(AppleCommandLineOptions.DEFAULT_VISIONOS_CPU) + : ImmutableList.copyOf(options.visionosCpus); ImmutableList watchosCpus = (options.watchosCpus == null || options.watchosCpus.isEmpty()) ? ImmutableList.of(AppleCommandLineOptions.DEFAULT_WATCHOS_CPU) @@ -133,13 +137,21 @@ public static AppleCpus create(AppleCommandLineOptions options, CoreOptions core : ImmutableList.copyOf(options.catalystCpus); return new AutoValue_AppleConfiguration_AppleCpus( - appleSplitCpu, iosMultiCpus, watchosCpus, tvosCpus, macosCpus, catalystCpus); + appleSplitCpu, + iosMultiCpus, + visionosCpus, + watchosCpus, + tvosCpus, + macosCpus, + catalystCpus); } abstract String appleSplitCpu(); abstract ImmutableList iosMultiCpus(); + abstract ImmutableList visionosCpus(); + abstract ImmutableList watchosCpus(); abstract ImmutableList tvosCpus(); @@ -248,6 +260,8 @@ private static String getPrefixedAppleCpu(PlatformType applePlatformType, AppleC switch (applePlatformType) { case IOS: return appleCpus.iosMultiCpus().get(0); + case VISIONOS: + return appleCpus.visionosCpus().get(0); case WATCHOS: return appleCpus.watchosCpus().get(0); case TVOS: @@ -296,6 +310,8 @@ public List getMultiArchitectures(PlatformType platformType) { switch (platformType) { case IOS: return appleCpus.iosMultiCpus(); + case VISIONOS: + return appleCpus.visionosCpus(); case WATCHOS: return appleCpus.watchosCpus(); case TVOS: @@ -341,6 +357,14 @@ public ApplePlatform getMultiArchPlatform(PlatformType platformType) { } } return ApplePlatform.IOS_SIMULATOR; + case VISIONOS: + for (String arch : architectures) { + if (ApplePlatform.forTarget(PlatformType.VISIONOS, arch) + == ApplePlatform.VISIONOS_DEVICE) { + return ApplePlatform.VISIONOS_DEVICE; + } + } + return ApplePlatform.VISIONOS_SIMULATOR; case WATCHOS: for (String arch : architectures) { if (ApplePlatform.forTarget(PlatformType.WATCHOS, arch) == ApplePlatform.WATCHOS_DEVICE) { @@ -500,6 +524,8 @@ public enum ConfigurationDistinguisher implements StarlarkValue { UNKNOWN("unknown"), /** Distinguisher for {@code apple_binary} rule with "ios" platform_type. */ APPLEBIN_IOS("applebin_ios"), + /** Distinguisher for {@code apple_binary} rule with "visionos" platform_type. */ + APPLEBIN_VISIONOS("applebin_visionos"), /** Distinguisher for {@code apple_binary} rule with "watchos" platform_type. */ APPLEBIN_WATCHOS("applebin_watchos"), /** Distinguisher for {@code apple_binary} rule with "tvos" platform_type. */ diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java b/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java index a050bbd4fcfd5f..b7af54fb6a9923 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java @@ -37,6 +37,8 @@ public enum ApplePlatform implements ApplePlatformApi { MACOS("macos", "MacOSX", PlatformType.MACOS, true), TVOS_DEVICE("tvos_device", "AppleTVOS", PlatformType.TVOS, true), TVOS_SIMULATOR("tvos_simulator", "AppleTVSimulator", PlatformType.TVOS, false), + VISIONOS_DEVICE("visionos_device", "XROS", PlatformType.VISIONOS, true), + VISIONOS_SIMULATOR("visionos_simulator", "XRSimulator", PlatformType.VISIONOS, false), WATCHOS_DEVICE("watchos_device", "WatchOS", PlatformType.WATCHOS, true), WATCHOS_SIMULATOR("watchos_simulator", "WatchSimulator", PlatformType.WATCHOS, false), CATALYST("catalyst", "MacOSX", PlatformType.CATALYST, true); @@ -45,6 +47,10 @@ public enum ApplePlatform implements ApplePlatformApi { ImmutableSet.of("ios_x86_64", "ios_i386", "ios_sim_arm64"); private static final ImmutableSet IOS_DEVICE_TARGET_CPUS = ImmutableSet.of("ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s", "ios_arm64e"); + private static final ImmutableSet VISIONOS_SIMULATOR_TARGET_CPUS = + ImmutableSet.of("visionos_x86_64", "visionos_sim_arm64"); + private static final ImmutableSet VISIONOS_DEVICE_TARGET_CPUS = + ImmutableSet.of("visionos_arm64"); private static final ImmutableSet WATCHOS_SIMULATOR_TARGET_CPUS = ImmutableSet.of("watchos_i386", "watchos_x86_64", "watchos_arm64"); private static final ImmutableSet WATCHOS_DEVICE_TARGET_CPUS = @@ -138,6 +144,10 @@ private static ApplePlatform forTargetCpuNullable(String targetCpu) { return IOS_SIMULATOR; } else if (IOS_DEVICE_TARGET_CPUS.contains(targetCpu)) { return IOS_DEVICE; + } else if (VISIONOS_SIMULATOR_TARGET_CPUS.contains(targetCpu)) { + return VISIONOS_SIMULATOR; + } else if (VISIONOS_DEVICE_TARGET_CPUS.contains(targetCpu)) { + return VISIONOS_DEVICE; } else if (WATCHOS_SIMULATOR_TARGET_CPUS.contains(targetCpu)) { return WATCHOS_SIMULATOR; } else if (WATCHOS_DEVICE_TARGET_CPUS.contains(targetCpu)) { @@ -245,6 +255,7 @@ public UnsupportedPlatformTypeException(String msg) { @Immutable public enum PlatformType implements ApplePlatformTypeApi { IOS("ios"), + VISIONOS("visionos"), WATCHOS("watchos"), TVOS("tvos"), MACOS("macos"), diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java index d042ab80462c72..241a7ecdce91bd 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java @@ -114,6 +114,8 @@ public static String sdkFrameworkDir(ApplePlatform targetPlatform, XcodeConfigIn } break; case MACOS: + case VISIONOS_DEVICE: + case VISIONOS_SIMULATOR: case WATCHOS_DEVICE: case WATCHOS_SIMULATOR: case TVOS_DEVICE: diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfig.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfig.java index 5df242200393a5..b2ed13fc09a22d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfig.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfig.java @@ -126,6 +126,9 @@ public ConfiguredTarget create(RuleContext ruleContext) (appleOptions.iosMinimumOs != null) ? DottedVersion.maybeUnwrap(appleOptions.iosMinimumOs) : iosSdkVersion; + DottedVersion visionosSdkVersion = xcodeVersionProperties.getDefaultVisionosSdkVersion(); + // TODO: Replace with CppOptions.minimumOsVersion + DottedVersion visionosMinimumOsVersion = DottedVersion.fromStringUnchecked("1.0"); DottedVersion watchosSdkVersion = (appleOptions.watchOsSdkVersion != null) ? DottedVersion.maybeUnwrap(appleOptions.watchOsSdkVersion) @@ -155,6 +158,8 @@ public ConfiguredTarget create(RuleContext ruleContext) new XcodeConfigInfo( iosSdkVersion, iosMinimumOsVersion, + visionosSdkVersion, + visionosMinimumOsVersion, watchosSdkVersion, watchosMinimumOsVersion, tvosSdkVersion, diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfigInfo.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfigInfo.java index e5692368f3d940..d4ce9fbd2411d4 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfigInfo.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfigInfo.java @@ -39,6 +39,8 @@ public class XcodeConfigInfo extends NativeInfo private final DottedVersion iosSdkVersion; private final DottedVersion iosMinimumOsVersion; + private final DottedVersion visionosSdkVersion; + private final DottedVersion visionosMinimumOsVersion; private final DottedVersion watchosSdkVersion; private final DottedVersion watchosMinimumOsVersion; private final DottedVersion tvosSdkVersion; @@ -52,6 +54,8 @@ public class XcodeConfigInfo extends NativeInfo public XcodeConfigInfo( DottedVersion iosSdkVersion, DottedVersion iosMinimumOsVersion, + DottedVersion visionosSdkVersion, + DottedVersion visionosMinimumOsVersion, DottedVersion watchosSdkVersion, DottedVersion watchosMinimumOsVersion, DottedVersion tvosSdkVersion, @@ -64,6 +68,8 @@ public XcodeConfigInfo( boolean includeXcodeReqs) { this.iosSdkVersion = Preconditions.checkNotNull(iosSdkVersion); this.iosMinimumOsVersion = Preconditions.checkNotNull(iosMinimumOsVersion); + this.visionosSdkVersion = Preconditions.checkNotNull(visionosSdkVersion); + this.visionosMinimumOsVersion = Preconditions.checkNotNull(visionosMinimumOsVersion); this.watchosSdkVersion = Preconditions.checkNotNull(watchosSdkVersion); this.watchosMinimumOsVersion = Preconditions.checkNotNull(watchosMinimumOsVersion); this.tvosSdkVersion = Preconditions.checkNotNull(tvosSdkVersion); @@ -135,6 +141,8 @@ private XcodeConfigProvider() { public XcodeConfigInfoApi xcodeConfigInfo( String iosSdkVersion, String iosMinimumOsVersion, + String visionosSdkVersion, + String visionosMinimumOsVersion, String watchosSdkVersion, String watchosMinimumOsVersion, String tvosSdkVersion, @@ -147,6 +155,8 @@ private XcodeConfigProvider() { return new XcodeConfigInfo( DottedVersion.fromString(iosSdkVersion), DottedVersion.fromString(iosMinimumOsVersion), + DottedVersion.fromString(visionosSdkVersion), + DottedVersion.fromString(visionosMinimumOsVersion), DottedVersion.fromString(watchosSdkVersion), DottedVersion.fromString(watchosMinimumOsVersion), DottedVersion.fromString(tvosSdkVersion), @@ -195,6 +205,9 @@ public DottedVersion getMinimumOsForPlatformType(ApplePlatform.PlatformType plat return iosMinimumOsVersion; case TVOS: return tvosMinimumOsVersion; + case VISIONOS: + // TODO: Replace with CppOptions.minimumOsVersion + return DottedVersion.fromStringUnchecked("1.0"); case WATCHOS: return watchosMinimumOsVersion; case MACOS: @@ -216,6 +229,9 @@ public DottedVersion getSdkVersionForPlatform(ApplePlatform platform) { case TVOS_DEVICE: case TVOS_SIMULATOR: return tvosSdkVersion; + case VISIONOS_DEVICE: + case VISIONOS_SIMULATOR: + return visionosSdkVersion; case WATCHOS_DEVICE: case WATCHOS_SIMULATOR: return watchosSdkVersion; diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionProperties.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionProperties.java index f3e6e39e175423..22410e9887f0ab 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionProperties.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionProperties.java @@ -36,12 +36,14 @@ public class XcodeVersionProperties extends NativeInfo implements XcodePropertie new BuiltinProvider(STARLARK_NAME, XcodeVersionProperties.class) {}; @VisibleForTesting public static final String DEFAULT_IOS_SDK_VERSION = "8.4"; + @VisibleForTesting public static final String DEFAULT_VISIONOS_SDK_VERSION = "1.0"; @VisibleForTesting public static final String DEFAULT_WATCHOS_SDK_VERSION = "2.0"; @VisibleForTesting public static final String DEFAULT_MACOS_SDK_VERSION = "10.11"; @VisibleForTesting public static final String DEFAULT_TVOS_SDK_VERSION = "9.0"; private final Optional xcodeVersion; private final DottedVersion defaultIosSdkVersion; + private final DottedVersion defaultVisionosSdkVersion; private final DottedVersion defaultWatchosSdkVersion; private final DottedVersion defaultTvosSdkVersion; private final DottedVersion defaultMacosSdkVersion; @@ -63,7 +65,7 @@ public static XcodeVersionProperties unknownXcodeVersionProperties() { * specified. */ XcodeVersionProperties(DottedVersion xcodeVersion) { - this(xcodeVersion, null, null, null, null); + this(xcodeVersion, null, null, null, null, null); } /** @@ -73,6 +75,7 @@ public static XcodeVersionProperties unknownXcodeVersionProperties() { XcodeVersionProperties( DottedVersion xcodeVersion, @Nullable String defaultIosSdkVersion, + @Nullable String defaultVisionosSdkVersion, @Nullable String defaultWatchosSdkVersion, @Nullable String defaultTvosSdkVersion, @Nullable String defaultMacosSdkVersion) { @@ -81,6 +84,10 @@ public static XcodeVersionProperties unknownXcodeVersionProperties() { Strings.isNullOrEmpty(defaultIosSdkVersion) ? DottedVersion.fromStringUnchecked(DEFAULT_IOS_SDK_VERSION) : DottedVersion.fromStringUnchecked(defaultIosSdkVersion); + this.defaultVisionosSdkVersion = + Strings.isNullOrEmpty(defaultVisionosSdkVersion) + ? DottedVersion.fromStringUnchecked(DEFAULT_VISIONOS_SDK_VERSION) + : DottedVersion.fromStringUnchecked(defaultVisionosSdkVersion); this.defaultWatchosSdkVersion = Strings.isNullOrEmpty(defaultWatchosSdkVersion) ? DottedVersion.fromStringUnchecked(DEFAULT_WATCHOS_SDK_VERSION) @@ -117,6 +124,13 @@ public String getDefaultIosSdkVersionString() { return defaultIosSdkVersion != null ? defaultIosSdkVersion.toString() : null; } + /** Returns the default visionOS sdk version to use if this xcode version is in use. */ + @Nullable + @Override + public String getDefaultVisionosSdkVersionString() { + return defaultVisionosSdkVersion != null ? defaultVisionosSdkVersion.toString() : null; + } + /** Returns the default watchos sdk version to use if this xcode version is in use. */ @Nullable @Override @@ -148,6 +162,11 @@ public DottedVersion getDefaultIosSdkVersion() { return defaultIosSdkVersion; } + @Nullable + public DottedVersion getDefaultVisionosSdkVersion() { + return defaultVisionosSdkVersion; + } + @Nullable public DottedVersion getDefaultWatchosSdkVersion() { return defaultWatchosSdkVersion; @@ -174,6 +193,7 @@ public boolean equals(Object other) { XcodeVersionProperties otherData = (XcodeVersionProperties) other; return xcodeVersion.equals(otherData.getXcodeVersion()) && defaultIosSdkVersion.equals(otherData.getDefaultIosSdkVersion()) + && defaultVisionosSdkVersion.equals(otherData.getDefaultVisionosSdkVersion()) && defaultWatchosSdkVersion.equals(otherData.getDefaultWatchosSdkVersion()) && defaultTvosSdkVersion.equals(otherData.getDefaultTvosSdkVersion()) && defaultMacosSdkVersion.equals(otherData.getDefaultMacosSdkVersion()); @@ -184,6 +204,7 @@ public int hashCode() { return Objects.hash( xcodeVersion, defaultIosSdkVersion, + defaultVisionosSdkVersion, defaultWatchosSdkVersion, defaultTvosSdkVersion, defaultMacosSdkVersion); diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRule.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRule.java index 41609a36f41ef6..e813fa03d8b7b0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRule.java @@ -31,6 +31,7 @@ public class XcodeVersionRule implements RuleDefinition { static final String VERSION_ATTR_NAME = "version"; static final String ALIASES_ATTR_NAME = "aliases"; static final String DEFAULT_IOS_SDK_VERSION_ATTR_NAME = "default_ios_sdk_version"; + static final String DEFAULT_VISIONOS_SDK_VERSION_ATTR_NAME = "default_visionos_sdk_version"; static final String DEFAULT_WATCHOS_SDK_VERSION_ATTR_NAME = "default_watchos_sdk_version"; static final String DEFAULT_TVOS_SDK_VERSION_ATTR_NAME = "default_tvos_sdk_version"; static final String DEFAULT_MACOS_SDK_VERSION_ATTR_NAME = "default_macos_sdk_version"; @@ -64,6 +65,13 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) .add( attr(DEFAULT_IOS_SDK_VERSION_ATTR_NAME, STRING) .nonconfigurable("this rule determines configuration")) + /* + The visionos sdk version that is used by default when this version of xcode is being used. + The visionos_sdk_version build flag will override the value specified here. + */ + .add( + attr(DEFAULT_VISIONOS_SDK_VERSION_ATTR_NAME, STRING) + .nonconfigurable("this rule determines configuration")) /* The watchos sdk version that is used by default when this version of xcode is being used. The watchos_sdk_version build flag will override the value specified here. diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRuleData.java b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRuleData.java index ff8cc3549c254a..266265911ac652 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRuleData.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/XcodeVersionRuleData.java @@ -52,6 +52,8 @@ public class XcodeVersionRuleData implements TransitiveInfoProvider { attrMapper.get(XcodeVersionRule.VERSION_ATTR_NAME, Type.STRING)); String iosSdkVersionString = attrMapper.get(XcodeVersionRule.DEFAULT_IOS_SDK_VERSION_ATTR_NAME, Type.STRING); + String visionosSdkVersionString = + attrMapper.get(XcodeVersionRule.DEFAULT_VISIONOS_SDK_VERSION_ATTR_NAME, Type.STRING); String watchosSdkVersionString = attrMapper.get(XcodeVersionRule.DEFAULT_WATCHOS_SDK_VERSION_ATTR_NAME, Type.STRING); String tvosSdkVersionString = @@ -63,6 +65,7 @@ public class XcodeVersionRuleData implements TransitiveInfoProvider { new XcodeVersionProperties( xcodeVersion, iosSdkVersionString, + visionosSdkVersionString, watchosSdkVersionString, tvosSdkVersionString, macosxSdkVersionString); @@ -114,6 +117,9 @@ public boolean equals(Object other) { && xcodeVersionProperties .getDefaultIosSdkVersion() .equals(otherData.getXcodeVersionProperties().getDefaultIosSdkVersion()) + && xcodeVersionProperties + .getDefaultVisionosSdkVersion() + .equals(otherData.getXcodeVersionProperties().getDefaultVisionosSdkVersion()) && xcodeVersionProperties .getDefaultWatchosSdkVersion() .equals(otherData.getXcodeVersionProperties().getDefaultWatchosSdkVersion()) diff --git a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java index 3c18636b04d271..274adc7ccc549d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java +++ b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java @@ -67,6 +67,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import javax.annotation.Nullable; /** @@ -83,6 +84,20 @@ public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, ActionConflictException { AttributeMap attributes = NonconfigurableAttributeMapper.of(ruleContext.getRule()); + Optional likelyLabelInvalidSetting = + attributes.get(ConfigSettingRule.SETTINGS_ATTRIBUTE, Type.STRING_DICT).keySet().stream() + .filter(s -> s.startsWith("@") || s.startsWith("//") || s.startsWith(":")) + .findFirst(); + if (likelyLabelInvalidSetting.isPresent()) { + ruleContext.attributeError( + ConfigSettingRule.SETTINGS_ATTRIBUTE, + String.format( + "'%s' is not a valid setting name, but appears to be a label. Did you mean to place" + + " it in %s instead?", + likelyLabelInvalidSetting.get(), ConfigSettingRule.FLAG_SETTINGS_ATTRIBUTE)); + return null; + } + // Get the built-in Blaze flag settings that match this rule. ImmutableMultimap nativeFlagSettings = ImmutableMultimap.builder() diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java index 1ade3e2dfc0103..e7561c2639745c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java @@ -631,7 +631,7 @@ public static ImmutableList getLegacyFeatures( " action: 'c++-link-static-library'", " flag_group {", ifLinux(platform, "flag: 'rcsD'"), - ifMac(platform, "flag: '-static'", "flag: '-s'"), + ifMac(platform, "flag: '-static'"), " }", " flag_group {", " expand_if_all_available: 'output_execpath'", diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java index ed504331cffdf8..f991a687359a18 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java @@ -134,7 +134,8 @@ public class CompilationSupport implements StarlarkValue { "-fexceptions", "-fasm-blocks", "-fobjc-abi-version=2", "-fobjc-legacy-dispatch"); /** - * Frameworks implicitly linked to iOS, watchOS, and tvOS binaries when using legacy compilation. + * Frameworks implicitly linked to iOS, visionOS, watchOS, and tvOS binaries when using legacy + * compilation. */ @VisibleForTesting static final NestedSet AUTOMATIC_SDK_FRAMEWORKS = diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java index a407517c7f84fd..ff636f9cd0bf89 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java @@ -251,6 +251,8 @@ private static ConfigurationDistinguisher configurationDistinguisher(PlatformTyp return ConfigurationDistinguisher.APPLEBIN_IOS; case CATALYST: return ConfigurationDistinguisher.APPLEBIN_CATALYST; + case VISIONOS: + return ConfigurationDistinguisher.APPLEBIN_VISIONOS; case WATCHOS: return ConfigurationDistinguisher.APPLEBIN_WATCHOS; case TVOS: @@ -286,6 +288,10 @@ private static DottedVersion.Option minimumOsVersionOption( case CATALYST: option = buildOptions.get(AppleCommandLineOptions.class).iosMinimumOs; break; + case VISIONOS: + // TODO: Replace with CppOptions.minimumOsVersion + option = DottedVersion.option(DottedVersion.fromStringUnchecked("1.0")); + break; case WATCHOS: option = buildOptions.get(AppleCommandLineOptions.class).watchosMinimumOs; break; @@ -333,6 +339,9 @@ private static BuildOptionsView defaultBuildOptionsForSplit( case MACOS: appleCommandLineOptions.macosMinimumOs = minimumOsVersionOption; break; + case VISIONOS: + // TODO: use CppOptions.minimumOsVersion + break; } return splitOptions; } @@ -461,6 +470,13 @@ public static ImmutableMap handleAppleCpus( } cpus = supportedAppleCpusFromMinimumOs(minimumOsVersionOption, cpus, platformType); break; + case VISIONOS: + cpus = buildOptions.get(AppleCommandLineOptions.class).visionosCpus; + if (cpus.isEmpty()) { + cpus = ImmutableList.of(AppleCommandLineOptions.DEFAULT_VISIONOS_CPU); + } + cpus = supportedAppleCpusFromMinimumOs(minimumOsVersionOption, cpus, platformType); + break; case WATCHOS: cpus = buildOptions.get(AppleCommandLineOptions.class).watchosCpus; if (cpus.isEmpty()) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java index 4b3e044fd740a7..946b3fb728b27d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java @@ -207,8 +207,8 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment envi return builder /* Names of SDK frameworks to link with (e.g. "AddressBook", "QuartzCore"). "UIKit" and - "Foundation" are always included when building for the iOS, tvOS and watchOS platforms. - For macOS, only "Foundation" is always included. + "Foundation" are always included when building for the iOS, tvOS, visionOS, + and watchOS platforms. For macOS, only "Foundation" is always included.

    When linking a top level Apple binary, all SDK frameworks listed in that binary's transitive dependency graph are linked. diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ApplePlatformTypeApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ApplePlatformTypeApi.java index e110ad94c78198..54edcfe31dd764 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ApplePlatformTypeApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ApplePlatformTypeApi.java @@ -23,7 +23,7 @@ name = "apple_platform_type", category = DocCategory.BUILTIN, doc = - "Describes an Apple \"platform type\", such as iOS, macOS, tvOS, or watchOS. This is" + "Describes an Apple \"platform type\", such as iOS, macOS, tvOS, visionOS, or watchOS. This is" + " distinct from a \"platform\", which is the platform type combined with one or more" + " CPU architectures.

    Specific instances of this type can be retrieved by accessing" + " the fields of the apple_common.platform_type.ios" + "

  • apple_common.platform_type.macos
  • " + "
  • apple_common.platform_type.tvos
  • " + + "
  • apple_common.platform_type.visionos
  • " + "
  • apple_common.platform_type.watchos
  • Likewise, the" + " platform type of an existing platform value can be retrieved using its" + " platform_type field.

    Platform types can be converted to a lowercase" diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java index 781b5aa3b86160..8229f03ac5b423 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java @@ -103,6 +103,16 @@ interface XcodeConfigProviderApi extends ProviderApi { named = true, positional = false, doc = "The ios minimum os version."), + @Param( + name = "visionosSdkVersion", + named = true, + positional = false, + doc = "The visionOS SDK version."), + @Param( + name = "visionosMinimumOsVersion", + named = true, + positional = false, + doc = "The visionOS minimum os version."), @Param( name = "watchosSdkVersion", named = true, @@ -144,6 +154,8 @@ interface XcodeConfigProviderApi extends ProviderApi { XcodeConfigInfoApi xcodeConfigInfo( String iosSdkVersion, String iosMinimumOsVersion, + String visionosSdkVersion, + String visionosMinimumOsVersion, String watchosSdkVersion, String watchosMinimumOsVersion, String tvosSdkVersion, diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodePropertiesApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodePropertiesApi.java index 4ad4b565dbe5f8..bedfbb42da2d7b 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodePropertiesApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodePropertiesApi.java @@ -45,6 +45,16 @@ public interface XcodePropertiesApi extends StructApi { @Nullable String getDefaultIosSdkVersionString(); + @StarlarkMethod( + name = "default_visionos_sdk_version", + doc = + "The default visionOS sdk version for this version of xcode, or None if " + + "unknown.", + structField = true, + allowReturnNones = true) + @Nullable + String getDefaultVisionosSdkVersionString(); + @StarlarkMethod( name = "default_watchos_sdk_version", doc = diff --git a/src/main/protobuf/spawn.proto b/src/main/protobuf/spawn.proto index f11de34f13d177..5863f973424431 100644 --- a/src/main/protobuf/spawn.proto +++ b/src/main/protobuf/spawn.proto @@ -41,6 +41,10 @@ message File { // Digest of the file's contents. Digest digest = 2; + + // Whether the file is a tool. + // Only set for inputs, never for outputs. + bool is_tool = 3; } // Contents of command environment. @@ -185,3 +189,17 @@ message SpawnExec { // Timing, size and memory statistics. SpawnMetrics metrics = 20; } + +// Additional information that should be taken into account when +// computing the key of an action, thereby ensuring that actions remain +// distinct. +message CacheSalt { + // Whether or not the action may be executed remotely, if remote + // execution were to be enabled. This ensures that adding/removing the + // "no-remote-exec" tag from a target forces a local/remote rebuild. + bool may_be_executed_remotely = 1; + + // Requires the execution service do NOT share caches across different + // workspace. + string workspace = 2; +} diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl index 4beca92ef650c1..a657498cff4842 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl @@ -33,6 +33,8 @@ _LINKING_STATIC = "static_linking_mode" _IOS_SIMULATOR_TARGET_CPUS = ["ios_x86_64", "ios_i386", "ios_sim_arm64"] _IOS_DEVICE_TARGET_CPUS = ["ios_armv6", "ios_arm64", "ios_armv7", "ios_armv7s", "ios_arm64e"] +_VISIONOS_SIMULATOR_TARGET_CPUS = ["visionos_x86_64", "visionos_sim_arm64"] +_VISIONOS_DEVICE_TARGET_CPUS = ["visionos_arm64"] _WATCHOS_SIMULATOR_TARGET_CPUS = ["watchos_i386", "watchos_x86_64", "watchos_arm64"] _WATCHOS_DEVICE_TARGET_CPUS = ["watchos_armv7k", "watchos_arm64_32"] _TVOS_SIMULATOR_TARGET_CPUS = ["tvos_x86_64", "tvos_sim_arm64"] @@ -555,7 +557,7 @@ def _report_invalid_options(ctx, cc_toolchain, cpp_config): fail("The selected toolchain does not support setting --grte_top (it doesn't specify builtin_sysroot).") def _is_apple_platform(target_cpu): - if target_cpu in _IOS_SIMULATOR_TARGET_CPUS or target_cpu in _IOS_DEVICE_TARGET_CPUS or target_cpu in _WATCHOS_SIMULATOR_TARGET_CPUS or target_cpu in _WATCHOS_DEVICE_TARGET_CPUS or target_cpu in _TVOS_SIMULATOR_TARGET_CPUS or target_cpu in _TVOS_DEVICE_TARGET_CPUS or target_cpu in _CATALYST_TARGET_CPUS or target_cpu in _MACOS_TARGET_CPUS: + if target_cpu in _IOS_SIMULATOR_TARGET_CPUS or target_cpu in _IOS_DEVICE_TARGET_CPUS or target_cpu in _VISIONOS_SIMULATOR_TARGET_CPUS or target_cpu in _VISIONOS_DEVICE_TARGET_CPUS or target_cpu in _WATCHOS_SIMULATOR_TARGET_CPUS or target_cpu in _WATCHOS_DEVICE_TARGET_CPUS or target_cpu in _TVOS_SIMULATOR_TARGET_CPUS or target_cpu in _TVOS_DEVICE_TARGET_CPUS or target_cpu in _CATALYST_TARGET_CPUS or target_cpu in _MACOS_TARGET_CPUS: return True return False diff --git a/src/main/starlark/builtins_bzl/common/objc/transitions.bzl b/src/main/starlark/builtins_bzl/common/objc/transitions.bzl index 88aec6da87282b..f886f5933b1448 100644 --- a/src/main/starlark/builtins_bzl/common/objc/transitions.bzl +++ b/src/main/starlark/builtins_bzl/common/objc/transitions.bzl @@ -37,6 +37,14 @@ def _determine_single_architecture(platform_type, settings): if cpu_value == "darwin_arm64": return "sim_arm64" return DEFAULT_IOS_CPU + if platform_type == VISIONOS: + cpus = settings["//command_line_option:visionos_cpus"] + if len(cpus) > 0: + return cpus[0] + cpu_value = settings["//command_line_option:cpu"] + if cpu_value == "darwin_arm64": + return "sim_arm64" + return DEFAULT_VISIONOS_CPU if platform_type == WATCHOS: watchos_cpus = settings["//command_line_option:watchos_cpus"] if len(watchos_cpus) == 0: @@ -64,13 +72,16 @@ def _determine_single_architecture(platform_type, settings): fail("ERROR: Unhandled platform type {}".format(platform_type)) IOS = "ios" +VISIONOS = "visionos" WATCHOS = "watchos" TVOS = "tvos" MACOS = "macos" CATALYST = "catalyst" IOS_CPU_PREFIX = "ios_" +VISIONOS_CPU_PREFIX = "visionos_" DARWIN_CPU_PREFIX = "darwin_" DEFAULT_IOS_CPU = "x86_64" +DEFAULT_VISIONOS_CPU = "x86_64" DEFAULT_WATCHOS_CPU = "i386" DEFAULT_TVOS_CPU = "x86_64" DEFAULT_MACOS_CPU = "x86_64" @@ -122,6 +133,7 @@ _apple_rule_base_transition_inputs = [ "//command_line_option:ios_multi_cpus", "//command_line_option:macos_cpus", "//command_line_option:tvos_cpus", + "//command_line_option:visionos_cpus", "//command_line_option:watchos_cpus", "//command_line_option:catalyst_cpus", "//command_line_option:platforms", diff --git a/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java index a1d315267231cc..dd0a4d1954d07c 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java +++ b/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java @@ -29,9 +29,12 @@ import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.actions.ActionExecutionContext; import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact; +import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; import com.google.devtools.build.lib.actions.ArtifactRoot; import com.google.devtools.build.lib.actions.FutureSpawn; import com.google.devtools.build.lib.actions.MetadataProvider; +import com.google.devtools.build.lib.actions.ArtifactRoot.RootType; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.SpawnExecutedEvent; import com.google.devtools.build.lib.actions.SpawnResult; @@ -92,6 +95,7 @@ public TestedSpawnStrategy(Path execRoot, SpawnRunner spawnRunner) { private final Path execRoot = fs.getPath("/execroot"); private Scratch scratch; private ArtifactRoot rootDir; + private ArtifactRoot outputDir; @Mock private SpawnRunner spawnRunner; @Mock private ActionExecutionContext actionExecutionContext; @Mock private MessageOutputStream messageOutput; @@ -103,6 +107,7 @@ public final void setUp() throws Exception { MockitoAnnotations.initMocks(this); scratch = new Scratch(fs); rootDir = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.dir("/execroot"))); + outputDir = ArtifactRoot.asDerivedRoot(scratch.dir("/execroot"), RootType.Output, "out"); eventHandler = new StoredEventHandler(); when(actionExecutionContext.getEventHandler()).thenReturn(eventHandler); when(actionExecutionContext.getClock()).thenReturn(clock); @@ -453,6 +458,60 @@ public void testLogSpawn_defaultPlatform_getsLogged() throws Exception { verify(messageOutput).write(expected); // output will reflect default properties } + @Test + public void testLogSpawn_toolInputs() throws Exception { + Artifact toolFile = ActionsTestUtil.createArtifact(rootDir, "tool.file"); + SpecialArtifact toolDir = + ActionsTestUtil.createTreeArtifactWithGeneratingAction(outputDir, "tool.dir"); + + scratch.file("/execroot/tool.file", "123"); + scratch.file("/execroot/out/tool.dir/tool.file", "456"); + + setUpExecutionContext(/* executionOptions= */ null, /* remoteOptions= */ null); + when(actionExecutionContext.getArtifactExpander()) + .thenReturn( + (artifact, output) -> { + if (artifact.equals(toolDir)) { + output.add(TreeFileArtifact.createTreeOutput(toolDir, "tool.file")); + } + }); + Spawn spawn = + new SpawnBuilder("cmd").withInputs(toolFile, toolDir).withTools(toolFile, toolDir).build(); + assertThrows( + SpawnExecException.class, + () -> new TestedSpawnStrategy(execRoot, spawnRunner).exec(spawn, actionExecutionContext)); + + SpawnExec expected = + defaultSpawnExecBuilder("cmd") + .addInputs( + File.newBuilder() + .setPath("out/tool.dir/tool.file") + .setDigest( + Digest.newBuilder() + .setHash( + "cdfba543ee8ef7fdb3d8b587648cc22dd792bbd6272cc5447307c7c106c2374c") + .setSizeBytes(4) + .setHashFunctionName("SHA-256") + .build()) + .setIsTool(true) + .build()) + .addInputs( + File.newBuilder() + .setPath("tool.file") + .setDigest( + Digest.newBuilder() + .setHash( + "181210f8f9c779c26da1d9b2075bde0127302ee0e3fca38c9a83f5b1dd8e5d3b") + .setSizeBytes(4) + .setHashFunctionName("SHA-256") + .build()) + .setIsTool(true) + .build()) + .build(); + + verify(messageOutput).write(expected); + } + @Test public void testLogSpawn_spawnMetrics() throws Exception { ExecutionOptions executionOptions = Options.getDefaults(ExecutionOptions.class); diff --git a/src/test/java/com/google/devtools/build/lib/exec/util/SpawnBuilder.java b/src/test/java/com/google/devtools/build/lib/exec/util/SpawnBuilder.java index 9564169e77e2a1..5a396b8d055624 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/util/SpawnBuilder.java +++ b/src/test/java/com/google/devtools/build/lib/exec/util/SpawnBuilder.java @@ -235,6 +235,14 @@ public SpawnBuilder withTool(ActionInput tool) { return this; } + @CanIgnoreReturnValue + public SpawnBuilder withTools(ActionInput... tools) { + for (ActionInput tool : tools) { + this.tools.add(tool); + } + return this; + } + @CanIgnoreReturnValue public SpawnBuilder withLocalResources(ResourceSet resourceSet) { this.resourceSet = resourceSet; diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java index ec3d6f2c7d315e..b657474765a2dc 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockPlatformSupport.java @@ -112,6 +112,10 @@ public static void setup( " constraint_setting = ':os',", ")", "constraint_value(", + " name = 'visionos',", + " constraint_setting = ':os',", + ")", + "constraint_value(", " name = 'watchos',", " constraint_setting = ':os',", ")", diff --git a/src/test/java/com/google/devtools/build/lib/remote/BUILD b/src/test/java/com/google/devtools/build/lib/remote/BUILD index 7c83743208ff34..bcdc577ff5ef0e 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/BUILD +++ b/src/test/java/com/google/devtools/build/lib/remote/BUILD @@ -98,6 +98,7 @@ java_test( "//src/main/java/com/google/devtools/common/options", "//src/main/protobuf:failure_details_java_proto", "//src/main/protobuf:remote_execution_log_java_proto", + "//src/main/protobuf:spawn_java_proto", "//src/test/java/com/google/devtools/build/lib:test_runner", "//src/test/java/com/google/devtools/build/lib/actions/util", "//src/test/java/com/google/devtools/build/lib/analysis/util", diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java index 8b17b1433feaff..fcc728e7cf7814 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java @@ -80,6 +80,7 @@ import com.google.devtools.build.lib.events.EventKind; import com.google.devtools.build.lib.events.Reporter; import com.google.devtools.build.lib.events.StoredEventHandler; +import com.google.devtools.build.lib.exec.Protos.CacheSalt; import com.google.devtools.build.lib.exec.util.FakeOwner; import com.google.devtools.build.lib.exec.util.SpawnBuilder; import com.google.devtools.build.lib.remote.RemoteExecutionService.RemoteActionResult; @@ -261,7 +262,7 @@ public void buildRemoteAction_withActionInputDirectoryAsOutput() throws Exceptio } @Test - public void buildRemoteAction_differentiateWorkspace_generateActionSalt() throws Exception { + public void buildRemoteAction_generateActionSalt_differentiateWorkspaceCache() throws Exception { Spawn spawn = new SpawnBuilder("dummy") .withExecutionInfo(ExecutionRequirements.DIFFERENTIATE_WORKSPACE_CACHE, "aa") @@ -271,10 +272,23 @@ public void buildRemoteAction_differentiateWorkspace_generateActionSalt() throws RemoteAction remoteAction = service.buildRemoteAction(spawn, context); - Platform expected = - Platform.newBuilder() - .addProperties(Platform.Property.newBuilder().setName("workspace").setValue("aa")) + CacheSalt expected = + CacheSalt.newBuilder().setMayBeExecutedRemotely(true).setWorkspace("aa").build(); + assertThat(remoteAction.getAction().getSalt()).isEqualTo(expected.toByteString()); + } + + @Test + public void buildRemoteAction_generateActionSalt_noRemoteExec() throws Exception { + Spawn spawn = + new SpawnBuilder("dummy") + .withExecutionInfo(ExecutionRequirements.NO_REMOTE_EXEC, "") .build(); + FakeSpawnExecutionContext context = newSpawnExecutionContext(spawn); + RemoteExecutionService service = newRemoteExecutionService(); + + RemoteAction remoteAction = service.buildRemoteAction(spawn, context); + + CacheSalt expected = CacheSalt.newBuilder().setMayBeExecutedRemotely(false).build(); assertThat(remoteAction.getAction().getSalt()).isEqualTo(expected.toByteString()); } diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java index 623f2fe0808fb1..b479751e86fab3 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java @@ -152,7 +152,7 @@ public class RemoteSpawnRunnerTest { // The action key of the Spawn returned by newSimpleSpawn(). private final String simpleActionId = - "eb45b20cc979d504f96b9efc9a08c48103c6f017afa09c0df5c70a5f92a98ea8"; + "31aea267dc597b047a9b6993100415b6406f82822318dc8988e4164a535b51ee"; @Before public final void setUp() throws Exception { @@ -557,7 +557,7 @@ public void testHumanReadableServerLogsSavedForFailingActionWithSiblingRepositor Digest logDigest = digestUtil.computeAsUtf8("bla"); Path logPath = logDir - .getRelative("b9a727771337fd8ce54821f4805e2d451c4739e92fec6f8ecdb18ff9d1983b27") + .getRelative("e0a5a3561464123504c1240b3587779cdfd6adee20f72aa136e388ecfd570c12") .getRelative("logname"); ExecuteResponse resp = ExecuteResponse.newBuilder() diff --git a/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java b/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java index 51ea58bddd6337..cd41a807eb30f3 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java @@ -445,7 +445,9 @@ public void xcodeVersionConfig_isFunction() throws Exception { + " tvosMinimumOsVersion='1.6'," + " macosSdkVersion='1.7'," + " macosMinimumOsVersion='1.8'," - + " xcodeVersion='1.9'))]", + + " visionosSdkVersion='1.9'," + + " visionosMinimumOsVersion='1.10'," + + " xcodeVersion='1.11'))]", "my_rule = rule(_impl, attrs = { 'dep' : attr.label() })"); scratch.file("foo/BUILD", "load(':extension.bzl', 'my_rule')", "my_rule(name='test')"); assertNoEvents(); @@ -466,6 +468,8 @@ public void xcodeVersionConfig_isFunction() throws Exception { DottedVersion.fromStringUnchecked("1.7"), DottedVersion.fromStringUnchecked("1.8"), DottedVersion.fromStringUnchecked("1.9"), + DottedVersion.fromStringUnchecked("1.10"), + DottedVersion.fromStringUnchecked("1.11"), XcodeConfigInfo.Availability.UNKNOWN, /** xcodeVersionFlagValue= */ "", @@ -489,7 +493,9 @@ public void xcodeVersionConfig_throwsOnBadInput() throws Exception { + " tvosMinimumOsVersion='1.6'," + " macosSdkVersion='1.7'," + " macosMinimumOsVersion='1.8'," - + " xcodeVersion='1.9'))]", + + " visionosSdkVersion='1.9'," + + " visionosMinimumOsVersion='1.10'," + + " xcodeVersion='1.11'))]", "my_rule = rule(_impl, attrs = { 'dep' : attr.label() })"); scratch.file("foo/BUILD", "load(':extension.bzl', 'my_rule')", "my_rule(name='test')"); assertNoEvents(); @@ -509,12 +515,14 @@ public void xcodeVersionConfig_exposesExpectedAttributes() throws Exception { + " iosSdkVersion='1.1'," + " iosMinimumOsVersion='1.2'," + " watchosSdkVersion='1.3'," - + " watchosMinimumOsVersion='1.4'," + + " watchosMinimumOsVersion='2.4'," + " tvosSdkVersion='1.5'," + " tvosMinimumOsVersion='1.6'," + " macosSdkVersion='1.7'," + " macosMinimumOsVersion='1.8'," - + " xcodeVersion='1.9')", + + " visionosSdkVersion='1.9'," + + " visionosMinimumOsVersion='1.10'," + + " xcodeVersion='1.11')", " return [result(xcode_version=xcode_version.xcode_version()," + "min_os=xcode_version.minimum_os_for_platform_type(ctx.fragments.apple.single_arch_platform.platform_type)),]", "my_rule = rule(_impl, attrs = { 'dep' : attr.label() }, fragments = ['apple'])"); @@ -525,7 +533,7 @@ public void xcodeVersionConfig_exposesExpectedAttributes() throws Exception { (StructImpl) myRuleTarget.get( new StarlarkProvider.Key(Label.parseCanonical("//foo:extension.bzl"), "result")); - assertThat(info.getValue("xcode_version").toString()).isEqualTo("1.9"); + assertThat(info.getValue("xcode_version").toString()).isEqualTo("1.11"); assertThat(info.getValue("min_os").toString()).isEqualTo("1.8"); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java index aa425fb7200c54..3a182ff1dbb81e 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java @@ -2317,4 +2317,20 @@ public void singleValueThatLooksLikeMultiValueIsOkay() throws Exception { assertThat(getConfiguredTarget("//test:fg")).isNotNull(); assertNoEvents(); } + + @Test + public void labelInValuesError() throws Exception { + scratch.file( + "test/BUILD", + "config_setting(", + " name = 'match',", + " values = {'//foo:bar': 'value'},", + ")"); + reporter.removeHandler(failFastHandler); // expect errors + assertThat(getConfiguredTarget("//test:match")).isNull(); + assertContainsEvent( + "in values attribute of config_setting rule //test:match: '//foo:bar' is" + + " not a valid setting name, but appears to be a label. Did you mean to place it in" + + " flag_values instead?"); + } } diff --git a/src/test/shell/bazel/android/android_integration_test.sh b/src/test/shell/bazel/android/android_integration_test.sh index a61fa6f461314e..776a40dbe0514d 100755 --- a/src/test/shell/bazel/android/android_integration_test.sh +++ b/src/test/shell/bazel/android/android_integration_test.sh @@ -232,7 +232,7 @@ android_binary( EOF cat > MODULE.bazel << 'EOF' # Required for android_integration_test_with_platforms -bazel_dep(name = "platforms", version = "0.0.5") +bazel_dep(name = "platforms", version = "0.0.7") EOF bazel clean diff --git a/src/test/shell/integration/action_env_test.sh b/src/test/shell/integration/action_env_test.sh index 08af2abd059630..6feaf075740bb0 100755 --- a/src/test/shell/integration/action_env_test.sh +++ b/src/test/shell/integration/action_env_test.sh @@ -39,6 +39,15 @@ load("//pkg:build.bzl", "environ") environ(name = "no_default_env", env = 0) environ(name = "with_default_env", env = 1) +environ( + name = "with_default_and_fixed_env", + env = 1, + fixed_env = { + "ACTION_FIXED": "action", + "ACTION_AND_CLIENT_FIXED": "action", + "ACTION_AND_CLIENT_INHERITED": "action", + }, +) sh_test( name = "test_env_foo", @@ -72,12 +81,16 @@ def _impl(ctx): ctx.actions.run_shell( inputs=[], outputs=[output], + env = ctx.attr.fixed_env, use_default_shell_env = ctx.attr.env, command="env > %s" % output.path) environ = rule( implementation=_impl, - attrs={"env": attr.bool(default=True)}, + attrs={ + "env": attr.bool(default=True), + "fixed_env": attr.string_dict(), + }, outputs={"out": "%{name}.env"}, ) EOF @@ -222,6 +235,52 @@ function test_use_default_shell_env { && fail "dynamic action_env used, even though requested not to") || true } +function test_use_default_shell_env_and_fixed_env { + ACTION_AND_CLIENT_INHERITED=client CLIENT_INHERITED=client \ + bazel build \ + --noincompatible_merge_fixed_and_default_shell_env \ + --action_env=ACTION_AND_CLIENT_FIXED=client \ + --action_env=ACTION_AND_CLIENT_INHERITED \ + --action_env=CLIENT_FIXED=client \ + --action_env=CLIENT_INHERITED \ + //pkg:with_default_and_fixed_env + echo + cat bazel-bin/pkg/with_default_and_fixed_env.env + echo + grep -q ACTION_AND_CLIENT_FIXED=client bazel-bin/pkg/with_default_and_fixed_env.env \ + || fail "static action environment not honored" + grep -q ACTION_AND_CLIENT_INHERITED=client bazel-bin/pkg/with_default_and_fixed_env.env \ + || fail "dynamic action environment not honored" + grep -q ACTION_FIXED bazel-bin/pkg/with_default_and_fixed_env.env \ + && fail "fixed env provided by action should have been ignored" + grep -q CLIENT_FIXED=client bazel-bin/pkg/with_default_and_fixed_env.env \ + || fail "static action environment not honored" + grep -q CLIENT_INHERITED=client bazel-bin/pkg/with_default_and_fixed_env.env \ + || fail "dynamic action environment not honored" + + ACTION_AND_CLIENT_INHERITED=client CLIENT_INHERITED=client \ + bazel build \ + --incompatible_merge_fixed_and_default_shell_env \ + --action_env=ACTION_AND_CLIENT_FIXED=client \ + --action_env=ACTION_AND_CLIENT_INHERITED \ + --action_env=CLIENT_FIXED=client \ + --action_env=CLIENT_INHERITED \ + //pkg:with_default_and_fixed_env + echo + cat bazel-bin/pkg/with_default_and_fixed_env.env + echo + grep -q ACTION_AND_CLIENT_FIXED=action bazel-bin/pkg/with_default_and_fixed_env.env \ + || fail "action-provided env should have overridden static --action_env" + grep -q ACTION_AND_CLIENT_INHERITED=action bazel-bin/pkg/with_default_and_fixed_env.env \ + || fail "action-provided env should have overridden dynamic --action_env" + grep -q ACTION_FIXED=action bazel-bin/pkg/with_default_and_fixed_env.env \ + || fail "action-provided env should have been honored" + grep -q CLIENT_FIXED=client bazel-bin/pkg/with_default_and_fixed_env.env \ + || fail "static action environment not honored" + grep -q CLIENT_INHERITED=client bazel-bin/pkg/with_default_and_fixed_env.env \ + || fail "dynamic action environment not honored" +} + function test_action_env_changes_honored { # Verify that changes to the explicitly specified action_env in honored in # tests. Regression test for #3265. diff --git a/tools/osx/BUILD b/tools/osx/BUILD index 79344650445338..2a0f44224ce2f2 100644 --- a/tools/osx/BUILD +++ b/tools/osx/BUILD @@ -3,6 +3,7 @@ load( "ios_sdk_version_flag", "macos_sdk_version_flag", "tvos_sdk_version_flag", + "visionos_sdk_version_flag", "watchos_sdk_version_flag", "xcode_version_flag", ) @@ -100,6 +101,8 @@ ios_sdk_version_flag(name = "ios_sdk_version_flag") tvos_sdk_version_flag(name = "tvos_sdk_version_flag") +visionos_sdk_version_flag(name = "visionos_sdk_version_flag") + watchos_sdk_version_flag(name = "watchos_sdk_version_flag") macos_sdk_version_flag(name = "macos_sdk_version_flag") diff --git a/tools/osx/xcode_configure.bzl b/tools/osx/xcode_configure.bzl index e8b7499a814861..e9c4152b924c01 100644 --- a/tools/osx/xcode_configure.bzl +++ b/tools/osx/xcode_configure.bzl @@ -71,6 +71,7 @@ def _xcode_version_output(repository_ctx, name, version, aliases, developer_dir, ios_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "iphoneos") tvos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "appletvos") macos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "macosx") + visionos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "xros") watchos_sdk_version = _search_sdk_output(xcodebuild_result.stdout, "watchos") build_contents += "xcode_version(\n name = '%s'," % name build_contents += "\n version = '%s'," % version @@ -82,6 +83,8 @@ def _xcode_version_output(repository_ctx, name, version, aliases, developer_dir, build_contents += "\n default_tvos_sdk_version = '%s'," % tvos_sdk_version if macos_sdk_version: build_contents += "\n default_macos_sdk_version = '%s'," % macos_sdk_version + if visionos_sdk_version: + build_contents += "\n default_visionos_sdk_version = '%s'," % visionos_sdk_version if watchos_sdk_version: build_contents += "\n default_watchos_sdk_version = '%s'," % watchos_sdk_version build_contents += "\n)\n" diff --git a/tools/osx/xcode_version_flag.bzl b/tools/osx/xcode_version_flag.bzl index a7ede5f54dd95a..1578a731b8fe32 100644 --- a/tools/osx/xcode_version_flag.bzl +++ b/tools/osx/xcode_version_flag.bzl @@ -98,6 +98,16 @@ def _tvos_sdk_version_flag_impl(ctx): ), )) +def _visionos_sdk_version_flag_impl(ctx): + """A rule that allows select() to select based on the visionOS SDK version.""" + xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig] + + return config_common.FeatureFlagInfo(value = _strip_version( + xcode_config.sdk_version_for_platform( + apple_common.platform.visionos_device, + ), + )) + def _watchos_sdk_version_flag_impl(ctx): """A rule that allows select() to select based on the watchOS SDK version.""" xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig] @@ -200,6 +210,16 @@ tvos_sdk_version_flag = rule( }, ) +visionos_sdk_version_flag = rule( + implementation = _visionos_sdk_version_flag_impl, + attrs = { + "_xcode_config": attr.label(default = configuration_field( + fragment = "apple", + name = "xcode_config_label", + )), + }, +) + watchos_sdk_version_flag = rule( implementation = _watchos_sdk_version_flag_impl, attrs = {