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

flutter build apk ignores --target-platform if --debug is set #413

Open
thgoebel opened this issue Aug 26, 2024 · 2 comments
Open

flutter build apk ignores --target-platform if --debug is set #413

thgoebel opened this issue Aug 26, 2024 · 2 comments

Comments

@thgoebel
Copy link

Report

rinf always compiles for x86_64 and x86_32 when --debug is passed. Flutter's --target-platform flag is ignoed.

Steps to Reproduce

  1. flutter create testproject
  2. cd testproject
  3. Add rinf to it (details omitted)
  4. flutter build apk --target-platform=android-arm64 --debug

Expected results

The resulting app-debug.apk only contains code for android-arm64.

Actual results

The resulting app-debug.apk contains code for android-arm, android-arm64, android-x86, android-x64.

When running without --debug, i.e. flutter build apk --target-platform=android-arm64 then the resulting app-release.apk correctly contains only code for android-arm64.

Why this is relevant

(Re)compiling Rust code for 4 target archs takes a loooong time (e.g. after a flutter clean). But I only need and only want to compile for one arch, because I am working on a physical test device. I expect --target-platform to work with --debug.

I see that by default one may want to include x86_64 and x86_32 for debug builds. But if I explicitly set --target-platform, I want this choice to be respected, and not have flutter and/or rinf trying to be clever and build for two additional platforms.

Context

I also filed a bug against this with Flutter: flutter/flutter#153359

Flutter implements this "default x86 behaviour" here: https://github.com/flutter/flutter/blob/6608936e6d430926eddc5759e2c4ca07dc873b03/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy#L642

Nevertheless, this still needs to be tracked for rinf separately. Because rinf does the same thing as Flutter:

// Same thing addFlutterDependencies does in flutter.gradle
. So both Flutter and rinf would need to implement logic to respect --target-platform.

System Information

$ rustc --version
rustc 1.82.0-nightly (91376f416 2024-08-12)

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.5 23F79 darwin-arm64, locale en-CH)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.92.0)
[✓] Connected device (3 available)
[✓] Network resources

! Doctor found issues in 1 category
@temeddix
Copy link
Member

Thanks for reporting, I'll be investigating this issue as soon as I can. Meanwhile, we are open to PRs :)

@temeddix
Copy link
Member

temeddix commented Sep 17, 2024

I think we need to communicate with cargokit, because Rinf is basically using Cargokit under the hood. /flutter_package/cargokit is a Git subtree directory pulled from Cargokit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@thgoebel @temeddix and others