gradle-native icon indicating copy to clipboard operation
gradle-native copied to clipboard

InstallExecutable puts readonly dependent libraries in target directory, consecutive builds fails when target is out of date

Open enaess opened this issue 4 years ago • 0 comments

Expected Behavior

Incremental builds should complete

Current Behavior

Consecutive build operations fails saying that one of my dependent libraries that was read-only (.so file checked out as read-only from Perforce).

Context

Slows me down, I have to continuously add "clean" target for every run of my target

Steps to Reproduce (for bugs)

  • You apply the 'cpp-unit-test' plugin to a project that implements a library 'cpp-library'
  • Add a few dependencies on other projects that offers a configuration / pre-built library, e.g. libgmock.so
  • ./gradlew build
  • Make some changes to your test/main.cpp or whatever file to make CompileTestCpp out of date
  • ./gradlew build

The following code could benefit from adding a 755 file modification on Unix platforms. https://github.com/gradle/gradle/blob/4e8aa8adfaffe18bdf7b4583d4b7e920e4ecbfae/subprojects/platform-native/src/main/java/org/gradle/nativeplatform/tasks/InstallExecutable.java#L260-L265

I've worked around the problem as follows:

    // Fixing a bug where libraries are copied into target directory with read-only permission
    tasks.withType(InstallExecutable).configureEach {
        doFirst {
            File d = it.getInstallDirectory().getLocationOnly().map(dir -> dir.dir("lib")).get().getAsFile()
            it.libs.each { lib ->
                File f = new File(d, lib.name)
                if (f.exists()) {
                    f.writable = true
                }
            }
        }
    }

enaess avatar May 28 '21 19:05 enaess