1. 10 Sep, 2023 1 commit
    • Daco Harkes's avatar
      Native assets support for MacOS and iOS (#130494) · aa36db1d
      Daco Harkes authored
      Support for FFI calls with `@Native external` functions through Native assets on MacOS and iOS. This enables bundling native code without any build-system boilerplate code.
      
      For more info see:
      
      * https://github.com/flutter/flutter/issues/129757
      
      ### Implementation details for MacOS and iOS.
      
      Dylibs are bundled by (1) making them fat binaries if multiple architectures are targeted, (2) code signing these, and (3) copying them to the frameworks folder. These steps are done manual rather than via CocoaPods. CocoaPods would have done the same steps, but (a) needs the dylibs to be there before the `xcodebuild` invocation (we could trick it, by having a minimal dylib in the place and replace it during the build process, that works), and (b) can't deal with having no dylibs to be bundled (we'd have to bundle a dummy dylib or include some dummy C code in the build file).
      
      The dylibs are build as a new target inside flutter assemble, as that is the moment we know what build-mode and architecture to target.
      
      The mapping from asset id to dylib-path is passed in to every kernel compilation path. The interesting case is hot-restart where the initial kernel file is compiled by the "inner" flutter assemble, while after hot restart the "outer" flutter run compiled kernel file is pushed to the device. Both kernel files need to contain the mapping. The "inner" flutter assemble gets its mapping from the NativeAssets target which builds the native assets. The "outer" flutter run get its mapping from a dry-run invocation. Since this hot restart can be used for multiple target devices (`flutter run -d all`) it contains the mapping for all known targets.
      
      ### Example vs template
      
      The PR includes a new template that uses the new native assets in a package and has an app importing that. Separate discussion in: https://github.com/flutter/flutter/issues/131209.
      
      ### Tests
      
      This PR adds new tests to cover the various use cases.
      
      * dev/devicelab/bin/tasks/native_assets_ios.dart
        * Runs an example app with native assets in all build modes, doing hot reload and hot restart in debug mode.
      * dev/devicelab/bin/tasks/native_assets_ios_simulator.dart
        * Runs an example app with native assets, doing hot reload and hot restart.
      * packages/flutter_tools/test/integration.shard/native_assets_test.dart
        * Runs (incl hot reload/hot restart), builds, builds frameworks for iOS, MacOS and flutter-tester.
      * packages/flutter_tools/test/general.shard/build_system/targets/native_assets_test.dart
        * Unit tests the new Target in the backend.
      * packages/flutter_tools/test/general.shard/ios/native_assets_test.dart
      * packages/flutter_tools/test/general.shard/macos/native_assets_test.dart
        * Unit tests the native assets being packaged on a iOS/MacOS build.
      
      It also extends various existing tests:
      
      * dev/devicelab/bin/tasks/module_test_ios.dart
         * Exercises the add2app scenario.
      * packages/flutter_tools/test/general.shard/features_test.dart
         * Unit test the new feature flag.
      Unverified
      aa36db1d
  2. 23 May, 2023 1 commit
    • Ian Hickson's avatar
      Give channel descriptions in `flutter channel`, use branch instead of upstream... · 9c7a9e77
      Ian Hickson authored
      Give channel descriptions in `flutter channel`, use branch instead of upstream for channel name (#126936)
      
      ## How we determine the channel name
      
      Historically, we used the current branch's upstream to figure out the current channel name. I have no idea why. I traced it back to https://github.com/flutter/flutter/pull/446/files where @abarth implement this and I reviewed that PR and left no comment on it at the time.
      
      I think this is confusing. You can be on a branch and it tells you that your channel is different. That seems weird.
      
      This PR changes the logic to uses the current branch as the channel name.
      
      ## How we display channels
      
      The main reason this PR exists is to add channel descriptions to the `flutter channel` list:
      
      ```
      ianh@burmese:~/dev/flutter/packages/flutter_tools$ flutter channel
      Flutter channels:
        master (tip of tree, for contributors)
        main (tip of tree, follows master channel)
        beta (updated monthly, recommended for experienced users)
        stable (updated quarterly, for new users and for production app releases)
      * foo_bar
      
      Currently not on an official channel.
      ianh@burmese:~/dev/flutter/packages/flutter_tools$
      ```
      
      ## Other changes
      
      I made a few other changes while I was at it:
      
      * If you're not on an official channel, we used to imply `--show-all`, but now we don't, we just show the official channels plus yours. This avoids flooding the screen in the case the user is on a weird channel and just wants to know what channel they're on.
      * I made the tool more consistent about how it handles unofficial branches. Now it's always `[user branch]`.
      * I slightly adjusted how unknown versions are rendered so it's clearer the version is unknown rather than just having the word "Unknown" floating in the output without context.
      * Simplified some of the code.
      * Made some of the tests more strict (checking all output rather than just some aspects of it).
      * Changed the MockFlutterVersion to implement the FlutterVersion API more strictly.
      * I made sure we escape the output to `.metadata` to avoid potential injection bugs (previously we just inlined the version and channel name verbatim with no escaping, which is super sketchy).
      * Tweaked the help text for the `downgrade` command to be clearer.
      * Removed some misleading text in some error messages.
      * Made the `.metadata` generator consistent with the template file.
      * Removed some obsolete code to do with the `dev` branch.
      
      ## Reviewer notes
      
      I'm worried that there are implications to some of these changes that I am not aware of, so please don't assume I know what I'm doing when reviewing this code. :-)
      Unverified
      9c7a9e77
  3. 14 Apr, 2023 1 commit
  4. 23 Feb, 2023 1 commit
  5. 23 Jan, 2023 1 commit
  6. 31 Aug, 2022 1 commit
  7. 18 May, 2022 1 commit
  8. 16 Mar, 2022 1 commit
  9. 26 Jan, 2022 1 commit
  10. 04 Jan, 2022 2 commits
  11. 28 Jun, 2021 1 commit
  12. 24 Mar, 2021 1 commit
  13. 25 Feb, 2021 1 commit
  14. 27 Jan, 2021 1 commit
  15. 15 Oct, 2020 1 commit
  16. 27 Mar, 2020 1 commit