tomtzook / gradle-cmake

A Gradle integration plugin for CMake
6 stars 3 forks source link

No interruption of compilation in case of cmake execution errors #7

Closed keta1 closed 1 year ago

keta1 commented 1 year ago

https://github.com/tomtzook/gradle-cmake/blob/ad215d2b6b77c6fc94ca450cece720743e5b6157/plugin/src/main/java/com/github/tomtzook/gcmake/tasks/CmakeBuildTask.java#L76

maybe u shoule invkoe isIgnoreExitValue?

https://github.com/gradle/gradle/blob/master/subprojects/process-services/src/main/java/org/gradle/process/BaseExecSpec.java#L39

tomtzook commented 1 year ago

A bit surprised. Just checked again to make sure, and it does interrupt on error. Can you post the script you use and the output from gradle build task?

teble commented 1 year ago

Demo project: DexKit, Intentionally modify :dexkit module source code to make it non-compilable, use gradle :main:run get output:

image
tomtzook commented 1 year ago

Okay, seems that this behavior is caused by running the task via Android Studio. Add the following lines to dexkit/build.gradle:

tasks.clean.dependsOn tasks.cmakeClean
tasks.jar.dependsOn tasks.cmakeBuild

This seemed to solve the problem.

Basically, because of the dependency association on dexkit by main, there exists a dependency on :dexkit:jar. So this would add :dexkit:cmakeBuild to the dependency tree.

keta1 commented 1 year ago

Okay, seems that this behavior is caused by running the task via Android Studio. Add the following lines to dexkit/build.gradle:

tasks.clean.dependsOn tasks.cmakeClean
tasks.jar.dependsOn tasks.cmakeBuild

This seemed to solve the problem.

Basically, because of the dependency association on dexkit by main, there exists a dependency on :dexkit:jar. So this would add :dexkit:cmakeBuild to the dependency tree.

https://github.com/LuckyPray/DexKit/blob/6cded873a85fd37f165a0ddfcd0f6d9242b378d2/main/build.gradle#L45

tomtzook commented 1 year ago

I was referring to this file. Try adding the two lines in there

keta1 commented 1 year ago

I was referring to this file. Try adding the two lines in there

the relevant logic in this file :main:cmakeBuild dependsOn :dexkit:cmakeBuild :main:jar dependsOn :main:cmakeBuild

tomtzook commented 1 year ago

Very well. Instead add

tasks.run.dependsOn(tasks.cmakeBuild)

Below that line

keta1 commented 1 year ago

Very well. Instead add

tasks.run.dependsOn(tasks.cmakeBuild)

Below that line

Thank you, it did work as expected after this improvement. Although I still don't understand how it works, I'll check the gradle documentation to find out why

tomtzook commented 1 year ago

Although I still don't understand how it works, I'll check the gradle documentation to find out why

Well, if you run the task :main:run from the terminal, you'll see that it does terminate early. The behavior you saw seems to be only when running from Android Studio Configuration. At least as far as I saw. If that is indeed the case, it is likely that it's related to how Android Studio executes the tasks.

teble commented 1 year ago

Although I still don't understand how it works, I'll check the gradle documentation to find out why

Well, if you run the task :main:run from the terminal, you'll see that it does terminate early. The behavior you saw seems to be only when running from Android Studio Configuration. At least as far as I saw. If that is indeed the case, it is likely that it's related to how Android Studio executes the tasks.

Indeed, it seems to be a problem with the gradle that comes with AS. Thank you for your reply.