@@ -107,37 +107,39 @@ def rustJavaTargets = [
107107 ' x86_64-unknown-linux-gnu' : ' linux/x86_64'
108108]
109109
110- tasks. register(' installCargoZigbuild' , Exec ) {
111- group ' Build'
112- description ' Installs Cargo Zigbuild for Rust compilation.'
110+ def RustVersion = ' 1.81'
113111
114- commandLine ' cargo' , ' install' , ' cargo-zigbuild@0.19.3'
112+ tasks. register(' installRequiredRustVersion' , Exec ) {
113+ group ' Build'
114+ description ' Install required Rust version.'
115+ commandLine ' rustup' , ' install' , RustVersion
115116}
116117
117- tasks. register(' installRustTargets ' ) {
118- dependsOn(' installCargoZigbuild ' )
118+ tasks. register(' installCargoZigbuild ' , Exec ) {
119+ dependsOn(' installRequiredRustVersion ' )
119120 group ' Build'
120- description ' Installs Rust platform build targets .'
121+ description ' Installs Cargo Zigbuild for Rust compilation .'
121122
122- doLast {
123- rustLibraryTargets. keySet(). forEach { rustTarget ->
124- exec {
125- commandLine ' rustup' , ' target' , ' add' , rustTarget
126- }
127- }
128- }
123+ commandLine ' cargo' , ' +' + RustVersion , ' install' , ' cargo-zigbuild@0.19.3'
129124}
130125
131126tasks. register(' compileFFI' ) {
132- dependsOn(' installRustTargets ' )
127+ dependsOn(' installCargoZigbuild ' )
133128 group ' Build'
134129 description ' Compiles Foreign Function Interface libraries.'
130+ exec {
131+ workingDir = ffiDir
132+ commandLine ' rustup' , ' override' , ' set' , RustVersion
133+ }
135134
136135 doLast {
137136 rustLibraryTargets. forEach { rustTarget , libraryFile ->
137+ exec {
138+ commandLine ' rustup' , ' target' , ' add' , rustTarget, ' --toolchain' , RustVersion
139+ }
138140 exec {
139141 workingDir = ffiDir
140- commandLine ' cargo' , ' zigbuild' , ' --features' , ' partial-eval' , ' --release' , ' --target' , rustTarget
142+ commandLine ' cargo' , ' + ' + RustVersion , ' zigbuild' , ' --features' , ' partial-eval' , ' --release' , ' --target' , rustTarget
141143 }
142144
143145 def sourcePath = " ${ ffiDir} /target/${ rustTarget} /release/${ libraryFile} "
0 commit comments