irondash / cargokit

Integrate cargo build with flutter plugins and applications.
Other
51 stars 16 forks source link

Add config option to disable certain target architectures #50

Open AlienKevin opened 6 months ago

AlienKevin commented 6 months ago

Currently, cargokit always builds for all supported architectures. For example, there are 3 targets for iOS and 4 targets for Android.

However, many devs test primarily on one device during development and only need to build for all architectures during release. This means that a lot of build time is wasted on architectures that the devs don't need, slowing down the development cycle.

It'd be great if devs can whitelist/blacklist target architectures in dev mode to cut down unnecessary build time.

knopp commented 6 months ago

On iOS this is controlled by XCode build. For example during debug on XCode the "Build Active Architecture Only" option is usually set, in which case cargokit should only build one architecture.

On android the target platforms being build are obtained from flutter plugin. I'm not sure if there is a way to adjust that.

Vedsaga commented 5 months ago

So, it is possible to disable certain arch in flutter android,

android {
   ...
   defaultConfig {
       ...  
       ndk {
          abiFilters "armeabi-v7a", "arm64-v8a"
       }
   }
}

https://stackoverflow.com/questions/42984644/how-to-specify-supported-architectures-for-android-app-in-build-gradle

cc: @knopp

AlienKevin commented 1 month ago

You can also skip the steps for building extra android architectures by updating cargokit/gradle/plugin.gradle. The following example shows how to only compile for arm64:

            ... 
            def platforms = plugin.getTargetPlatforms().collect()

            // Only compile for arm64 on Android
            platforms = platforms.findAll { it == "android-arm64" }

            // Comment out the following lines which add intel targets in debug mode
            // Same thing addFlutterDependencies does in flutter.gradle
            // if (buildType == "debug") {
            //     platforms.add("android-x86")
            //     platforms.add("android-x64")
            // }