Skip to content

Commit 1ff39c2

Browse files
Patch jna.boot.library.path in build scripts
This fixes the build on macOS until JetBrains/MPS#71 is fixed.
1 parent ce79c00 commit 1ff39c2

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

build.gradle

+37-14
Original file line numberDiff line numberDiff line change
@@ -159,53 +159,76 @@ tasks.withType(RunAntScript).configureEach {
159159
dependsOn(configureJava, resolveMps)
160160
}
161161

162-
task build_allScripts(type: BuildLanguages, dependsOn: [resolveMps, configureJava]) {
162+
def build_allScripts_unpatched = tasks.register('build_allScripts_unpatched', BuildLanguages) {
163163
script "$buildDir/scripts/build_all_scripts.xml"
164164
}
165165

166+
// Patch JNA path in generated build scripts until https://github.com/JetBrains/MPS/pull/71 is fixed
167+
def patch_allScripts = tasks.register('patch_allScripts', Copy) {
168+
dependsOn build_allScripts_unpatched
169+
from 'build/scripts'
170+
into 'build/patched-scripts'
171+
172+
def isAarch64 = System.getProperty('os.arch') == 'aarch64'
173+
def jnaArch = isAarch64 ? 'aarch64' : 'amd64'
174+
175+
filter {
176+
it.replace('"-Djna.boot.library.path=${artifacts.mps}/lib/jna"',
177+
'"-Djna.boot.library.path=${artifacts.mps}/lib/jna/' + jnaArch + '"')
178+
}
179+
}
180+
181+
task build_allScripts {
182+
dependsOn patch_allScripts
183+
}
184+
185+
File scriptFile(String name) {
186+
file("$buildDir/patched-scripts/$name")
187+
}
188+
166189
// All other MPS tasks depend on build_allScripts
167190
tasks.withType(RunAntScript).configureEach {
168-
if (it != build_allScripts) {
191+
if (it.name != build_allScripts_unpatched.name) {
169192
it.dependsOn(build_allScripts)
170193
}
171194
}
172195

173196
task build_base_languages(type: BuildLanguages) {
174-
script "$buildDir/scripts/build-base-languages.xml"
197+
script scriptFile('build-base-languages.xml')
175198
}
176199

177200
task build_testing_languages(type: BuildLanguages, dependsOn: [build_base_languages]) {
178-
script "$buildDir/scripts/build-testing-languages.xml"
201+
script scriptFile('build-testing-languages.xml')
179202
}
180203

181204
task test_testing(type: TestLanguages, dependsOn: [build_testing_languages]) {
182205
// MPS build language generator is confused about the basedir of the generated script so we set it manually
183206
scriptArgs = ["-Dbasedir=${file('code/languages/org.mpsqa.testing')}"]
184-
script "$buildDir/scripts/test-testing.xml"
207+
script scriptFile("test-testing.xml")
185208
}
186209

187210
task build_clones_languages(type: BuildLanguages, dependsOn: [build_base_languages]) {
188-
script "$buildDir/scripts/build-clones-languages.xml"
211+
script scriptFile("build-clones-languages.xml")
189212
}
190213

191214
task build_mutant_languages(type: BuildLanguages, dependsOn: []) {
192-
script "$buildDir/scripts/build-mutant-languages.xml"
215+
script scriptFile("build-mutant-languages.xml")
193216
}
194217

195218
task build_unused_languages(type: BuildLanguages, dependsOn: []) {
196-
script "$buildDir/scripts/build-unused-languages-analysis.xml"
219+
script scriptFile("build-unused-languages-analysis.xml")
197220
}
198221

199222
task build_arch_languages(type: BuildLanguages, dependsOn: []) {
200-
script "$buildDir/scripts/build-arch-analysis-languages.xml"
223+
script scriptFile("build-arch-analysis-languages.xml")
201224
}
202225

203226
task build_deprecation_analysis_languages(type: BuildLanguages, dependsOn: []) {
204-
script "$buildDir/scripts/build-deprecated-analysis-languages.xml"
227+
script scriptFile("build-deprecated-analysis-languages.xml")
205228
}
206229

207230
task build_lint_analysis_languages(type: BuildLanguages, dependsOn: []) {
208-
script "$buildDir/scripts/build-lint-analysis-languages.xml"
231+
script scriptFile("build-lint-analysis-languages.xml")
209232
}
210233

211234
task build_allInOne_package(type: BuildLanguages, dependsOn: [build_allScripts]) {
@@ -217,7 +240,7 @@ task build_allInOne_package(type: BuildLanguages, dependsOn: [build_allScripts])
217240
dependsOn 'build_arch_languages'
218241
dependsOn 'build_deprecation_analysis_languages'
219242
dependsOn 'build_lint_analysis_languages'
220-
script "$buildDir/scripts/build-allInOne-package.xml"
243+
script scriptFile("build-allInOne-package.xml")
221244
}
222245

223246
task package_mpsqa(type: Zip, dependsOn: build_allInOne_package) {
@@ -228,12 +251,12 @@ task package_mpsqa(type: Zip, dependsOn: build_allInOne_package) {
228251

229252
task test_clones(type: TestLanguages, dependsOn: build_clones_languages) {
230253
description "Will execute clones tests from command line"
231-
script new File("$buildDir/scripts/test-clones.xml")
254+
script scriptFile("test-clones.xml")
232255
}
233256

234257
task test_lint(type: TestLanguages, dependsOn: build_lint_analysis_languages) {
235258
description "Will execute lint tests from command line"
236-
script "$buildDir/scripts/build-lint-tests.xml"
259+
script scriptFile("build-lint-tests.xml")
237260
}
238261

239262
check.dependsOn(tasks.withType(TestLanguages))

0 commit comments

Comments
 (0)