Prebuilt LIbraries: Two things I would find useful

software-model

(Schalk Cronjé) #1

Continuing the discussion from [CPP] Conditional Linking and Excluding:

There’s two things related to prebuild libraries that I noticed through forum discussions and my own experience that people would find useful.

[1] Specifying system libraries

binaries.all {
  systemlib lib : 'z'  linkage : 'static'
}    

Then let Gradle figure out how to add the appropriate linker flags.

[2] GeneratedBy equivalent

Related to: Please clarify: "A library component that is not built by gradle."

This is the case where a library is not built by native means, but still needs to be unpacked by Gradle (or maybe built via external means i.e. make or scons). IN this case having the equivalanet of generatedBy which is in souce sets will be useful.

repositories {
  libs {
    boost {
      generatedBy ':other-project:unpackTaskName'
    }

Now Gradle should know that before any native compoenent specifying boost as library is executed it know sit has to run :other-project:unpackTaskName first.

Maybe you Gradle devs are already working on this, but I thought I would mention them anyway,


(Schalk Cronjé) #2

I want to add a third useful thing. Now I don;t know if this is arleady supported by currently I have to do

libs(PrebuiltLibraries) {
    pace {
        headers.srcDir '/dir/where/includes/are'
        binaries.withType(PrebuiltStaticLibraryBinary) {
            staticLibraryFile = file("${someLibDir}/libmyarchive.a")
        }
    }
}

This means I have to prefix ’lib and postfix .a. I would prefer to have it more platform independent i.e.

libs(PrebuiltLibraries) {
    pace {
        headers.srcDir '/dir/where/includes/are'
        binaries.withType(PrebuiltStaticLibraryBinary) {
            staticLibraryFile  dir : file('/where/the/lib/is'), lib : 'myarchive'
        }
    }
}

In this way I can let Gradle do the work for me.