diff --git a/BUILD.bazel b/BUILD.bazel index ea211b3..243ec10 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,3 +1,6 @@ +load("//tools/ci:assertions.bzl", "expect_equal") +load("//tools/flutter:android.bzl", "flutter_assets_dir") + # The root package exists so //tools/format:buildifier_test has a label in it to # locate the tree it should check. Nothing reads MODULE.bazel's contents through # this export. @@ -8,3 +11,13 @@ package(default_visibility = ["//visibility:public"]) exports_files(["MODULE.bazel"]) + +# Asserted rather than merely called: a silently wrong prefix is the failure +# this helper exists to prevent, and the root package is the case with no +# separator. Checked here rather than from a Consumer Module because the +# supported API deliberately does not export the helper. +expect_equal( + flutter_assets_dir(assets = ":assets"), + "assets", + "flutter_assets_dir in the root package", +) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 29ccf56..d175851 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -260,7 +260,7 @@ "moduleExtensions": { "//flutter:extensions.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "myIOBLM9s4amVM4T5T6C1tqW7cS9Lfibpp0Fm+0j9n0=", + "bzlTransitiveDigest": "W+b9mUmjJokRiRa9wTCAJ9dZ3uQ9K+TAfIefMFVXYGc=", "usagesDigest": "u+HEkcGg21uv1v1Y5n7OFzVXl5/8Fi8W5y561YLsmWA=", "recordedInputs": [ "REPO_MAPPING:,platforms platforms", @@ -299,7 +299,7 @@ }, "//tools/flutter:repo.bzl%flutter": { "general": { - "bzlTransitiveDigest": "xF3NHN89e0wpLlITfvPlzlq4YYs2Cm7XkvAn18uvo1k=", + "bzlTransitiveDigest": "d0akA1llff6BLmlVnXIvFQO70c00GoPx6Qps3UswgoY=", "usagesDigest": "XPc34iYcVtVwau1/PJTQZHYQ8UUdz8xOBCqsX8yLGUw=", "recordedInputs": [ "REPO_MAPPING:,bazel_tools bazel_tools", diff --git a/QUICKSTART.md b/QUICKSTART.md index c3bf635..dabc838 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -197,7 +197,7 @@ arm64 device slice and an x86_64 emulator slice; use one identical list in all three locations if you choose a different supported set. ```python -load("@rules_flutter//tools/flutter:defs.bzl", "flutter_app") +load("@rules_flutter//flutter:defs.bzl", "flutter_app") package(default_visibility = ["//visibility:public"]) @@ -226,8 +226,7 @@ path with the ones Flutter generated for your app: ```python load("@rules_android//rules:rules.bzl", "android_library") -load("@rules_flutter//tools/flutter:android.bzl", "flutter_android_binary") -load("@rules_flutter//tools/flutter:embedding.bzl", "flutter_embedding_library") +load("@rules_flutter//flutter:defs.bzl", "flutter_android_binary", "flutter_embedding_library") load("@rules_kotlin//kotlin:android.bzl", "kt_android_library") package(default_visibility = ["//visibility:public"]) @@ -285,7 +284,7 @@ build does not prove that the APK launches. To build the debug-shaped APK, select debug mode on the APK target: ```sh -bazel build //android/app:hello_bazel --@rules_flutter//tools/flutter:mode=debug +bazel build //android/app:hello_bazel --@rules_flutter//flutter:mode=debug ``` #### Hot reload with `flutter run` @@ -657,7 +656,7 @@ dependency, so omitting `path_deps` would leave an undeclared input and make the path-dependency guard fail. ```python -load("@rules_flutter//tools/flutter:defs.bzl", "flutter_app") +load("@rules_flutter//flutter:defs.bzl", "flutter_app") package(default_visibility = ["//visibility:public"]) @@ -878,7 +877,7 @@ the consumer's declared repository while the recipe file is loaded. A concise arm64 `rive_native` recipe is: ```python -load("@rules_flutter//tools/flutter:recipe.bzl", "flutter_native_contribution") +load("@rules_flutter//flutter:defs.bzl", "flutter_native_contribution") load("@rules_kotlin//kotlin:android.bzl", "kt_android_library") _LIBRARIES = { @@ -916,7 +915,7 @@ Flutter's native-assets manifest uses, then creates the empty conventional package target: ```python -load("@rules_flutter//tools/flutter:recipe.bzl", "flutter_native_contribution") +load("@rules_flutter//flutter:defs.bzl", "flutter_native_contribution") _LIBRARIES = { "arm64-v8a": Label("@libsqlite3_android_arm64_v8a//file"), @@ -1003,7 +1002,7 @@ bazel build //android/app:demo_app For the debug-shaped APK, select debug on the Android target: ```sh -bazel build //android/app:demo_app --@rules_flutter//tools/flutter:mode=debug +bazel build //android/app:demo_app --@rules_flutter//flutter:mode=debug ``` Debug bundles use a kernel blob rather than a release AOT snapshot. Therefore diff --git a/README.md b/README.md index eff660d..25ac04b 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ use_repo(maven, "flutter_maven") Create `BUILD.bazel` at the project root: ```python -load("@rules_flutter//tools/flutter:defs.bzl", "flutter_app") +load("@rules_flutter//flutter:defs.bzl", "flutter_app") package(default_visibility = ["//visibility:public"]) @@ -166,8 +166,7 @@ Create `android/app/BUILD.bazel`, replacing `com.example.hello_bazel`, `hello_ba ```python load("@rules_android//rules:rules.bzl", "android_library") -load("@rules_flutter//tools/flutter:android.bzl", "flutter_android_binary") -load("@rules_flutter//tools/flutter:embedding.bzl", "flutter_embedding_library") +load("@rules_flutter//flutter:defs.bzl", "flutter_android_binary", "flutter_embedding_library") load("@rules_kotlin//kotlin:android.bzl", "kt_android_library") package(default_visibility = ["//visibility:public"]) @@ -219,7 +218,7 @@ bazel test //:guards_test Replace `.apk` with the APK discovered in `bazel-bin/android/app/`. To build the optional debug-shaped APK: ```sh -bazel build //android/app:hello_bazel --@rules_flutter//tools/flutter:mode=debug +bazel build //android/app:hello_bazel --@rules_flutter//flutter:mode=debug ``` Run the Bazel-built debug APK through Flutter. This installs it, launches it, diff --git a/examples/demo_app/BUILD.bazel b/examples/demo_app/BUILD.bazel index 543b792..e464d26 100644 --- a/examples/demo_app/BUILD.bazel +++ b/examples/demo_app/BUILD.bazel @@ -1,7 +1,7 @@ # Dart targets for the flat demo app. Standard flutter_app paths are derived # from the flutter create layout. -load("@rules_flutter//tools/flutter:defs.bzl", "flutter_app") +load("@rules_flutter//flutter:defs.bzl", "flutter_app") package(default_visibility = ["//visibility:public"]) diff --git a/examples/demo_app/MODULE.bazel.lock b/examples/demo_app/MODULE.bazel.lock index 4129e21..5a6f4b0 100644 --- a/examples/demo_app/MODULE.bazel.lock +++ b/examples/demo_app/MODULE.bazel.lock @@ -557,7 +557,7 @@ }, "@@sameri11_rules_flutter+//flutter:extensions.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "h0f/0RNvDpo1r9DeVB1pJNoDRBHQDBih+l5n+H8Gacw=", + "bzlTransitiveDigest": "hdvS83CtH504cF/AHNScFkfQnnPeFFdgwAl9Vz64I2s=", "usagesDigest": "EKTbZN96IdqkA4qQ7A5/CMRth7+5iMGDY1uCPeLj36w=", "recordedInputs": [ "REPO_MAPPING:bazel_features+,bazel_features_globals bazel_features++version_extension+bazel_features_globals", @@ -596,7 +596,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:ndk.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "wubp2T1WtFjfb9+kfYhB63NRFwpD0mXcOWF3daEO03c=", + "bzlTransitiveDigest": "+yVx90itfoCuMV0GwiqbA145KmYQEsib0gKU5MAQuKM=", "usagesDigest": "QrRRy1TWmQYnmdSUlW7uJgLdSfFApDsrkLaLj/wqh2g=", "recordedInputs": [ "REPO_MAPPING:sameri11_rules_flutter+,rules_android_ndk rules_android_ndk+" @@ -615,7 +615,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:plugins.bzl%flutter_plugins_ext": { "general": { - "bzlTransitiveDigest": "tQNMt955Aw9GgNkaaslFjOQlTt/8uwsvu2YmduiXfjg=", + "bzlTransitiveDigest": "YkUtLkaUUzscr6grLYf7CKtO9Rmd3tq/ckkt5Z0jtEE=", "usagesDigest": "F7WFYMW4xxcij40v7+FEbGw5UG1ZlPv/+chnuAng8vI=", "recordedInputs": [ "REPO_MAPPING:,flutter_maven rules_jvm_external++maven+flutter_maven", @@ -663,8 +663,8 @@ "sqlite3": "{\"bzl\":\"@@//bazel/flutter:sqlite3.bzl\",\"macro\":\"sqlite3_recipe\",\"root\":true}" }, "embedding": "'@@//android/app:flutter_embedding'", - "android_bzl": "'@@sameri11_rules_flutter+//tools/flutter:android.bzl'", - "recipe_bzl": "'@@sameri11_rules_flutter+//tools/flutter:recipe.bzl'", + "android_bzl": "'@@sameri11_rules_flutter+//flutter:defs.bzl'", + "recipe_bzl": "'@@sameri11_rules_flutter+//flutter:defs.bzl'", "ndk_source_properties": "'@@sameri11_rules_flutter++android_ndk2+androidndk_cmake//:ndk_source_properties'" } } @@ -673,7 +673,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:repo.bzl%flutter": { "general": { - "bzlTransitiveDigest": "xF3NHN89e0wpLlITfvPlzlq4YYs2Cm7XkvAn18uvo1k=", + "bzlTransitiveDigest": "d0akA1llff6BLmlVnXIvFQO70c00GoPx6Qps3UswgoY=", "usagesDigest": "R5N9St8lZgehSPaOYkim03MK+V5jF4ZlA8/A8xndCVA=", "recordedInputs": [ "REPO_MAPPING:sameri11_rules_flutter+,bazel_tools bazel_tools", diff --git a/examples/demo_app/android/app/BUILD.bazel b/examples/demo_app/android/app/BUILD.bazel index 445486b..ea796ee 100644 --- a/examples/demo_app/android/app/BUILD.bazel +++ b/examples/demo_app/android/app/BUILD.bazel @@ -7,15 +7,14 @@ # files, so this BUILD survives, but keep that in mind when upgrading templates. load("@rules_android//rules:rules.bzl", "android_library") -load("@rules_flutter//tools/flutter:android.bzl", "flutter_android_binary") -load("@rules_flutter//tools/flutter:embedding.bzl", "flutter_embedding_library") +load("@rules_flutter//flutter:defs.bzl", "flutter_android_binary", "flutter_embedding_library") load("@rules_kotlin//kotlin:android.bzl", "kt_android_library") package(default_visibility = ["//visibility:public"]) # Every plugin `pub get` reported as having an Android native build. The # aggregate is generated from .flutter-plugins-dependencies, so adding a plugin -# to pubspec.yaml is the only step -- see @rules_flutter//tools/flutter:plugins.bzl. Named +# to pubspec.yaml is the only step -- see @rules_flutter//flutter:extensions.bzl. Named # here only because :generated_plugin_registrant and :main_activity need it; # the APK derives it. PLUGINS = ["@flutter_plugins//:all"] @@ -34,7 +33,7 @@ ABIS = [ # this project's MODULE.bazel creates from this project's plugin coordinates. A # label naming it from inside the rules would resolve against the *rules'* # dependencies instead -- which is exactly the bug that made these rules -# unusable as a bazel_dep. See @rules_flutter//tools/flutter:embedding.bzl. +# unusable as a bazel_dep. See @rules_flutter//flutter:defs.bzl. flutter_embedding_library(name = "flutter_embedding") # Every Flutter contribution to the APK, joined into one target -- the AOT @@ -42,7 +41,7 @@ flutter_embedding_library(name = "flutter_embedding") # and their native halves, the recipe libraries, the registrant -- and then one # APK per shape: :demo_app carries every ABI, :demo_app_ carries one. A # bundle check per shape fails the build if any of them is missing a piece; see -# @rules_flutter//tools/flutter:bundle.bzl. +# @rules_flutter//flutter:defs.bzl. # # Four things are stated: the ABIs, the Dart half's package, the applicationId # and this module's own targets. The rest is derived -- //:app, //:assets and diff --git a/examples/demo_app/bazel/flutter/BUILD.bazel b/examples/demo_app/bazel/flutter/BUILD.bazel index bd59815..0fcb6dc 100644 --- a/examples/demo_app/bazel/flutter/BUILD.bazel +++ b/examples/demo_app/bazel/flutter/BUILD.bazel @@ -1,5 +1,5 @@ # Recipes for pub packages that fall outside the standard build, supplied by -# this project to //tools/flutter:plugins.bzl through plugins.package(). +# this project to //flutter:extensions.bzl through plugins.package(). # # These are consumer-side files: they are loaded by BUILD files the rules # generate, by canonical label, and their own load() statements resolve in this diff --git a/examples/demo_app/bazel/flutter/rive_native.bzl b/examples/demo_app/bazel/flutter/rive_native.bzl index 59e443c..22a6180 100644 --- a/examples/demo_app/bazel/flutter/rive_native.bzl +++ b/examples/demo_app/bazel/flutter/rive_native.bzl @@ -1,7 +1,7 @@ """Recipe for rive_native's Kotlin plugin and prebuilt Android libraries.""" # Load from the defining module; @@// is root-module-relative. -load("@rules_flutter//tools/flutter:recipe.bzl", "flutter_native_contribution") +load("@rules_flutter//flutter:defs.bzl", "flutter_native_contribution") load("@rules_kotlin//kotlin:android.bzl", "kt_android_library") # The archive's supported ABIs. Label() resolves repositories in this module. diff --git a/examples/demo_app/bazel/flutter/sqlite3.bzl b/examples/demo_app/bazel/flutter/sqlite3.bzl index d104f37..32b3b0d 100644 --- a/examples/demo_app/bazel/flutter/sqlite3.bzl +++ b/examples/demo_app/bazel/flutter/sqlite3.bzl @@ -7,7 +7,7 @@ code asset below. # Resolve these repositories in this module, where MODULE.bazel declares them. # Bare apparent names would resolve in the generated repository's mapping. -load("@rules_flutter//tools/flutter:recipe.bzl", "flutter_native_contribution") +load("@rules_flutter//flutter:defs.bzl", "flutter_native_contribution") _LIBRARIES = { "arm64-v8a": Label("@libsqlite3_android_arm64_v8a//file"), diff --git a/examples/demo_app/lib/dart_plugin_registrant.dart b/examples/demo_app/lib/dart_plugin_registrant.dart index a2b713e..e9c6a21 100755 --- a/examples/demo_app/lib/dart_plugin_registrant.dart +++ b/examples/demo_app/lib/dart_plugin_registrant.dart @@ -1,5 +1,5 @@ // -// Generated by //tools/flutter:plugins.bzl -- do not edit. +// Generated by //flutter:extensions.bzl -- do not edit. // // The Dart half of plugin registration. GeneratedPluginRegistrant.java // instantiates each plugin's *native* class; a federated plugin also ships a diff --git a/examples/demo_app/plugin_deps.MODULE.bazel b/examples/demo_app/plugin_deps.MODULE.bazel index 9cdf358..cd57ed5 100644 --- a/examples/demo_app/plugin_deps.MODULE.bazel +++ b/examples/demo_app/plugin_deps.MODULE.bazel @@ -1,4 +1,4 @@ -# Generated by @rules_flutter//tools/flutter:plugins.bzl -- do not edit by hand. +# Generated by @rules_flutter//flutter:extensions.bzl -- do not edit by hand. # # Maven artifacts from the Flutter embedding and plugin build files. # Run the generated updater target when `pub_plugins_check` reports drift. diff --git a/examples/local_plugin/MODULE.bazel.lock b/examples/local_plugin/MODULE.bazel.lock index ef203ce..ae195f5 100644 --- a/examples/local_plugin/MODULE.bazel.lock +++ b/examples/local_plugin/MODULE.bazel.lock @@ -557,7 +557,7 @@ }, "@@sameri11_rules_flutter+//flutter:extensions.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "h0f/0RNvDpo1r9DeVB1pJNoDRBHQDBih+l5n+H8Gacw=", + "bzlTransitiveDigest": "hdvS83CtH504cF/AHNScFkfQnnPeFFdgwAl9Vz64I2s=", "usagesDigest": "EKTbZN96IdqkA4qQ7A5/CMRth7+5iMGDY1uCPeLj36w=", "recordedInputs": [ "REPO_MAPPING:bazel_features+,bazel_features_globals bazel_features++version_extension+bazel_features_globals", @@ -596,7 +596,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:ndk.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "wubp2T1WtFjfb9+kfYhB63NRFwpD0mXcOWF3daEO03c=", + "bzlTransitiveDigest": "+yVx90itfoCuMV0GwiqbA145KmYQEsib0gKU5MAQuKM=", "usagesDigest": "A7oaOkSjfvJwyjAnMsfa+v9OgvQ5pbbliBwdFibgSv4=", "recordedInputs": [ "REPO_MAPPING:sameri11_rules_flutter+,rules_android_ndk rules_android_ndk+" @@ -615,7 +615,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:plugins.bzl%flutter_plugins_ext": { "general": { - "bzlTransitiveDigest": "tQNMt955Aw9GgNkaaslFjOQlTt/8uwsvu2YmduiXfjg=", + "bzlTransitiveDigest": "YkUtLkaUUzscr6grLYf7CKtO9Rmd3tq/ckkt5Z0jtEE=", "usagesDigest": "VUBQEAvg1xhSGldyNPLYePHfrRP9QsreeqwpYGsvf4s=", "recordedInputs": [ "REPO_MAPPING:,flutter_maven rules_jvm_external++maven+flutter_maven", @@ -658,8 +658,8 @@ "overrides": {}, "recipes": {}, "embedding": "'@@//packages/host_app/android/app:flutter_embedding'", - "android_bzl": "'@@sameri11_rules_flutter+//tools/flutter:android.bzl'", - "recipe_bzl": "'@@sameri11_rules_flutter+//tools/flutter:recipe.bzl'", + "android_bzl": "'@@sameri11_rules_flutter+//flutter:defs.bzl'", + "recipe_bzl": "'@@sameri11_rules_flutter+//flutter:defs.bzl'", "ndk_source_properties": "'@@sameri11_rules_flutter++android_ndk2+androidndk_cmake//:ndk_source_properties'" } } @@ -668,7 +668,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:repo.bzl%flutter": { "general": { - "bzlTransitiveDigest": "xF3NHN89e0wpLlITfvPlzlq4YYs2Cm7XkvAn18uvo1k=", + "bzlTransitiveDigest": "d0akA1llff6BLmlVnXIvFQO70c00GoPx6Qps3UswgoY=", "usagesDigest": "R5N9St8lZgehSPaOYkim03MK+V5jF4ZlA8/A8xndCVA=", "recordedInputs": [ "REPO_MAPPING:sameri11_rules_flutter+,bazel_tools bazel_tools", diff --git a/examples/local_plugin/packages/host_app/BUILD.bazel b/examples/local_plugin/packages/host_app/BUILD.bazel index d151c64..d20bf18 100644 --- a/examples/local_plugin/packages/host_app/BUILD.bazel +++ b/examples/local_plugin/packages/host_app/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_flutter//tools/flutter:defs.bzl", "flutter_app") +load("@rules_flutter//flutter:defs.bzl", "flutter_app") package(default_visibility = ["//visibility:public"]) diff --git a/examples/local_plugin/packages/host_app/android/app/BUILD.bazel b/examples/local_plugin/packages/host_app/android/app/BUILD.bazel index 27ca78b..aecb9bd 100644 --- a/examples/local_plugin/packages/host_app/android/app/BUILD.bazel +++ b/examples/local_plugin/packages/host_app/android/app/BUILD.bazel @@ -1,6 +1,5 @@ load("@rules_android//rules:rules.bzl", "android_library") -load("@rules_flutter//tools/flutter:android.bzl", "flutter_android_binary") -load("@rules_flutter//tools/flutter:embedding.bzl", "flutter_embedding_library") +load("@rules_flutter//flutter:defs.bzl", "flutter_android_binary", "flutter_embedding_library") load("@rules_kotlin//kotlin:android.bzl", "kt_android_library") package(default_visibility = ["//visibility:public"]) diff --git a/examples/local_plugin/packages/host_app/lib/dart_plugin_registrant.dart b/examples/local_plugin/packages/host_app/lib/dart_plugin_registrant.dart index 34dea82..73b4882 100755 --- a/examples/local_plugin/packages/host_app/lib/dart_plugin_registrant.dart +++ b/examples/local_plugin/packages/host_app/lib/dart_plugin_registrant.dart @@ -1,5 +1,5 @@ // -// Generated by //tools/flutter:plugins.bzl -- do not edit. +// Generated by //flutter:extensions.bzl -- do not edit. // // The Dart half of plugin registration. GeneratedPluginRegistrant.java // instantiates each plugin's *native* class; a federated plugin also ships a diff --git a/examples/local_plugin/plugin_deps.MODULE.bazel b/examples/local_plugin/plugin_deps.MODULE.bazel index 2966fbf..d930ba1 100644 --- a/examples/local_plugin/plugin_deps.MODULE.bazel +++ b/examples/local_plugin/plugin_deps.MODULE.bazel @@ -1,4 +1,4 @@ -# Generated by @rules_flutter//tools/flutter:plugins.bzl -- do not edit by hand. +# Generated by @rules_flutter//flutter:extensions.bzl -- do not edit by hand. # # Maven artifacts from the Flutter embedding and plugin build files. # Run the generated updater target when `pub_plugins_check` reports drift. diff --git a/examples/no_plugins/BUILD.bazel b/examples/no_plugins/BUILD.bazel index 00112ed..d96523d 100644 --- a/examples/no_plugins/BUILD.bazel +++ b/examples/no_plugins/BUILD.bazel @@ -1,6 +1,6 @@ # Dart targets for a plugin-free app. -load("@rules_flutter//tools/flutter:defs.bzl", "flutter_app") +load("@rules_flutter//flutter:defs.bzl", "flutter_app") package(default_visibility = ["//visibility:public"]) diff --git a/examples/no_plugins/MODULE.bazel.lock b/examples/no_plugins/MODULE.bazel.lock index 5a35db1..ace1e6f 100644 --- a/examples/no_plugins/MODULE.bazel.lock +++ b/examples/no_plugins/MODULE.bazel.lock @@ -557,7 +557,7 @@ }, "@@sameri11_rules_flutter+//flutter:extensions.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "h0f/0RNvDpo1r9DeVB1pJNoDRBHQDBih+l5n+H8Gacw=", + "bzlTransitiveDigest": "hdvS83CtH504cF/AHNScFkfQnnPeFFdgwAl9Vz64I2s=", "usagesDigest": "EKTbZN96IdqkA4qQ7A5/CMRth7+5iMGDY1uCPeLj36w=", "recordedInputs": [ "REPO_MAPPING:bazel_features+,bazel_features_globals bazel_features++version_extension+bazel_features_globals", @@ -596,7 +596,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:ndk.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "wubp2T1WtFjfb9+kfYhB63NRFwpD0mXcOWF3daEO03c=", + "bzlTransitiveDigest": "+yVx90itfoCuMV0GwiqbA145KmYQEsib0gKU5MAQuKM=", "usagesDigest": "RmWgbl3ZrcRS38YkTUmgaXvm4e7smxgPZPFePrLvlLU=", "recordedInputs": [ "REPO_MAPPING:sameri11_rules_flutter+,rules_android_ndk rules_android_ndk+" @@ -615,7 +615,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:repo.bzl%flutter": { "general": { - "bzlTransitiveDigest": "xF3NHN89e0wpLlITfvPlzlq4YYs2Cm7XkvAn18uvo1k=", + "bzlTransitiveDigest": "d0akA1llff6BLmlVnXIvFQO70c00GoPx6Qps3UswgoY=", "usagesDigest": "R5N9St8lZgehSPaOYkim03MK+V5jF4ZlA8/A8xndCVA=", "recordedInputs": [ "REPO_MAPPING:sameri11_rules_flutter+,bazel_tools bazel_tools", diff --git a/examples/no_plugins/android/app/BUILD.bazel b/examples/no_plugins/android/app/BUILD.bazel index a672443..78ed3da 100644 --- a/examples/no_plugins/android/app/BUILD.bazel +++ b/examples/no_plugins/android/app/BUILD.bazel @@ -1,8 +1,7 @@ # Android targets for the plugin-free app. load("@rules_android//rules:rules.bzl", "android_library") -load("@rules_flutter//tools/flutter:android.bzl", "flutter_android_binary") -load("@rules_flutter//tools/flutter:embedding.bzl", "flutter_embedding_library") +load("@rules_flutter//flutter:defs.bzl", "flutter_android_binary", "flutter_embedding_library") load("@rules_kotlin//kotlin:android.bzl", "kt_android_library") package(default_visibility = ["//visibility:public"]) diff --git a/examples/pub_plugins/BUILD.bazel b/examples/pub_plugins/BUILD.bazel index 819a9e6..b7a4d7f 100644 --- a/examples/pub_plugins/BUILD.bazel +++ b/examples/pub_plugins/BUILD.bazel @@ -1,6 +1,6 @@ # Dart targets for the flat pub-plugin example. -load("@rules_flutter//tools/flutter:defs.bzl", "flutter_app") +load("@rules_flutter//flutter:defs.bzl", "flutter_app") package(default_visibility = ["//visibility:public"]) diff --git a/examples/pub_plugins/MODULE.bazel.lock b/examples/pub_plugins/MODULE.bazel.lock index 7f99143..d78bd68 100644 --- a/examples/pub_plugins/MODULE.bazel.lock +++ b/examples/pub_plugins/MODULE.bazel.lock @@ -557,7 +557,7 @@ }, "@@sameri11_rules_flutter+//flutter:extensions.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "h0f/0RNvDpo1r9DeVB1pJNoDRBHQDBih+l5n+H8Gacw=", + "bzlTransitiveDigest": "hdvS83CtH504cF/AHNScFkfQnnPeFFdgwAl9Vz64I2s=", "usagesDigest": "EKTbZN96IdqkA4qQ7A5/CMRth7+5iMGDY1uCPeLj36w=", "recordedInputs": [ "REPO_MAPPING:bazel_features+,bazel_features_globals bazel_features++version_extension+bazel_features_globals", @@ -596,7 +596,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:ndk.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "wubp2T1WtFjfb9+kfYhB63NRFwpD0mXcOWF3daEO03c=", + "bzlTransitiveDigest": "+yVx90itfoCuMV0GwiqbA145KmYQEsib0gKU5MAQuKM=", "usagesDigest": "DbV1H8oR3Qzpg/rrhdvrY4gJ0TwkhR++v18wnMYCt14=", "recordedInputs": [ "REPO_MAPPING:sameri11_rules_flutter+,rules_android_ndk rules_android_ndk+" @@ -615,7 +615,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:plugins.bzl%flutter_plugins_ext": { "general": { - "bzlTransitiveDigest": "tQNMt955Aw9GgNkaaslFjOQlTt/8uwsvu2YmduiXfjg=", + "bzlTransitiveDigest": "YkUtLkaUUzscr6grLYf7CKtO9Rmd3tq/ckkt5Z0jtEE=", "usagesDigest": "7EaQlVY1ElLzwQfzHxuszltJYgtUcQ7K4xYdgBgA7uU=", "recordedInputs": [ "REPO_MAPPING:,flutter_maven rules_jvm_external++maven+flutter_maven", @@ -658,8 +658,8 @@ "overrides": {}, "recipes": {}, "embedding": "'@@//android/app:flutter_embedding'", - "android_bzl": "'@@sameri11_rules_flutter+//tools/flutter:android.bzl'", - "recipe_bzl": "'@@sameri11_rules_flutter+//tools/flutter:recipe.bzl'", + "android_bzl": "'@@sameri11_rules_flutter+//flutter:defs.bzl'", + "recipe_bzl": "'@@sameri11_rules_flutter+//flutter:defs.bzl'", "ndk_source_properties": "'@@sameri11_rules_flutter++android_ndk2+androidndk_cmake//:ndk_source_properties'" } } @@ -668,7 +668,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:repo.bzl%flutter": { "general": { - "bzlTransitiveDigest": "xF3NHN89e0wpLlITfvPlzlq4YYs2Cm7XkvAn18uvo1k=", + "bzlTransitiveDigest": "d0akA1llff6BLmlVnXIvFQO70c00GoPx6Qps3UswgoY=", "usagesDigest": "R5N9St8lZgehSPaOYkim03MK+V5jF4ZlA8/A8xndCVA=", "recordedInputs": [ "REPO_MAPPING:sameri11_rules_flutter+,bazel_tools bazel_tools", diff --git a/examples/pub_plugins/android/app/BUILD.bazel b/examples/pub_plugins/android/app/BUILD.bazel index 8d48f76..76293cf 100644 --- a/examples/pub_plugins/android/app/BUILD.bazel +++ b/examples/pub_plugins/android/app/BUILD.bazel @@ -2,8 +2,7 @@ # manifest, resources and sources. load("@rules_android//rules:rules.bzl", "android_library") -load("@rules_flutter//tools/flutter:android.bzl", "flutter_android_binary") -load("@rules_flutter//tools/flutter:embedding.bzl", "flutter_embedding_library") +load("@rules_flutter//flutter:defs.bzl", "flutter_android_binary", "flutter_embedding_library") load("@rules_kotlin//kotlin:android.bzl", "kt_android_library") package(default_visibility = ["//visibility:public"]) diff --git a/examples/pub_plugins/lib/dart_plugin_registrant.dart b/examples/pub_plugins/lib/dart_plugin_registrant.dart index 20b8d02..663c793 100755 --- a/examples/pub_plugins/lib/dart_plugin_registrant.dart +++ b/examples/pub_plugins/lib/dart_plugin_registrant.dart @@ -1,5 +1,5 @@ // -// Generated by //tools/flutter:plugins.bzl -- do not edit. +// Generated by //flutter:extensions.bzl -- do not edit. // // The Dart half of plugin registration. GeneratedPluginRegistrant.java // instantiates each plugin's *native* class; a federated plugin also ships a diff --git a/examples/pub_plugins/plugin_deps.MODULE.bazel b/examples/pub_plugins/plugin_deps.MODULE.bazel index faf1cde..9b85f85 100644 --- a/examples/pub_plugins/plugin_deps.MODULE.bazel +++ b/examples/pub_plugins/plugin_deps.MODULE.bazel @@ -1,4 +1,4 @@ -# Generated by @rules_flutter//tools/flutter:plugins.bzl -- do not edit by hand. +# Generated by @rules_flutter//flutter:extensions.bzl -- do not edit by hand. # # Maven artifacts from the Flutter embedding and plugin build files. # Run the generated updater target when `pub_plugins_check` reports drift. diff --git a/flutter/BUILD.bazel b/flutter/BUILD.bazel index 281e959..1bff3c0 100644 --- a/flutter/BUILD.bazel +++ b/flutter/BUILD.bazel @@ -1,6 +1,26 @@ +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load("//tools/flutter:abis.bzl", "MODES") + package(default_visibility = ["//visibility:public"]) exports_files([ "defs.bzl", "extensions.bzl", ]) + +# Flutter runtime mode, independent of --compilation_mode. +string_flag( + name = "mode", + build_setting_default = "release", + values = MODES, +) + +config_setting( + name = "mode_debug", + flag_values = {":mode": "debug"}, +) + +config_setting( + name = "mode_release", + flag_values = {":mode": "release"}, +) diff --git a/tests/consumer/BUILD.bazel b/tests/consumer/BUILD.bazel index 88f10fe..4e2ccc9 100644 --- a/tests/consumer/BUILD.bazel +++ b/tests/consumer/BUILD.bazel @@ -1,7 +1,7 @@ -"""Supported BUILD API, including macro-internal coverage. +"""The supported BUILD API for a Consumer Module. -Public symbols load from @rules_flutter//flutter:defs.bzl. Specialist loads -cover private helpers, not Consumer Module API. +All supported symbols load from @rules_flutter//flutter:defs.bzl. Internal +implementation helpers are exercised indirectly through the supported macros. """ load("@bazel_skylib//rules:build_test.bzl", "build_test") @@ -23,22 +23,6 @@ load( "pub_plugins_check", "strip_native_libs", ) -load( - "@rules_flutter//tools/flutter:abis.bzl", - "aot_gen_snapshot", - "aot_target_compatible_with", - "plugin_repo_target", -) -load("@rules_flutter//tools/flutter:android.bzl", "flutter_assets_dir") -load( - "@rules_flutter//tools/flutter:bundle.bzl", - "CLASSES", - "NATIVE_LIB", - "flutter_bundle_contribution", -) - -# Macro-internal coverage only; not Consumer Module API. -load("@rules_flutter//tools/flutter:defs.bzl", "dart_aot_elf") load("@rules_java//java:defs.bzl", "java_import") load(":assertions.bzl", "expect_equal", "expect_label_equal") @@ -74,26 +58,6 @@ dart_kernel( target_os = "ios", ) -dart_aot_elf( - name = "aot", - dill = ":kernel", - gen_snapshot = aot_gen_snapshot("arm64-v8a"), - snapshot_flags = ABIS["arm64-v8a"].snapshot_flags, - strip = True, - target_compatible_with = aot_target_compatible_with(), -) - -# The ABI carrying gen_snapshot flags. Named so a table entry losing them is an -# analysis-visible change here rather than a silent one in a snapshot. -dart_aot_elf( - name = "aot_armv7", - dill = ":kernel", - gen_snapshot = aot_gen_snapshot("armeabi-v7a"), - snapshot_flags = ABIS["armeabi-v7a"].snapshot_flags, - strip = True, - target_compatible_with = aot_target_compatible_with(), -) - expect_equal( ABIS["armeabi-v7a"].snapshot_flags, [ @@ -297,15 +261,6 @@ java_import( jars = ["fixtures/fake_native_libs.jar"], ) -# Asserted rather than merely called: a silently wrong prefix is the failure it -# exists to prevent, and this module's assets target sits in the root package, -# the case with no separator. -expect_equal( - flutter_assets_dir(assets = ":assets"), - "assets", - "flutter_assets_dir(':assets')", -) - # Two ABIs, so the per-ABI shape is exercised rather than degenerating to one # entry, and `aot` is the real flutter_aot_library above -- the join derives # `_` from it, and a rename breaks that. @@ -340,34 +295,6 @@ flutter_android_libs( registrant = ":fake_registrant", ) -# The contribution rule on its own, in all three forms: slice-keyed, not, and -# the `empty = True` one VI.2 names as the first thing a non-Android platform -# needs. -flutter_bundle_contribution( - name = "contribution", - srcs = ["fixtures/libfake.so"], - kind = "aot_library", - location = NATIVE_LIB, -) - -flutter_bundle_contribution( - name = "contribution_sliced", - kind = "recipe_libraries", - libraries = { - "arm64-v8a": "fixtures/libfake.so", - "x86_64": "fixtures/libfake.so", - }, - location = NATIVE_LIB, -) - -flutter_bundle_contribution( - name = "contribution_empty", - srcs = [], - empty = True, - kind = "runtime_classes", - location = CLASSES, -) - # The macro on top of the join: it emits `` plus `_`, so a # consumer's APK targets are named by it and a rename here is a rename in their # CI scripts. Two ABIs, because the per-ABI variants only exist above one. @@ -567,7 +494,7 @@ build_test( "@flutter_plugins//fake_plugin:fake_plugin", # A Kotlin-only plugin leaves this per-ABI native aggregate empty. It # must still provide JavaInfo through an empty `java_library`. - "@flutter_plugins//:" + plugin_repo_target("plugin_native_libraries", "arm64-v8a"), + "@flutter_plugins//:plugin_libs_arm64-v8a", ], ) @@ -575,8 +502,8 @@ build_test( alias( name = "embedding_mode_hazard_expected", actual = select({ - "@rules_flutter//tools/flutter:mode_debug": "@flutter_embedding_debug//jar:file", - "@rules_flutter//tools/flutter:mode_release": "@flutter_embedding_release//jar:file", + "@rules_flutter//flutter:mode_debug": "@flutter_embedding_debug//jar:file", + "@rules_flutter//flutter:mode_release": "@flutter_embedding_release//jar:file", }), ) @@ -591,7 +518,7 @@ genrule( if ! cmp -s "$(location :flutter_embedding_no_plugins)" "$(location :embedding_mode_hazard_expected)"; then echo "flutter_embedding_no_plugins is not this configuration's embedding" >&2 echo "jar. embedding.bzl's jars select() resolved a select() key against" >&2 - echo "the decoy //tools/flutter package instead of @rules_flutter's --" >&2 + echo "this module's decoy package instead of @rules_flutter's --" >&2 echo "see the comment above." >&2 exit 1 fi diff --git a/tests/consumer/MODULE.bazel.lock b/tests/consumer/MODULE.bazel.lock index 6943749..fabfbc6 100644 --- a/tests/consumer/MODULE.bazel.lock +++ b/tests/consumer/MODULE.bazel.lock @@ -557,7 +557,7 @@ }, "@@sameri11_rules_flutter+//flutter:extensions.bzl%android_ndk": { "general": { - "bzlTransitiveDigest": "h0f/0RNvDpo1r9DeVB1pJNoDRBHQDBih+l5n+H8Gacw=", + "bzlTransitiveDigest": "hdvS83CtH504cF/AHNScFkfQnnPeFFdgwAl9Vz64I2s=", "usagesDigest": "CE2Z/tOTJqwioicux0yXg4nzWLIvZDfcM/KtRNy1Og4=", "recordedInputs": [ "REPO_MAPPING:bazel_features+,bazel_features_globals bazel_features++version_extension+bazel_features_globals", @@ -596,7 +596,7 @@ }, "@@sameri11_rules_flutter+//flutter:extensions.bzl%flutter_plugins_ext": { "general": { - "bzlTransitiveDigest": "h0f/0RNvDpo1r9DeVB1pJNoDRBHQDBih+l5n+H8Gacw=", + "bzlTransitiveDigest": "hdvS83CtH504cF/AHNScFkfQnnPeFFdgwAl9Vz64I2s=", "usagesDigest": "Ledc+BavJyeReHRqHvz5/Wcm+5OIAQF8UJuGmSbzKpI=", "recordedInputs": [ "REPO_MAPPING:,fake_plugin_metadata +fake_plugin_metadata+fake_plugin_metadata", @@ -643,8 +643,8 @@ "absent_package": "{\"bzl\":\"@@external_app+//:absent_package.bzl\",\"macro\":\"absent_package_recipe\",\"root\":false}" }, "embedding": "'@@//:flutter_embedding_no_plugins'", - "android_bzl": "'@@sameri11_rules_flutter+//tools/flutter:android.bzl'", - "recipe_bzl": "'@@sameri11_rules_flutter+//tools/flutter:recipe.bzl'", + "android_bzl": "'@@sameri11_rules_flutter+//flutter:defs.bzl'", + "recipe_bzl": "'@@sameri11_rules_flutter+//flutter:defs.bzl'", "ndk_source_properties": "'@@sameri11_rules_flutter++android_ndk+androidndk_cmake//:ndk_source_properties'" } } @@ -653,7 +653,7 @@ }, "@@sameri11_rules_flutter+//tools/flutter:repo.bzl%flutter": { "general": { - "bzlTransitiveDigest": "xF3NHN89e0wpLlITfvPlzlq4YYs2Cm7XkvAn18uvo1k=", + "bzlTransitiveDigest": "d0akA1llff6BLmlVnXIvFQO70c00GoPx6Qps3UswgoY=", "usagesDigest": "eda2QKoZ+OsZtf4G6TFDQlPX9B2jypD8+TJmVZiVbyA=", "recordedInputs": [ "REPO_MAPPING:sameri11_rules_flutter+,bazel_tools bazel_tools", diff --git a/tests/consumer/README.md b/tests/consumer/README.md index 2ffdeb9..494f267 100644 --- a/tests/consumer/README.md +++ b/tests/consumer/README.md @@ -58,17 +58,16 @@ Bazel would descend in and evaluate these packages as *root* packages, where ## What it covers -Loading and analysis — `--nobuild` — of every public symbol, plus focused -behavior checks: +Loading and analysis — `--nobuild` — of every supported BUILD symbol through +`@rules_flutter//flutter:defs.bzl`, plus focused behavior checks: -| file | symbols | +| entry point | symbols | | --- | --- | -| `defs.bzl` | `dart_kernel`, `dart_aot_elf`, `flutter_aot_library`, `flutter_assets`, `pub_path_deps_check`, `pub_plugins_check`, `flutter_app` | -| `android.bzl` | `jni_lib_jar`, `android_native_lib_jar`, `strip_native_libs` | -| `bundle.bzl` | `flutter_bundle_contribution` (all three forms: `srcs`, slice-keyed `libraries`, `empty`), the location constants | -| `android.bzl` (join) | `flutter_android_libs` over **two** ABIs, and `flutter_android_binary` on top of it — the entry point that names a consumer's APK targets; `:apk_external_app` drives that high-level API from an external module through a real bundle and signed APK | -| `recipe.bzl` | `flutter_native_contribution` (both the populated and `empty = True` forms), `flutter_native_libs` | -| `plugins.bzl` | `flutter_plugins_ext` (`plugins.project()`/`plugins.package()`) over a real, checked-in external plugin graph — `:fake_plugin_deps_check`, `:fake_plugin_test` | +| `defs.bzl` | `ABIS`, `dart_kernel`, `flutter_aot_library`, `flutter_assets`, `pub_path_deps_check`, `pub_plugins_check`, `flutter_app`, `jni_lib_jar`, `android_native_lib_jar`, `strip_native_libs`, `flutter_android_libs`, `flutter_android_binary`, `flutter_embedding_library`, `flutter_native_contribution`, `flutter_native_libs`, `flutter_pubspec` | +| `extensions.bzl` | `flutter_plugins_ext` (`plugins.project()`/`plugins.package()`) over a real, checked-in external plugin graph — `:fake_plugin_deps_check`, `:fake_plugin_test` | + +Implementation-only rules and helpers are covered indirectly by these supported +macros; this Consumer Module does not load specialist implementation files. That catches the two things a refactor of these rules actually breaks: a symbol moving between files (load phase) and an attribute renamed, removed or made diff --git a/tests/consumer/external_app/absent_package.bzl b/tests/consumer/external_app/absent_package.bzl index 168a85f..1517643 100644 --- a/tests/consumer/external_app/absent_package.bzl +++ b/tests/consumer/external_app/absent_package.bzl @@ -5,7 +5,7 @@ depend on. `_flutter_plugins_impl` must report and discard it. The impossible symbol below turns any attempted load into a test failure. """ -load("@rules_flutter//tools/flutter:recipe.bzl", "this_symbol_does_not_exist") +load("@rules_flutter//flutter:defs.bzl", "this_symbol_does_not_exist") # Keep the alias so buildifier treats the deliberately invalid import as used. absent_package_recipe = this_symbol_does_not_exist diff --git a/tests/consumer/fixtures/plugin_deps.MODULE.bazel b/tests/consumer/fixtures/plugin_deps.MODULE.bazel index 6bad892..3aeb04c 100644 --- a/tests/consumer/fixtures/plugin_deps.MODULE.bazel +++ b/tests/consumer/fixtures/plugin_deps.MODULE.bazel @@ -1,7 +1,7 @@ -# Generated by @rules_flutter//tools/flutter:plugins.bzl -- do not edit by hand. +# Generated by @rules_flutter//flutter:extensions.bzl -- do not edit by hand. # # The complete Maven artifact list: the Flutter embedding's own dependencies -# (from @rules_flutter//tools/flutter:embedding.bzl) merged with the coordinates +# (from @rules_flutter//flutter:defs.bzl) merged with the coordinates # extracted from every plugin's android/build.gradle. # # Drift is detected by a `pub_plugins_check` guard over this file. A project diff --git a/tests/consumer/tools/flutter/BUILD.bazel b/tests/consumer/flutter/BUILD.bazel similarity index 83% rename from tests/consumer/tools/flutter/BUILD.bazel rename to tests/consumer/flutter/BUILD.bazel index 24825f4..fce842a 100644 --- a/tests/consumer/tools/flutter/BUILD.bazel +++ b/tests/consumer/flutter/BUILD.bazel @@ -1,14 +1,14 @@ -# A colliding package -- this module has no reason to own `tools/flutter`, +# A colliding package -- this module has no reason to own `flutter`, # and that is the point. `select()` keys written as bare strings inside a # macro resolve in the *caller's* repo mapping, not the defining module's # (docs_internal/build-modes-plan.md P2). Every real select() in -# `@rules_flutter`'s macros uses `Label("//tools/flutter:mode_debug")` +# `@rules_flutter`'s macros use `Label("//flutter:mode_debug")` # precisely so this package is never consulted; its only job is to make a # regression to a bare `":mode_debug"` observable instead of silent. # # The trap: `mode_debug` here matches under this module's *default* test # invocation (`--compilation_mode=fastbuild`, unset by every target below), -# while the real `//tools/flutter:mode` defaults to "release". A bare-string +# while the real `//flutter:mode` defaults to "release". A bare-string # select() would therefore flip to the debug branch under an ordinary # release build -- dropping the `aot_library` contribution while # `flutter_bundle_check`'s own `_mode` (a rule attribute, resolved against diff --git a/tools/ci/assertions.bzl b/tools/ci/assertions.bzl new file mode 100644 index 0000000..011f94b --- /dev/null +++ b/tools/ci/assertions.bzl @@ -0,0 +1,11 @@ +"""Assertions for values a rule computes at loading time. + +A BUILD file cannot use `if`, and a bare `x == y or fail(...)` is an expression +statement buildifier rejects, so equality checks go through here. Maintainer +tooling only: nothing a Consumer Module loads reaches this file. +""" + +def expect_equal(actual, expected, what): + """Fails the load if `actual` differs from `expected`.""" + if actual != expected: + fail("{}: got {}, expected {}".format(what, actual, expected)) diff --git a/tools/flutter/BUILD.bazel b/tools/flutter/BUILD.bazel index ce17262..50dac4b 100644 --- a/tools/flutter/BUILD.bazel +++ b/tools/flutter/BUILD.bazel @@ -1,6 +1,3 @@ -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") -load(":abis.bzl", "MODES") - package(default_visibility = ["//visibility:public"]) exports_files([ @@ -16,23 +13,6 @@ exports_files([ "ndk.bzl", ]) -# Flutter runtime mode, independent of --compilation_mode. -string_flag( - name = "mode", - build_setting_default = "release", - values = MODES, -) - -config_setting( - name = "mode_debug", - flag_values = {":mode": "debug"}, -) - -config_setting( - name = "mode_release", - flag_values = {":mode": "release"}, -) - # Excluded from wildcard checks because resolving it requires @androidsdk. alias( name = "_android_sdk_marker", diff --git a/tools/flutter/abis.bzl b/tools/flutter/abis.bzl index 86bd73f..c570b6e 100644 --- a/tools/flutter/abis.bzl +++ b/tools/flutter/abis.bzl @@ -267,7 +267,7 @@ def aot_target_compatible_with(): """ conditions = {"//conditions:default": [Label("@platforms//:incompatible")]} for mode in AOT_MODES: - conditions[Label("//tools/flutter:mode_" + mode)] = [] + conditions[Label("//flutter:mode_" + mode)] = [] return select(conditions) def aot_gen_snapshot(abi): @@ -285,7 +285,7 @@ def aot_gen_snapshot(abi): A select() value for a `gen_snapshot` attribute. """ conditions = { - Label("//tools/flutter:mode_" + mode): gen_snapshot_label(abi, mode) + Label("//flutter:mode_" + mode): gen_snapshot_label(abi, mode) for mode in AOT_MODES } conditions["//conditions:default"] = gen_snapshot_label(abi, AOT_MODES[0]) diff --git a/tools/flutter/android.bzl b/tools/flutter/android.bzl index 24d6779..8faf66a 100644 --- a/tools/flutter/android.bzl +++ b/tools/flutter/android.bzl @@ -44,8 +44,8 @@ load(":bundle.bzl", "ASSETS", "CLASSES", "FlutterBundleContributionInfo", "NATIV load(":embedding.bzl", "flutter_embedding_deps") load(":pubspec.bzl", "FlutterPubspecInfo") -_MODE_DEBUG = Label("//tools/flutter:mode_debug") -_MODE_RELEASE = Label("//tools/flutter:mode_release") +_MODE_DEBUG = Label("//flutter:mode_debug") +_MODE_RELEASE = Label("//flutter:mode_release") def _jni_lib_jar_impl(ctx): jar = ctx.actions.declare_file(ctx.label.name + ".jar") @@ -564,7 +564,7 @@ def _flutter_bundle_check_impl(ctx): # Pin release builds to `opt`; preserve explicitly non-fastbuild modes. def _pin_release_compilation_mode_impl(settings, _attr): - mode = settings["//tools/flutter:mode"] + mode = settings["//flutter:mode"] compilation_mode = str(settings["//command_line_option:compilation_mode"]) if mode == "release" and compilation_mode == "fastbuild": compilation_mode = "opt" @@ -573,7 +573,7 @@ def _pin_release_compilation_mode_impl(settings, _attr): _pin_release_compilation_mode = transition( implementation = _pin_release_compilation_mode_impl, inputs = [ - "//tools/flutter:mode", + "//flutter:mode", "//command_line_option:compilation_mode", ], outputs = ["//command_line_option:compilation_mode"], @@ -627,7 +627,7 @@ APK does not package.""", allow_single_file = True, ), "_mode": attr.label( - default = "//tools/flutter:mode", + default = "//flutter:mode", providers = [BuildSettingInfo], ), }, diff --git a/tools/flutter/defs.bzl b/tools/flutter/defs.bzl index ad0bb0e..8f66b62 100644 --- a/tools/flutter/defs.bzl +++ b/tools/flutter/defs.bzl @@ -361,9 +361,9 @@ half of the input set that is not declared file-by-file.""", allow_files = True, ), "_mode": attr.label( - default = "//tools/flutter:mode", + default = "//flutter:mode", providers = [BuildSettingInfo], - doc = """Build mode, read from //tools/flutter:mode. Governs both + doc = """Build mode, read from //flutter:mode. Governs both compiler flags and cache policy. Release output is stripped of absolute paths by gen_snapshot, so it is safe to @@ -442,7 +442,7 @@ dart_aot_elf = rule( executable = True, cfg = "exec", allow_single_file = True, - doc = "The ABI's gen_snapshot; see //tools/flutter:abis.bzl.", + doc = "The ABI's gen_snapshot from the ABI table.", ), "snapshot_flags": attr.string_list( doc = """Extra gen_snapshot flags for this ABI. @@ -459,7 +459,7 @@ def flutter_aot_library(name, srcs, abis, pubspec, entrypoint, package_config, p Produces an AOT-shaped `.dill` and its `libapp.so` per ABI. `dart_kernel`'s `--aot`/`--tfa` branch is what gen_snapshot needs; it is selected by the - ambient `//tools/flutter:mode`, not pinned here. Under `mode=debug` this + ambient `//flutter:mode`, not pinned here. Under `mode=debug` this target's kernel compiles without them, so each `dart_aot_elf` here is `target_compatible_with` only the modes `AOT_MODES` lists -- an explicit debug build, or a `//...` sweep under debug, reports incompatibility @@ -608,7 +608,7 @@ def flutter_app( | `:guards_test` | the guards, under `bazel test` | `:app_` and `:assets` compile to their debug shape under - `--@rules_flutter//tools/flutter:mode=debug`; see + `--@rules_flutter//flutter:mode=debug`; see docs_internal/build-modes-plan.md. The names are fixed rather than derived from a `name` parameter: the Android @@ -977,7 +977,7 @@ bundle that started varying by architecture fails here rather than shipping.""", allow_single_file = True, ), "_mode": attr.label( - default = "//tools/flutter:mode", + default = "//flutter:mode", providers = [BuildSettingInfo], doc = "See dart_kernel._mode. Debug bundles ship kernel_blob.bin.", ), diff --git a/tools/flutter/embedding.bzl b/tools/flutter/embedding.bzl index 706d1f5..3db2d1e 100644 --- a/tools/flutter/embedding.bzl +++ b/tools/flutter/embedding.bzl @@ -23,8 +23,8 @@ load("@rules_java//java:defs.bzl", "java_import") load(":abis.bzl", "embedding_repo") load(":maven.bzl", "maven_label") -_MODE_DEBUG = Label("//tools/flutter:mode_debug") -_MODE_RELEASE = Label("//tools/flutter:mode_release") +_MODE_DEBUG = Label("//flutter:mode_debug") +_MODE_RELEASE = Label("//flutter:mode_release") FLUTTER_EMBEDDING_ARTIFACTS = [ "androidx.lifecycle:lifecycle-common:2.7.0", diff --git a/tools/flutter/ndk.bzl b/tools/flutter/ndk.bzl index d29d3fe..4ae88a8 100644 --- a/tools/flutter/ndk.bzl +++ b/tools/flutter/ndk.bzl @@ -10,7 +10,7 @@ load("@rules_android_ndk//:rules.bzl", "android_ndk_repository") _MIN_NDK_MAJOR = 28 -_CMAKE_STUB_BUILD = """# Generated by //tools/flutter:ndk.bzl -- do not edit. +_CMAKE_STUB_BUILD = """# Generated by //flutter:extensions.bzl -- do not edit. package(default_visibility = ["//visibility:public"]) genrule( diff --git a/tools/flutter/plugins.bzl b/tools/flutter/plugins.bzl index dd1921e..1add648 100644 --- a/tools/flutter/plugins.bzl +++ b/tools/flutter/plugins.bzl @@ -52,7 +52,7 @@ _DEP_CONFIGURATIONS = [ "runtimeOnly", ] -_BUILD_LOADS = """# Generated by //tools/flutter:plugins.bzl -- do not edit. +_BUILD_LOADS = """# Generated by //flutter:extensions.bzl -- do not edit. load("@rules_android//rules:rules.bzl", "android_library") """ @@ -240,7 +240,7 @@ load(":package_info.bzl", "PACKAGE_INFO") ) """ -_PACKAGE_INFO_TEMPLATE = '''# Generated by //tools/flutter:plugins.bzl -- do not edit. +_PACKAGE_INFO_TEMPLATE = '''# Generated by //flutter:extensions.bzl -- do not edit. # # Everything the standard generator knows about {name}, handed to its recipe. # Paths are relative to this package. Sources are enumerated rather than left to @@ -325,7 +325,7 @@ java_library( ) """ -_MODULE_SEGMENT_HEADER = """# Generated by @rules_flutter//tools/flutter:plugins.bzl -- do not edit by hand. +_MODULE_SEGMENT_HEADER = """# Generated by @rules_flutter//flutter:extensions.bzl -- do not edit by hand. # # Maven artifacts from the Flutter embedding and plugin build files. # Run the generated updater target when `pub_plugins_check` reports drift. @@ -594,7 +594,7 @@ def _extract_dependencies(build_gradle_text): return coordinates, reasons _DART_REGISTRANT_TEMPLATE = """// -// Generated by //tools/flutter:plugins.bzl -- do not edit. +// Generated by //flutter:extensions.bzl -- do not edit. // // The Dart half of plugin registration. GeneratedPluginRegistrant.java // instantiates each plugin's *native* class; a federated plugin also ships a @@ -1448,11 +1448,11 @@ flutter_plugins = repository_rule( mandatory = True, ), "android_bzl": attr.string( - doc = "Label of //tools/flutter:android.bzl, for android_native_lib_jar.", + doc = "Label of //flutter:defs.bzl, for android_native_lib_jar.", mandatory = True, ), "recipe_bzl": attr.string( - doc = "Label of //tools/flutter:recipe.bzl, for flutter_native_libs.", + doc = "Label of //flutter:defs.bzl, for flutter_native_libs.", mandatory = True, ), "ndk_source_properties": attr.string( @@ -1620,10 +1620,10 @@ Supplied by the consuming project because the target must live there: its deps are Maven artifacts resolved from that project's own coordinate list, and a label naming them from inside these rules would resolve against these rules' dependencies instead. Instantiate it with -`//tools/flutter:embedding.bzl%flutter_embedding_library` and pass the result +`//flutter:defs.bzl%flutter_embedding_library` and pass the result here. The default is the bare release engine jar, which compiles but leaves plugins without androidx.annotation -- enough to fail loudly rather than -silently. Module extension tags cannot read `//tools/flutter:mode`, so this +silently. Module extension tags cannot read `//flutter:mode`, so this default cannot itself vary by mode; a debug build supplies its own `flutter_embedding_library()` result here regardless.""", ), @@ -1715,8 +1715,8 @@ def _flutter_plugins_ext_impl(ctx): recipes = recipes, # Labels resolve in the Consumer Module before generation. embedding = str(project.embedding), - android_bzl = str(Label("//tools/flutter:android.bzl")), - recipe_bzl = str(Label("//tools/flutter:recipe.bzl")), + android_bzl = str(Label("//flutter:defs.bzl")), + recipe_bzl = str(Label("//flutter:defs.bzl")), ndk_source_properties = str(Label("@androidndk_cmake//:ndk_source_properties")), )