I was able to use a task:Exec in order to execute our Intel Fortran compiler to build a single source program.
I’m trying to force the linkage task to depend on the exec task doing the compilation since there is no fortran support.
Any insights from gradle/groovy experts much appreciated.
// build.gradle
apply plugin: 'c'
def compileFortran(name) {
println '## compileFortran'
task("$name", type:Exec) {
println "## compile $name"
executable "sh"
args "-c", "ifort -i2 --c -o obj/${name}.o ${name}.f -I/usr/local/include -I/usr/include"
}
}
def statLib(libpath) {
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("$libpath")
}
}
model {
task compileFort {
compileFortran("bank002")
compileFortran("dummy")
//compileScreen("bksc002")
dependsOn("bank002")
dependsOn("dummy")
dependsOn("bksc002")
}
//linkBank002Executable {
// println '### linkBank002Executable'
//}
repositories {
lib(PrebuiltLibraries) {
libNEWCore { statLib("/work/build_new/lib/libNEWCore.a") }
libDISC2 { statLib("/work/build_new/lib/libDISC2.a") }
libDISC_dbg { statLib("/work/build_new/lib/libDISC_dbg.a") }
libisam { statLib("/usr/lib/libisam.a") }
libc { statLib("/lib/libc.a") }
libm { statLib("/lib/libm.a") }
}
}
components {
bank002(NativeExecutableSpec) {
sources {
c {
builtBy tasks.compileFort
//source {
// srcDir "."
// include "*.o"
//}
}
}
binaries.all {
tasks.assemble.dependsOn tasks.compileFort
lib library: 'libNEWCore', linkage: 'static'
lib library: 'libDISC2', linkage: 'static'
lib library: 'libDISC_dbg', linkage: 'static'
lib library: 'libisam', linkage: 'static'
lib library: 'libc', linkage: 'static'
lib library: 'libm', linkage: 'static'
}
}
}
}