gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
93 stars 8 forks source link

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

Open enaess opened 3 years ago

enaess commented 3 years ago

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)

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
                }
            }
        }
    }