Native project additional file resources


(Adrian Lis) #1

Hi,
I have quite complex project setup. There are libraries that are built from the sources, executables that depend upon those libraries as well as prebuilt native libraries used by some of the executables. Some of the prebuilt libraries require additonal resource files to operate. I would like to add custom logic for install task to copy over the resources where the are needed.

Ideally I would like to copy over the files for Install task on Executable that has dependency on a particular prebuilt Shared library but anything that would work somewhat is better then what I currently have.

The code I tried so far looks like this:

model {
    binaries {
    withType(NativeExecutableBinarySpec) { bin ->
      bin.tasks.withType(InstallExecutable) { installTask ->  
        def arch = bin.targetPlatform.name
        def buildType = bin.buildType.name
        installTask.dependsOn {
          // print("It runs the closure")
          outputs.upToDateWhen { 
            // print("It gets called")
            false // I tried return false too
          }
          return task('copyCefRuntimeFiles', type:Copy) {
            // print("It also runs this")
            from('dependencies/cef/lib/${arch}/${buildType}') {
              include '*.bin'
              include 'd3dcompiler_43.dll'
              include 'd3dcompiler_47.dll'
              include 'widevinecdmadapter.dll'
            }                
            from 'dependencies/cef/resources'
            into '${installTask.destinationDir}/lib'
          }
        }   
      }   
    }
  }
}

This solution has two major problems. First one it worked once and since then when I run gradle install task on executable it says that the task is UP-TO-DATE even the files are not there even after clean. Second problem is that it tries to copy over the files to every executable built not to those that depend on Prebuilt Shared library (can it by somehow filter out on the name of the prebuilt library?)

Thanks for any hints in advance