Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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",
)
4 changes: 2 additions & 2 deletions MODULE.bazel.lock

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

15 changes: 7 additions & 8 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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"])

Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand All @@ -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"])
Expand Down Expand Up @@ -219,7 +218,7 @@ bazel test //:guards_test
Replace `<name>.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,
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"])

Expand Down
12 changes: 6 additions & 6 deletions examples/demo_app/MODULE.bazel.lock

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

9 changes: 4 additions & 5 deletions examples/demo_app/android/app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -34,15 +33,15 @@ 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
# snapshot, the engine, the runtime classes, the assets, the plugin libraries
# and their native halves, the recipe libraries, the registrant -- and then one
# APK per shape: :demo_app carries every ABI, :demo_app_<abi> 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
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_app/bazel/flutter/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_app/bazel/flutter/rive_native.bzl
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_app/bazel/flutter/sqlite3.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_app/lib/dart_plugin_registrant.dart
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_app/plugin_deps.MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
12 changes: 6 additions & 6 deletions examples/local_plugin/MODULE.bazel.lock

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

2 changes: 1 addition & 1 deletion examples/local_plugin/packages/host_app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"])

Expand Down
Original file line number Diff line number Diff line change
@@ -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"])
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/local_plugin/plugin_deps.MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/no_plugins/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"])

Expand Down
6 changes: 3 additions & 3 deletions examples/no_plugins/MODULE.bazel.lock

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

3 changes: 1 addition & 2 deletions examples/no_plugins/android/app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"])
Expand Down
2 changes: 1 addition & 1 deletion examples/pub_plugins/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"])

Expand Down
Loading
Loading