How to make Gradle choose a different version of C compiler?

Hi Ganesh,

You are right, there was some information missing. Here is the complete code for this:

apply plugin: 'c'

model {
  platforms {
    mySparc {
      architecture "sparc"
    }
  }
  toolChains {
    gcc(Gcc) {
      path "/opt/rtems/version_number/bin"
      target("mySparc") {
        cCompiler.executable = "sparc-rtems-gcc"
      }
    }
  }
  components {
    main(NativeLibrarySpec) {
      targetPlatform "mySparc"
    }
  }
}

Notice the targetPlatform for the component which is noted here in the user guide. Also, notice the change from eachPlatform to target for the GCC toolchain. The eachPlatform configuration will configure only the supported platform as specified here. Instead, we specify a new supported platform for the toolchain as well as configuring that new one. You can find more information about this here in the user guide.

Thanks,

Daniel

1 Like