Skip to content

Commit 5b3f64e

Browse files
Use Rust 1.81 to crossbuild FFI (#252)
Signed-off-by: Shaobo He <shaobohe@amazon.com>
1 parent dcdc73a commit 5b3f64e

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

.github/workflows/run_cedar_java_reusable.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ jobs:
4040
ref: ${{ inputs.cedar_policy_ref }}
4141
path: ./cedar
4242
- name: Prepare Rust Build
43-
# zigbuild issue: rust-cross/cargo-zigbuild#289
44-
run: rustup install 1.81 && rustup default 1.81 && rustup component add rustfmt
43+
run: rustup install stable && rustup default stable
4544
- name: Configure CedarJavaFFI for CI build
4645
run: bash configure_ci_build.sh
4746
- name: Check FFI Formatting

CedarJava/build.gradle

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

131126
tasks.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

Comments
 (0)