Unverified Commit c429fa2f authored by Malte Poll's avatar Malte Poll Committed by GitHub
Browse files

bazel_7: 7.1.0 -> 7.1.2 (#314279)

* bazel_7: 7.1.0 -> 7.1.2

* bazel_7: update lockfiles

* bazel_7: upgrade lockfile format for versions > 3

The new lockfile format 6 drops the "name" attribute of each repoSpec.
See also: https://github.com/bazelbuild/bazel/pull/21026
This prevents the builder from effectively the deps using
requiredDepNamePredicate.
Instead, we now generate names from other metadata.
parent 5a64d9a2
Loading
Loading
Loading
Loading
+726 −1060

File changed.

Preview size limit exceeded, changes collapsed.

+62 −23
Original line number Diff line number Diff line
@@ -12,23 +12,45 @@ let
  modules = builtins.fromJSON (builtins.readFile lockfile);
  modulesVersion = modules.lockFileVersion;

  # a foldl' for json values
  foldlJSON = op: acc: value:
    let
      # preorder, visit the current node first
      acc' = op acc value;
  # A foldl' for moduleDepGraph repoSpecs.
  # We take any RepoSpec object under .moduleDepGraph.<moduleName>.repoSpec
  foldlModuleDepGraph = op: acc: value:
    if builtins.isAttrs value && value ? moduleDepGraph && builtins.isAttrs value.moduleDepGraph
    then
      lib.foldlAttrs
        (_acc: moduleDepGraphName: module: (
          if builtins.isAttrs module && module ? repoSpec
          then op _acc { inherit moduleDepGraphName; } module.repoSpec
          else _acc
        ))
        acc
        value.moduleDepGraph
    else acc;

      # then visit child values, ignoring attribute names
      children =
        if builtins.isList value then
          lib.foldl' (foldlJSON op) acc' value
        else if builtins.isAttrs value then
          lib.foldlAttrs (_acc: _name: foldlJSON op _acc) acc' value
        else
          acc';
    in
    # like foldl', force evaluation of intermediate results
    builtins.seq acc' children;
  # a foldl' for moduleExtensions generatedRepoSpecs
  # We take any RepoSpec object under .moduleExtensions.<moduleExtensionName>.general.generatedRepoSpecs.<generatedRepoName>
  foldlGeneratedRepoSpecs = op: acc: value:
    if builtins.isAttrs value && value ? moduleExtensions
    then
      lib.foldlAttrs
        (_acc: moduleExtensionName: moduleExtension: (
          if builtins.isAttrs moduleExtension
            && moduleExtension ? general
            && builtins.isAttrs moduleExtension.general
            && moduleExtension.general ? generatedRepoSpecs
            && builtins.isAttrs moduleExtension.general.generatedRepoSpecs
          then
            lib.foldlAttrs
              (__acc: moduleExtensionGeneratedRepoName: repoSpec: (
                op __acc { inherit moduleExtensionName moduleExtensionGeneratedRepoName; } repoSpec
              ))
              _acc
              moduleExtension.general.generatedRepoSpecs
          else _acc
        ))
        acc
        value.moduleExtensions
    else acc;

  # remove the "--" prefix, abusing undocumented negative substring length
  sanitize = str:
@@ -36,6 +58,22 @@ let
    then builtins.substring 2 (-1) str
    else str;

  unmangleName = mangledName:
    if mangledName ? moduleDepGraphName
    then builtins.replaceStrings [ "@" ] [ "~" ] mangledName.moduleDepGraphName
    else
    # given moduleExtensionName = "@scope~//path/to:extension.bzl%extension"
    # and moduleExtensionGeneratedRepoName = "repoName"
    # return "scope~extension~repoName"
      let
        isMainModule = lib.strings.hasPrefix "//" mangledName.moduleExtensionName;
        moduleExtensionParts = builtins.split "^@*([a-zA-Z0-9_~]*)//.*%(.*)$" mangledName.moduleExtensionName;
        match = if (builtins.length moduleExtensionParts >= 2) then builtins.elemAt moduleExtensionParts 1 else [ "unknownPrefix" "unknownScope" "unknownExtension" ];
        scope = if isMainModule then "_main" else builtins.elemAt match 0;
        extension = builtins.elemAt match 1;
      in
      "${scope}~${extension}~${mangledName.moduleExtensionGeneratedRepoName}";

  # We take any "attributes" object that has a "sha256" field. Every value
  # under "attributes" is assumed to be an object, and all the "attributes"
  # with a "sha256" field are assumed to have either a "urls" or "url" field.
@@ -55,9 +93,10 @@ let
  #
  # !REMINDER! This works on a best-effort basis, so try to keep it from
  # failing loudly. Prefer warning traces.
  extract_source = f: acc: value:
  extract_source = f: acc: mangledName: value:
    let
      attrs = value.attributes;
      name = unmangleName mangledName;
      entry = hash: urls: name: {
        ${hash} = fetchurl {
          name = "source"; # just like fetch*, to get some deduplication
@@ -72,11 +111,10 @@ let
        let
          validUrls = builtins.isList urls
            && builtins.all (url: builtins.isString url && builtins.substring 0 4 url == "http") urls;
          validName = builtins.isString attrs.name;
          validHash = builtins.isString hash;
          valid = validUrls && validName && validHash;
          valid = validUrls && validHash;
        in
        if valid then acc // entry hash urls attrs.name
        if valid then acc // entry hash urls name
        else acc;
      withToplevelValue = acc: insert acc
        (attrs.integrity or attrs.sha256)
@@ -94,15 +132,16 @@ let
      addSources = acc: withToplevelValue (withRemotePatches (withArchives acc));
    in
    if builtins.isAttrs value && value ? attributes
      && builtins.isAttrs attrs && attrs ? name
      && value ? ruleClassName
      && builtins.isAttrs attrs
      && (attrs ? sha256 || attrs ? integrity)
      && (attrs ? urls || attrs ? url)
      && f attrs.name
      && f name
    then addSources acc
    else acc;

  requiredSourcePredicate = n: requiredDepNamePredicate (sanitize n);
  requiredDeps = foldlJSON (extract_source requiredSourcePredicate) { } modules;
  requiredDeps = foldlModuleDepGraph (extract_source requiredSourcePredicate) { } modules // foldlGeneratedRepoSpecs (extract_source requiredSourcePredicate) { } modules;

  command = ''
    mkdir -p $out/content_addressable/sha256
+464 −467

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -24,8 +24,8 @@ let
    # Take all the rules_ deps, bazel_ deps and their transitive dependencies,
    # but none of the platform-specific binaries, as they are large and useless.
    requiredDepNamePredicate = name:
      null == builtins.match ".*(macos|osx|linux|win|apple|android|maven).*" name
      && null != builtins.match "(platforms|com_google_|protobuf|rules_|bazel_).*" name ;
      null == builtins.match ".*(macos|osx|linux|win|android|maven).*" name
      && null != builtins.match "(platforms|com_google_|protobuf|rules_|bazel_|apple_support).*" name;
  };

  mergedDistDir = symlinkJoin {
+2 −2
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@
  # Always assume all markers valid (this is needed because we remove markers; they are non-deterministic).
  # Also, don't clean up environment variables (so that NIX_ environment variables are passed to compilers).
, enableNixHacks ? false
, version ? "7.1.0",
, version ? "7.1.2"
}:

let
@@ -51,7 +51,7 @@ let

  src = fetchurl {
    url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
    hash = "sha256-HiDQyJ98nRtKOBqMWGtKQ1qWv8Qfu880osKUlOs4Z6E=";
    hash = "sha256-nPbtIxnIFpGdlwFe720MWULNGu1I4DxzuggV2VPtYas=";
  };

  # Use builtins.fetchurl to avoid IFD, in particular on hydra
Loading