diff options
| author | Ville Voutilainen <ville.voutilainen@qt.io> | 2024-09-29 21:44:22 +0300 |
|---|---|---|
| committer | Ville Voutilainen <ville.voutilainen@qt.io> | 2024-09-30 08:15:06 +0000 |
| commit | 35f87b6deda46fe62b27a814213ecc7fe13161cb (patch) | |
| tree | dba8e263e76331c1e5ad14004187efb2a92c812e | |
| parent | c00d018c71ade97c73b050a787c597cc9146f284 (diff) | |
Make the JTE builds use different directories for debug/release builds
This fixes our longest-standing problem; when run in parallel, the build
sometimes (often) fails, because parallel builds cause JTE to write
to the same java class files concurrently.
The problem is cured by defining a task-specific property that is then passed
down to Jenny as the directory suffix to use for the JTE output directory.
Change-Id: I1f49a3af7f8d1102dc06cc1705c0ff1868477568
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
4 files changed, 34 insertions, 1 deletions
diff --git a/compiler/src/main/java/io/github/landerlyoung/jenny/Configurations.kt b/compiler/src/main/java/io/github/landerlyoung/jenny/Configurations.kt index 7c4ca49..106c2b4 100644 --- a/compiler/src/main/java/io/github/landerlyoung/jenny/Configurations.kt +++ b/compiler/src/main/java/io/github/landerlyoung/jenny/Configurations.kt @@ -33,6 +33,7 @@ data class Configurations( val errorLoggerFunction: String?, val outputDirectory: String?, val templateDirectory: String?, + val templateBuildSuffix: String?, val fusionProxyHeaderName: String, val headerOnlyProxy: Boolean = true, val useJniHelper: Boolean = false, @@ -53,6 +54,8 @@ data class Configurations( val TEMPLATE_DIRECTORY = PREFIX + Configurations::templateDirectory.name + val TEMPLATE_BUILD_SUFFIX = PREFIX + Configurations::templateBuildSuffix.name + val FUSION_PROXY_HEADER_NAME = PREFIX + Configurations::fusionProxyHeaderName.name val HEADER_ONLY_PROXY = PREFIX + Configurations::headerOnlyProxy.name @@ -66,6 +69,7 @@ data class Configurations( ERROR_LOGGER_FUNCTION, OUTPUT_DIRECTORY, TEMPLATE_DIRECTORY, + TEMPLATE_BUILD_SUFFIX, FUSION_PROXY_HEADER_NAME, HEADER_ONLY_PROXY, USE_JNI_HELPER, @@ -77,6 +81,7 @@ data class Configurations( options[ERROR_LOGGER_FUNCTION], options[OUTPUT_DIRECTORY], options[TEMPLATE_DIRECTORY], + options[TEMPLATE_BUILD_SUFFIX], options[FUSION_PROXY_HEADER_NAME] ?: Constants.JENNY_FUSION_PROXY_HEADER_NAME, options[HEADER_ONLY_PROXY] != false.toString(), options[USE_JNI_HELPER] == true.toString(), diff --git a/compiler/src/main/java/io/github/landerlyoung/jenny/NativeProxyGenerator.kt b/compiler/src/main/java/io/github/landerlyoung/jenny/NativeProxyGenerator.kt index 4b4a46b..eced20e 100644 --- a/compiler/src/main/java/io/github/landerlyoung/jenny/NativeProxyGenerator.kt +++ b/compiler/src/main/java/io/github/landerlyoung/jenny/NativeProxyGenerator.kt @@ -106,6 +106,8 @@ class NativeProxyGenerator(env: Environment, clazz: TypeElement, nativeProxy: Na if (useTemplates) { val path: String = mEnv.configurations.templateDirectory ?: (System.getProperty("user.dir") + "/templates") + val templateBuildSuffix: String = mEnv.configurations.templateBuildSuffix + ?: "" if (!File(path).exists()) { error("Templates folder does not exist failed to generate using templates. Attempting without templates") useTemplates = false @@ -113,7 +115,7 @@ class NativeProxyGenerator(env: Environment, clazz: TypeElement, nativeProxy: Na val codeResolver = DirectoryCodeResolver(Path.of(path)) templateEngine = TemplateEngine.create( codeResolver, - Path.of(path), + Path.of(path + templateBuildSuffix), ContentType.Plain, NativeProxyGenerator::class.java.classLoader ) diff --git a/sample-android-qt/build.gradle b/sample-android-qt/build.gradle index 2ca61b6..656a147 100644 --- a/sample-android-qt/build.gradle +++ b/sample-android-qt/build.gradle @@ -68,6 +68,19 @@ android { } } +import org.jetbrains.kotlin.gradle.internal.KaptTask + +tasks.withType(KaptTask) { task -> + def suffix = task.name.contains("kaptDebug") ? "_debug" : "_release" + + annotationProcessorOptionProviders.add([new CommandLineArgumentProvider() { + @Override + Iterable<String> asArguments() { + return ["jenny.templateBuildSuffix=" + suffix] + } + }]) +} + kapt { arguments { // pass arguments to jenny diff --git a/sample-android/build.gradle b/sample-android/build.gradle index d505451..2184e26 100644 --- a/sample-android/build.gradle +++ b/sample-android/build.gradle @@ -72,6 +72,19 @@ android { } } +import org.jetbrains.kotlin.gradle.internal.KaptTask + +tasks.withType(KaptTask) { task -> + def suffix = task.name.contains("kaptDebug") ? "_debug" : "_release" + + annotationProcessorOptionProviders.add([new CommandLineArgumentProvider() { + @Override + Iterable<String> asArguments() { + return ["jenny.templateBuildSuffix=" + suffix] + } + }]) +} + kapt { arguments { // pass arguments to jenny |
