Building for MIPS architecture

For native builds Gradle 2.0 cpp plugin supports multiple architectures (x84, x86_64, ARM, Sparc, etc.), which is great. In my projects I have to do builds for different MIPS variants (little endian, small endian, etc.) using different GCC-based toolchains. The first roadblock seems to be that none of the MIPS architectures are defined in Gradle. Is there a way to extend the list of supported platforms without actually modifying cpp plugin? I did see some examples of people defining their own platforms and architectures, but those no longer work.

Another question is about GCC-based toolchains. For each architecture targeting different flavors of platforms we have different toolchains. They are all based on GCC and all platforms in one way or the other are Linux’es. I guess the idea would be to define a separate platform and then set-up the toolchain for each.

The goal is to actually have a build with such targets:

  • ARM

– ARM Platform GCC Toolchain 1

– ARM Platform GCC Toolchain 2

  • MIPS

– MIPS Platform GCC Toolchain 1

– MIPS Platform GCC Toolchain 2

Is anything like this possible? It would be great to see some examples.

You can simply define a number of ‘platforms’, and configure your ToolChain instances to target these named platforms, without regard to the Architecture/OperatingSystem.

Take a look at the ‘native-binaries/target-platforms’ sample in a recent nightly build (not sure if this sample was done in time for Gradle 2.0).

In Gradle 2.0, it should look something like this:

model {
  platforms {
    arm1 { architecture "arm" }
    arm2 { architecture "arm" }
    mips1
    mips2
  }
  toolChains {
    gcc1(Gcc) {
      path "/path/to/gcc"
      target("arm1") // Gradle will set compiler flags based on architecture
      target("mips1") { // You need to tell Gradle any args for this platform
        cppCompiler.withArguments { args ->
          args << "-march" << "arm"
         }
      }
    }
    gcc2(Gcc) {
        path "/path/to/gcc2"
        target("arm2")
        target("mips2") { ... }
    }
  }
}

Awesome! This is exactly what I needed