mozilla / rust-android-gradle

Apache License 2.0
1.03k stars 67 forks source link

Configure Gradle task dependencies to be architecture-specific #112

Open AquilesCanta opened 1 year ago

AquilesCanta commented 1 year ago

I'm building a library which I'd like to make available on every possible platform: arm, arm64, x86, x86_64. However, during development I usually care about a single one. But gradle compiles everything, which takes some extra time.

One option is to manually disable the archs which I don't care about. I can do that by commenting out the undesired archs. Like so:

    targets = [
    //        "arm",
            "arm64",
    //        "x86",
    //        "x86_64"
    ]

But that's inconvenient because (1) the gradle file is checked into the version control system and (2) I need to remember to change this if I change de development device (e.g. I transition from a physical device to an emulator).

I'm wondering if there's a recommended way during development to tell gradle to only compile the right arch for the device we are targeting when we launch the app using the "run" button. I think Android Studio handles this gracefully for regular JNI/C++ code using CMake in Android Studio.

ncalexan commented 1 year ago

We've not built anything out of the box. Set up your Gradle dependencies differently to have the per-arch build jobs depend on the per-arch cargo tasks like cargoBuild${ARCH}. See #68 and similar tickets.

Alternatively, use local.properties to configure your local environment using targets.

I'll keep this open to track doing better automatically, 'cuz it is possible -- just not easy right now.

MatrixDev commented 1 year ago

@ncalexan, it should be relatively easy to jsut handle "android.injected.build.abi" property and just filter out targets