1. 11 Dec, 2023 13 commits
  2. 10 Dec, 2023 1 commit
  3. 09 Dec, 2023 6 commits
  4. 08 Dec, 2023 18 commits
  5. 07 Dec, 2023 2 commits
    • Andrew Kolos's avatar
      Support conditional bundling of assets based on `--flavor` (#132985) · 016eb851
      Andrew Kolos authored
      Provides support for conditional bundling of assets through the existing `--flavor` option for `flutter build` and `flutter run`. Closes https://github.com/flutter/flutter/issues/21682. Resolves https://github.com/flutter/flutter/issues/136092
      
      ## Change
      Within the `assets` section pubspec.yaml, the user can now specify one or more `flavors` that an asset belongs to. Consider this example:
      
      ```yaml
      # pubspec.yaml
      flutter:
        assets:
          - assets/normal-asset.png
          - path: assets/vanilla/ice-cream.png
            flavors: 
              - vanilla
          - path: assets/strawberry/ice-cream.png
            flavors:
              - strawberry
      ```
      
      With this pubspec,
      * `flutter run --flavor vanilla` will not include `assets/strawberry/ice-cream.png` in the build output.
      * `flutter run --flavor strawberry` will not include `assets/vanilla/ice-cream.png`.
      * `flutter run` will only include `assets/normal-asset.png`.
      
      ## Open questions
      
      * Should this be supported for all platforms, or should this change be limited to ones with documented `--flavor` support (Android, iOS, and (implicitly) MacOS)? This PR currently only enables this feature for officially supported platforms.
      
      ## Design thoughts, what this PR does not do, etc.
      
      ### This does not provide an automatic mapping/resolution of asset keys/paths to others based on flavor at runtime.
      
      The implementation in this PR represents a simplest approach. Notably, it does not give Flutter the ability to dynamically choose an asset based on flavor using a single asset key. For example, one can't use `Image.asset('config.json')` to dynamically choose between different "flavors" of `config.json` (such as `dev-flavor/config.json` or `prod-flavor/config.json`). However, a user could always implement such a mechanism in their project or in a library by examining the flavor at runtime.
      
      ### When multiple entries affect the same file and 1) at least one of these entries have a `flavors` list provided and 2) these lists are not equivalent, we always consider the manifest to be ambiguous and will throw a `ToolExit`. 
      
      <details>
      For example, these manifests would all be considered ambiguous:
      
      ```yaml
      assets:
        - assets/
        - path: assets/vanilla.png
          flavors: 
            - vanilla
      
      assets:
        - path: assets/vanilla/
          flavors: 
            - vanilla
        - path: assets/vanilla/cherry.png
           flavor:
            - cherry
      
      # Thinking towards the future where we might add glob/regex support and more conditions other than flavor:
      assets:
        - path: assets/vanilla/**
          flavors:
            - vanilla
        - path: assets/**/ios/**
          platforms: 
             - ios
      
      # Ambiguous in the case of assets like "assets/vanilla/ios/icon.svg" since we 
      # don't know if flavor `vanilla` and platform `ios` should be combined using or-logic or and-logic.
      ```
      
      See [this review comment thread](https://github.com/flutter/flutter/pull/132985#discussion_r1381909942) for the full story on how I arrived at this decision.
      </details>
      
      ### This does not support Android's multidimensional flavors feature (in an intuitive way)
      
      <details>
      
      Conder this excerpt from a Flutter project's android/app/build.gradle file:
      
      ```groovy
      android {
          // ...
      
          flavorDimensions "mode", "api"
      
          productFlavors {
              free {
                  dimension "mode"
                  applicationIdSuffix ".free"
              }
      
              premium {
                  dimension "mode"
                  applicationIdSuffix ".premium"
              }
      
              minApi23 {
                  dimension "api"
                  versionNameSuffix "-minApi23"
              }
      
              minApi21 {
                  dimension "api"
                  versionNameSuffix "-minApi21"
              }
          }
      }
      ```
      
      In this setup, the following values are valid `--flavor` are valid `freeMinApi21`, `freeMinApi23`, `premiumMinApi21`, and `premiumMinApi23`. We call these values "flavor combinations". Consider the following from the Android documentation[^1]:
      
      > In addition to the source set directories you can create for each individual product flavor and build variant, you can also create source set directories for each combination of product flavors. For example, you can create and add Java sources to the src/demoMinApi24/java/ directory, and Gradle uses those sources only when building a variant that combines those two product flavors.
      > 
      > Source sets you create for product flavor combinations have a higher priority than source sets that belong to each individual product flavor. To learn more about source sets and how Gradle merges resources, read the section about how to [create source sets](https://developer.android.com/build/build-variants#sourcesets).
      
      This feature will not behave in this way. If a user utilizes this feature and also Android's multidimensional flavors feature, they will have to list out all flavor combinations that contain the flavor they want to limit an asset to:
      
      ```yaml
      assets:
        - assets/free/
          flavors:
            - freeMinApi21
            - freeMinApi23
      ```
      
      This is mostly due to a technical limitation in the hot-reload feature of `flutter run`. During a hot reload, the tool will try to update the asset bundle on the device, but the tool does not know the flavors contained within the flavor combination (that the user passes to `--flavor`). Gradle is the source of truth of what flavors were involved in the build, and `flutter run` currently does not access to that information since it's an implementation detail of the build process. We could bubble up this information, but it would require a nontrivial amount of engineering work, and it's unclear how desired this functionality is. It might not be worth implementing.
      
      </details>
      
      See https://flutter.dev/go/flavor-specific-assets for the (outdated) design document. 
      
      <summary>Pre-launch Checklist</summary>
      
      </details>
      
      [^1]: https://developer.android.com/build/build-variants#flavor-dimensions
      016eb851
    • engine-flutter-autoroll's avatar
      Roll Flutter Engine from 82de3347ccd7 to 6d9b2fb17ad6 (16 revisions) (#139768) · 0dfb2c13
      engine-flutter-autoroll authored
      https://github.com/flutter/engine/compare/82de3347ccd7...6d9b2fb17ad6
      
      2023-12-07 jason-simmons@users.noreply.github.com Revert Dart SDK back to be8a95b6717d (flutter/engine#48799)
      2023-12-07 15619084+vashworth@users.noreply.github.com Retry when safaridriver fails (flutter/engine#48791)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from f49ec3e6c1b1 to b541f668f531 (2 revisions) (flutter/engine#48796)
      2023-12-07 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Update clang revision from 00396e6a1a0b7 to b3a9e8f7c0afb00." (flutter/engine#48802)
      2023-12-07 chinmaygarde@google.com Update clang revision from 00396e6a1a0b7 to b3a9e8f7c0afb00. (flutter/engine#48705)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from c68e050e9198 to f49ec3e6c1b1 (1 revision) (flutter/engine#48790)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from af998f66ae73 to c68e050e9198 (1 revision) (flutter/engine#48788)
      2023-12-07 jason-simmons@users.noreply.github.com Reland "Replace use of Fontmgr::RefDefault with explicit creation calls" (flutter/engine#48764)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from 308f3d9bef2c to af998f66ae73 (1 revision) (flutter/engine#48784)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from 2b33ff5642c3 to 308f3d9bef2c (1 revision) (flutter/engine#48777)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Dart SDK from 4b22e6430c20 to b6d5e010d2c5 (1 revision) (flutter/engine#48776)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from 0753f680c573 to 2b33ff5642c3 (1 revision) (flutter/engine#48772)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from 0f1822e9137a to 0753f680c573 (1 revision) (flutter/engine#48771)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from dbcf508d1dce to 0f1822e9137a (1 revision) (flutter/engine#48769)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Dart SDK from be8a95b6717d to 4b22e6430c20 (1 revision) (flutter/engine#48768)
      2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from 8ebf43ba1c09 to dbcf508d1dce (1 revision) (flutter/engine#48766)
      
      If this roll has caused a breakage, revert this CL and stop the roller
      using the controls here:
      https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
      Please CC chinmaygarde@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
      is aware of the problem.
      
      To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose
      
      To report a problem with the AutoRoller itself, please file a bug:
      https://issues.skia.org/issues/new?component=1389291&template=1850622
      
      Documentation for the AutoRoller is here:
      https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
      0dfb2c13