Gradle 1.12 fails to compile native library correctly when it is included as a subproject

Hi,

let me explain my problem:

I have a multimodule setup, for java, it works fine. However, I got one native dependency that I compile. There’s a custom gradle file for it and it works fine when I call the buildLibrary task in standalone mode.

However, when I include it as a subproject, it does not work anymore. Instead of using my custom toolchain, it uses the Visual Studio toolchain. What do I have to do to get the toolchain properly working in a submodule? It seems like Gradle ignores my platform config.

I need this toolchain as I am crosscompiling for ARM.

Here’s the gradle for the subproject:

apply plugin: 'c'
  model {
    toolChains {
     gcc(Gcc) {
               path "../toolchains/Sourcery/bin"
               cCompiler.executable = 'arm-none-linux-gnueabi-gcc.exe'
               cppCompiler.executable = 'arm-none-linux-gnueabi-g++.exe'
               linker.executable = 'arm-none-linux-gnueabi-ld.exe'
               assembler.executable = 'arm-none-linux-gnueabi-as.exe'
               staticLibArchiver.executable = 'arm-none-linux-gnueabi-ar.exe'
           addPlatformConfiguration(new ArmArchitecture())
         }
    }
          platforms {
        arm {
            architecture "arm"
            operatingSystem "linux"
        }
    }
}
  sources {
    myLib {
        c {
            source {
                srcDir "./src/main/c"
                include "**/*.c"
            }
                  }
    }
   }
  libraries() {
 bulldog() {
  baseName "mylib"
  targetPlatform = "arm"
 }
 }
      class ArmArchitecture implements TargetPlatformConfiguration {
   def compilerArgs =
["-std=gnu11", "-O3", "-fPIC", "-fgnu89-inline"]
 def linkerArgs =
["--gc-sections", "-shared"]
      boolean supportsPlatform(Platform element) {
     return true
    }
      List<String> getCppCompilerArgs() {
       compilerArgs
    }
      List<String> getCCompilerArgs() {
       compilerArgs
    }
      List<String> getObjectiveCCompilerArgs() {
        []
    }
      List<String> getObjectiveCppCompilerArgs() {
        []
    }
      List<String> getAssemblerArgs() {
        []
    }
      List<String> getLinkerArgs() {
       linkerArgs
    }
      List<String> getStaticLibraryArchiverArgs() {
        []
    }
}

And this is how I call it:

def javaProjects = [
     project(":core"),
      project(":api"),
        ]
  def nativeProjects = [
      project(":native")
      ]
  configure(nativeProjects) {
 project -> apply from: new File(project.projectDir, 'build.gradle')
}
        configure(javaProjects) {
         apply: 'java' //etc...etc...
}

I don’t even have Visual Studio in %PATH%!

Second thing I’d like to know is: This will always produce a .dll extension, but I want .so. Is this somehow configurable? I’ve spent the whole day trying to achieve this, but cannot even find the variable for the binaries directory of a native build :frowning:

This turned out to be a problem of the eclipse plugin and not of gradle itself. It built just fine from the commandline, but when I start the build via eclipse strange things happen.

Gradle works fine.

I’m trying to do something similar for an arm-linux chip. I keep getting an unable to resolve TargetPlatformConfiguration. Is this another custom class that you have written?