From ede40dd500693a664558cf4ff9be379d0c3de5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20Ko=C5=A1=C4=8Dejev?= Date: Sun, 28 Jan 2024 09:52:43 +0100 Subject: [PATCH] Patch JNA path in build scripts Necessary to run tests on macOS until https://github.com/JetBrains/MPS/pull/71 is fixed --- build.gradle | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index c03cf423b..bb03d3f49 100644 --- a/build.gradle +++ b/build.gradle @@ -211,7 +211,7 @@ ext.extensions_home = '-Dextensions.home=' + rootDir // ___________________ utilities ___________________ File scriptFile(String relativePath) { - new File("$rootDir/build/generated/$relativePath") + new File("$rootDir/build/patched/$relativePath") } def defaultScriptArgs = [mps_home, build_dir, artifacts_dir, ext.buildDate, ext.pluginVersion] @@ -254,15 +254,30 @@ task resolved_diagram_dependencies(type: Copy) { } } -task build_allScripts(type: BuildLanguages, dependsOn: [ - 'downloadJbr', - resolveMps, - resolved_diagram_dependencies, - copyModelApi, -]) { +def build_allScripts_unpatched = tasks.register('build_allScripts_unpatched', BuildLanguages) { + dependsOn 'downloadJbr', resolveMps, copyModelApi, resolved_diagram_dependencies script "$rootDir/scripts/build.xml" } +// Patch JNA path in generated build scripts until https://github.com/JetBrains/MPS/pull/71 is fixed +def patch_allScripts = tasks.register('patch_allScripts', Copy) { + dependsOn build_allScripts_unpatched + from 'build/generated' + into 'build/patched' + + def isAarch64 = System.getProperty('os.arch') == 'aarch64' + def jnaArch = isAarch64 ? 'aarch64' : 'amd64' + + filter { + it.replace('"-Djna.boot.library.path=${artifacts.mps}/lib/jna"', + '"-Djna.boot.library.path=${artifacts.mps}/lib/jna/' + jnaArch + '"') + } +} + +task build_allScripts { + dependsOn patch_allScripts +} + task build_languages(type: BuildLanguages, dependsOn: [build_allScripts]) { script scriptFile('languages/build.xml') }