Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.2.0] Cherry-picks for starlarkifying all repo rules #22133

Closed
wants to merge 20 commits into from

Commits on Apr 25, 2024

  1. aquery: interpret "//foo:bar" as "all configured targets with label /…

    …/foo:bar"
    
    cquery acquired this behavior 4 years ago in unknown commit, but it was never ported to aquery. This fixes some potentially surprising behavior when multiple configured targets corresponding to the same label are present (see added test cases).
    
    RELNOTES: aquery: `//foo:bar` now means "all configured targets with label `//foo:bar`" instead of "choose an arbitrary configured target with label `//foo:bar`". This is in line with cquery behavior.
    PiperOrigin-RevId: 620091100
    Change-Id: Ib5c5ee33e35fe7ac30bc31f703b119dec40185b7
    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    4555d1d View commit details
    Browse the repository at this point in the history
  2. Local repo rules in Starlark

    Added `local_repository` and `new_local_repository` as Starlark repo rules under `@bazel_tools//tools/build_defs/repo:local.bzl`. They're drop-in replacements for their native counterparts.
    
    Work towards #18285.
    
    RELNOTES: The `local_repository` and `new_local_repository` repository rules are now available as Starlark rules under `@bazel_tools//tools/build_defs/repo:local.bzl`. They are drop-in replacements for their native counterparts, and can be used in module extensions.
    
    Closes #21681.
    
    PiperOrigin-RevId: 615926923
    Change-Id: I0cc7355b011751da23f2a3aa189f120ef177e0fe
    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    dd192e7 View commit details
    Browse the repository at this point in the history
  3. Add missing TOC entry to Starlark local repo rules

    These were added in 6f254ce but never added to the table of contents.
    
    Work towards #18285.
    
    PiperOrigin-RevId: 617904579
    Change-Id: I062f7d2fb4bcd441db566e4d00ed9d5d9af43886
    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    41a3ba1 View commit details
    Browse the repository at this point in the history
  4. Remove tests for legacy non-platforms Android builds.

    PiperOrigin-RevId: 586091870
    Change-Id: I372189e8f853845ddedcfd5eb79242cabaeac69a
    katre authored and Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    839c48a View commit details
    Browse the repository at this point in the history
  5. Remove --crosstool_top from tests

    It became no-op in e116bae
    
    PiperOrigin-RevId: 616176650
    Change-Id: Ib3829f9446e6f2a3ecffb6b044d017d24f42a28b
    mai93 authored and Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    27e1b82 View commit details
    Browse the repository at this point in the history
  6. Stop using --android_cpu in tests.

    PiperOrigin-RevId: 617788535
    Change-Id: I485211508ea9a24837b574e3bb48a7e0d25b11d7
    katre authored and Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    439caa2 View commit details
    Browse the repository at this point in the history
  7. Fix C++ unit test to use C++ toolchains

    BEGIN_PUBLIC
    Fix C++ unit test to use C++ toolchains
    
    This is preparation to make --incompatible_enable_cc_toolchain_resolution a no-op. All the unit tests need to work with the flag enabled.
    END_PUBLIC
    
    PiperOrigin-RevId: 586254632
    Change-Id: I55452515e571f12eefa376718743b1f23cbdbde8
    comius authored and Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    988edce View commit details
    Browse the repository at this point in the history
  8. Make incompatible_enable_cc_toolchain_resolution a no-op in android_s…

    …dk_integration_test
    
    PiperOrigin-RevId: 588363296
    Change-Id: I8af466628ce9c8d9175533255faef36968570aa4
    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    be90874 View commit details
    Browse the repository at this point in the history
  9. remove fat_apk_usage from blaze

    PiperOrigin-RevId: 615086311
    Change-Id: I349c25de5561d4b27ec35391445b7d4a0714fe54
    Googler authored and Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    1acd1f6 View commit details
    Browse the repository at this point in the history
  10. Remove --host_crosstool_top and --crosstool_top from tests

    They became no-op in e116bae
    
    PiperOrigin-RevId: 615817205
    Change-Id: Id40a92daa1c1c7044f5e8618ff8f43345ecc0725
    mai93 authored and Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    2328206 View commit details
    Browse the repository at this point in the history
  11. Replace --cpu usages with --platforms in tests

    PiperOrigin-RevId: 616992341
    Change-Id: I6bbc763e85f5b2e6376179098e359a2361f18c6b
    mai93 authored and Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    df2b9df View commit details
    Browse the repository at this point in the history
  12. Use the host_platform from @platforms in Bazel

    * Upgrade to `platforms` 0.0.9
    * `--host_platform` now defaults to `@bazel_tools//tools:host_platform`, which is an alias of `@platforms//host`
    * `local_config_platform` (the repo rule) now just outputs a thin wrapper; `@local_config_platform//:host` is an alias of `@platforms//host`, and `@local_config_platform//:constraints.bzl` re-exports `@platforms//host:constraints.bzl`
    * Removed all test mocks of `local_config_platform`. A follow-up will guard prod usage behind a flag.
    
    Work towards #8766 and #18285.
    
    PiperOrigin-RevId: 620316973
    Change-Id: I6593f62569f31faee69e88a520a0f7f42009e05d
    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    1bb00bc View commit details
    Browse the repository at this point in the history
  13. Forcibly use the bundled version of @platforms for loading the host…

    … platform repo rule
    
    #21877 happened because, even though we define `@platforms` to be the bundled version shipped with Bazel (which is 0.0.9 on HEAD), people tend to define their own versions of `@platforms` in WORKSPACE. If this ends up being a lower version (very likely), the subsequent `load` to use the `host_platform_repo` repo rule (which is a Starlark version of `local_config_platform`) will fail because that repo rule was only introduced in `platforms` version 0.0.9.
    
    To resolve this conundrum, we define a new repo `@internal_platforms_do_not_use` that _also_ points to the bundled version of `@platforms`. Nobody is likely to define this repo, so we can fairly reliably get the Starlark repo rule, and also still allow people to override the actual `@platforms` targets they use.
    
    This only affects WORKSPACE users; if `--enable_bzlmod` is set, the `@host_platform` seen by `@bazel_tools` will come from the module extension instead.
    
    Work towards #18285.
    
    Fixes #21877.
    
    Closes #21902.
    
    PiperOrigin-RevId: 622238362
    Change-Id: I6335ab1bc26ba9ef54473d8a21fc5a8510a3ace5
    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    67c3255 View commit details
    Browse the repository at this point in the history
  14. Force local_config_platform to redirect to the bundled platforms repo

    Similar to 77469e0, we redirect the redirects/aliases generated by `local_config_plaform` to the bundled platforms repo (`@internal_platforms_do_not_use`) if Bzlmod is not enabled. Same for the `@bazel_tools//tools:host_platform` alias.
    
    Fixes #21877.
    
    Closes #22021.
    
    PiperOrigin-RevId: 625613724
    Change-Id: I17940e5d4fbd8a7690d9199f80b80ceb62b53d1a
    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    9b35e10 View commit details
    Browse the repository at this point in the history
  15. Extract Bazel registry creation into a SkyFunction

    This gets rid of an ad-hoc cache maintained in `RegistryFactoryImpl` and prepares for making registries aware of hashes stored in the lockfile.
    
    Work towards #20369
    
    Closes #22040.
    
    PiperOrigin-RevId: 626307340
    Change-Id: I34b428553f7169c72ed7dddd2fe3ea5e6dca2a97
    fmeum authored and Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    526d9fa View commit details
    Browse the repository at this point in the history
  16. Add new flag --incompatible_disable_native_repo_rules

    This new flag defaults to `false`. When set to `true`, native repo rules cannot be used in WORKSPACE; their Starlark counterparts must be used. Native repo rules already can't be used in Bzlmod.
    
    Work towards #18285.
    
    Closes #21913.
    
    PiperOrigin-RevId: 626410163
    Change-Id: I4981cd8d99fc87d0d0b66991e563941478b40f12
    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    2d50139 View commit details
    Browse the repository at this point in the history
  17. Revert android_sdk_repository to using local_config_platform

    The native repo rule `android_sdk_repository` used to load from `@local_config_platform//:constraints.bzl`; 74c8ca4 changed it to load from `@platforms//host:constraints.bzl`. This caused failures with WORKSPACE users, as `@platforms` might still refer to an old version of `platforms` which doesn't have the `host` package, even though `@local_config_platform` knows to redirect to the bundled, newer version of `platforms`.
    
    This CL reverts that change, so `android_sdk_repository` now loads from `@local_config_platform` again. This is fine because both are native repo rules and will be deprecated at the same time.
    
    Partially fixes #21877.
    
    PiperOrigin-RevId: 627395814
    Change-Id: I5761cde3c86190d6da3e3933aa1bef18e0dcca3e
    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    48bd6d7 View commit details
    Browse the repository at this point in the history
  18. update lockfiles

    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    f0d328b View commit details
    Browse the repository at this point in the history
  19. fix build?

    Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    766c4ba View commit details
    Browse the repository at this point in the history
  20. Fix obtaining C++ toolchains

    Expose a single public method getToolchain(RuleContext) from CppHelper. Before several methods public methods were exposed and those were hard to follow. The new method covers both cases C++ toolchain resolution enabled or disabled.
    
    Add toolchain to StarlarkCcCommonTest. Because the new method only uses toolchains (not legacy attributes) when toolchain resolution is enabled.
    
    This is a preparation to remove incompatible_enable_cc_toolchain_resolution.
    
    PiperOrigin-RevId: 584856533
    Change-Id: I6dec785e000b20d4aa26be93686fd5fdbad8ff76
    comius authored and Wyverald committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    03ca07b View commit details
    Browse the repository at this point in the history