From 99e900618209a287d2a01b20706eb5f944187ed5 Mon Sep 17 00:00:00 2001 From: Alexander Pann Date: Tue, 30 Jan 2024 11:19:36 +0100 Subject: [PATCH] Include the JNA path workaround. See: https://github.com/JetBrains/MPS-extensions/pull/750 --- build.gradle.kts | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2b8490da..8ec2d0de 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -150,6 +150,8 @@ val defaultScriptArgs = mapOf( "jdk.util.zip.disableZip64ExtraFieldValidation" to true ) +fun scriptFile(relativePath: String):File = File("$rootDir/build/scripts/patched/$relativePath") + tasks { val configureJava by registering { val downloadJbr = named("downloadJbr", DownloadJbrForPlatform::class) @@ -180,24 +182,45 @@ tasks { description = "Set up MPS project libraries. Libraries are read in from projectlibraries.properties file." } - val build_allScripts by registering(BuildLanguages::class) { + val build_allScripts_unpatched by registering(BuildLanguages::class) { dependsOn(resolveMps, resolveLanguageLibs) script = "$buildDir/scripts/build_all_scripts.xml" } + // Patch JNA path in generated build scripts until https://github.com/JetBrains/MPS/pull/71 is fixed + val patch_allScripts by registering(Copy::class) { + dependsOn(build_allScripts_unpatched) + from("build/scripts") + exclude("patched") + exclude("build") + into("build/scripts/patched") + + val isAarch64 = System.getProperty("os.arch") == "aarch64" + val jnaArch = if (isAarch64) "aarch64" else "amd64" + + filter { line: String -> + line.replace("\"-Djna.boot.library.path=${'$'}{artifacts.mps}/lib/jna\"", + "\"-Djna.boot.library.path=${'$'}{artifacts.mps}/lib/jna/" + jnaArch + "\"") + } + } + + val build_allScripts by registering { + dependsOn(patch_allScripts, resolveLanguageLibs) + } + val build_formal_languages by registering(BuildLanguages::class) { dependsOn(build_allScripts) - script = "$buildDir/scripts/build-formal-languages.xml" + script = scriptFile("build-formal-languages.xml") } val build_fasten_safety_distribution by registering(BuildLanguages::class) { dependsOn(build_formal_languages) - script = "$buildDir/scripts/build-fasten-safe-distribution.xml" + script = scriptFile("build-fasten-safe-distribution.xml") } val run_smv_tests by registering(TestLanguages::class) { description = "Will execute all tests from command line" - script = "$buildDir/scripts/build-nusmv-tests.xml" + script = scriptFile("build-nusmv-tests.xml") doLast { ant.withGroovyBuilder { "taskdef"("name" to "junitreport", @@ -214,7 +237,7 @@ tasks { val run_safety_tests by registering(TestLanguages::class) { description = "Will execute all tests from command line" - script = "$buildDir/scripts/build-safety-tests.xml" + script = scriptFile("build-safety-tests.xml") doLast { ant.withGroovyBuilder { "taskdef"("name" to "junitreport", @@ -232,7 +255,7 @@ tasks { val run_all_tests by registering(TestLanguages::class) { dependsOn(configureJava) description = "Will execute all tests from command line" - script = "$buildDir/scripts/build-all-tests.xml" + script = scriptFile("build-all-tests.xml") doLast { ant.withGroovyBuilder { "taskdef"("name" to "junitreport", @@ -260,7 +283,7 @@ tasks { val build_assurance_languages by registering(BuildLanguages::class) { dependsOn(build_allScripts) - script = "$buildDir/scripts/build-assurance-languages.xml" + script = scriptFile("build-assurance-languages.xml") } val package_assurance by registering(Zip::class) {