Hello,
I have a build script that looks something like this:
someComponent(NativeLibrarySpec){
sources {
c {
source {
lib library: "some_lib", linkage: 'api'
lib project: ":some_project", library: "some_lib", linkage: 'api'
srcDirs "a_source_dir"
include "*.c"
}
}
}
}
aLib(NativeLibrarySpec){
sources {
c {
source {
lib library: "some_lib", linkage: 'api'
lib project: ":some_project", library: "some_lib", linkage: 'api'
srcDirs "a_source_dir"
include "*.c"
}
}
}
}
someComponent(NativeLibrarySpec){
sources {
c {
source {
lib library: "some_lib", linkage: 'api'
lib project: ":some_project", library: "some_lib", linkage: 'api'
srcDirs "a_source_dir"
include "*.c"
}
}
}
}
someComponent(NativeExecutableSpec){
sources {
c {
source {
lib library: "some_lib", linkage: 'api'
lib project: ":some_project", library: "some_lib", linkage: 'api'
srcDirs "a_source_dir"
include "*.c"
}
}
}Usually there are some compiler.args & linker.args here. Even after this I need to execute additional linking.
}
tasks.linkanExecutableIGenerate {
doLast {
ext {
ObjectFolder = Paths.get(workspace_path.getAbsolutePath(), "someFolder").getAbsolutePath()
//Object paths used in linking
objectOutputPath = project.buildDir.getAbsolutePath() + "/objs/"
componentObjectOutputPath = project.buildDir.getAbsolutePath() + "/objs/componentObject/"
//Find dependencies for componentObject.o
txtFiles = new FileNameFinder().getFileNames(cLibCObjectFolder, '**/lib_crc.o' /* includes */)
libCrcObjectFile = txtFiles.first().toString().replace("\\","/")
//Find dependencies for auxiliaryAirflow.o
txtFiles = new FileNameFinder().getFileNames(ObjectFolder , '**/dependency.o' /* includes */)
ObjectFile = txtFiles.first().toString().replace("\\","/")
}
//generate a .o
exec {
commandLine ld, "-some_flag",
libCrcObjectFile,
"-o", objectOutputPath + "cLib.o"
}
//generate another.o
exec {
commandLine ld, "-X", "-r",
finder.getFileNames(ObjectFolder, '**/someDependency.o').first(),
finder.getFileNames(ObjectFolder, '**/someDependency.o').first(),
finder.getFileNames(ObjectFolder, '**/someDependency.o').first(),
finder.getFileNames(ObjectFolder, '**/someDependency.o').first(),
"-o", objectOutputPath + "theObjectFile.o"
}
}
}
- Is there a property, spec, function that I can use to access the object file built when I create a library or executable? So that I can perhaps copy the files into another folder?
2)Finding the object files requires steps like finder.getFileNames(ObjectFolder, ‘**/someDependency.o’).first(), is there a better way of doing this? Can I pass a collection to the command line as arguments?
Best Regards,
Jonathan