Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
enaess opened this issue May 28, 2021 · 0 comments

Comments

@enaess
Copy link

enaess commented May 28, 2021

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
                }
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant