Skip to content

Commit a661b48

Browse files
committed
feat: upgrade to Rust 1.86.0
Pathfinder 0.5.5 has finally resolved the compilation errors encountered when upgrading to the new version of Rust. See also: servo/pathfinder#571
1 parent f4fbff0 commit a661b48

File tree

8 files changed

+41
-32
lines changed

8 files changed

+41
-32
lines changed

.github/workflows/CI.yaml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,18 @@ jobs:
114114
with:
115115
node-version: 18
116116
cache: yarn
117-
- name: Install
118-
uses: dtolnay/rust-toolchain@master
117+
- name: Rustup toolchain version
118+
shell: bash
119+
id: rustup-version
120+
run: |
121+
export RUST_TOOLCHAIN_VERSION="$(grep 'channel' rust-toolchain.toml | head -1 | awk -F '"' '{print $2}')"
122+
echo "Rust toolchain version: $RUST_TOOLCHAIN_VERSION"
123+
echo "RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION" >> "$GITHUB_OUTPUT"
124+
- name: Install Rust toolchain
125+
uses: dtolnay/rust-toolchain@stable
119126
if: ${{ !matrix.settings.docker }}
120127
with:
121-
toolchain: nightly-2023-12-11
128+
toolchain: ${{ steps.rustup-version.outputs.RUST_TOOLCHAIN_VERSION }}
122129
targets: ${{ matrix.settings.target }}
123130
- name: Cache cargo
124131
uses: actions/cache@v4
@@ -191,11 +198,20 @@ jobs:
191198
with:
192199
node-version: ${{ matrix.node }}
193200

194-
- name: Install
195-
uses: actions-rs/toolchain@v1
201+
- name: Rustup toolchain version
202+
shell: bash
203+
id: rustup-version
204+
run: |
205+
export RUST_TOOLCHAIN_VERSION="$(grep 'channel' rust-toolchain.toml | head -1 | awk -F '"' '{print $2}')"
206+
echo "Rust toolchain version: $RUST_TOOLCHAIN_VERSION"
207+
echo "RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION" >> "$GITHUB_OUTPUT"
208+
209+
- name: Install Rust toolchain
210+
uses: dtolnay/rust-toolchain@stable
211+
if: ${{ !matrix.settings.docker }}
196212
with:
197-
profile: minimal
198-
override: true
213+
toolchain: ${{ steps.rustup-version.outputs.RUST_TOOLCHAIN_VERSION }}
214+
targets: ${{ matrix.settings.target }}
199215

200216
- name: Cache cargo
201217
uses: Swatinem/rust-cache@v2

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ thiserror = "1.0.37"
1919
png = "=0.17.5"
2020
pathfinder_geometry = "0.5.1"
2121
pathfinder_content = { version = "0.5.0", default-features = false }
22-
pathfinder_simd = { version = "=0.5.2", features = ["pf-no-simd"] }
22+
pathfinder_simd = { version = "=0.5.5", features = ["pf-no-simd"] }
2323
futures = "0.3.21"
2424
woff2 = "0.3.0"
2525

@@ -38,8 +38,8 @@ resvg = { version = "0.34.0", default-features = false, features = [
3838
] }
3939

4040
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
41-
napi = { version = "2.16.0", features = ["serde-json", "async"] }
42-
napi-derive = "2.16.0"
41+
napi = { version = "2.16.17", features = ["serde-json", "async"] }
42+
napi-derive = "2.16.13"
4343
resvg = { version = "0.34.0", default-features = false, features = [
4444
"raster-images",
4545
"text",

js-binding.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/* auto-generated by NAPI-RS */
55

6-
export function renderAsync(svg: string | Buffer, options?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise<RenderedImage>
6+
export declare function renderAsync(svg: string | Buffer, options?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise<RenderedImage>
77
export declare class BBox {
88
x: number
99
y: number

rust-toolchain

Lines changed: 0 additions & 1 deletion
This file was deleted.

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Use `rustup show` to view the currently installed version.
2+
[toolchain]
3+
channel = "1.86.0"
4+
profile = "default"

wasm/index.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ var heap = new Array(128).fill(void 0);
3131
heap.push(void 0, null, true, false);
3232
var heap_next = heap.length;
3333
function addHeapObject(obj) {
34-
if (heap_next === heap.length)
35-
heap.push(heap.length + 1);
34+
if (heap_next === heap.length) heap.push(heap.length + 1);
3635
const idx = heap_next;
3736
heap_next = heap[idx];
3837
heap[idx] = obj;
@@ -42,8 +41,7 @@ function getObject(idx) {
4241
return heap[idx];
4342
}
4443
function dropObject(idx) {
45-
if (idx < 132)
46-
return;
44+
if (idx < 132) return;
4745
heap[idx] = heap_next;
4846
heap_next = idx;
4947
}
@@ -87,8 +85,7 @@ function passStringToWasm0(arg, malloc, realloc) {
8785
let offset = 0;
8886
for (; offset < len; offset++) {
8987
const code = arg.charCodeAt(offset);
90-
if (code > 127)
91-
break;
88+
if (code > 127) break;
9289
mem[ptr + offset] = code;
9390
}
9491
if (offset !== len) {
@@ -555,8 +552,7 @@ function __wbg_finalize_init(instance, module2) {
555552
return wasm;
556553
}
557554
async function __wbg_init(input) {
558-
if (wasm !== void 0)
559-
return wasm;
555+
if (wasm !== void 0) return wasm;
560556
if (typeof input === "undefined") {
561557
input = new URL("index_bg.wasm", void 0);
562558
}
@@ -585,8 +581,7 @@ var Resvg2 = class extends Resvg {
585581
* @param {ResvgRenderOptions | undefined} options
586582
*/
587583
constructor(svg, options) {
588-
if (!initialized)
589-
throw new Error("Wasm has not been initialized. Call `initWasm()` function.");
584+
if (!initialized) throw new Error("Wasm has not been initialized. Call `initWasm()` function.");
590585
const font = options?.font;
591586
if (!!font && isCustomFontsOptions(font)) {
592587
const serializableOptions = {

wasm/index.mjs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ var heap = new Array(128).fill(void 0);
44
heap.push(void 0, null, true, false);
55
var heap_next = heap.length;
66
function addHeapObject(obj) {
7-
if (heap_next === heap.length)
8-
heap.push(heap.length + 1);
7+
if (heap_next === heap.length) heap.push(heap.length + 1);
98
const idx = heap_next;
109
heap_next = heap[idx];
1110
heap[idx] = obj;
@@ -15,8 +14,7 @@ function getObject(idx) {
1514
return heap[idx];
1615
}
1716
function dropObject(idx) {
18-
if (idx < 132)
19-
return;
17+
if (idx < 132) return;
2018
heap[idx] = heap_next;
2119
heap_next = idx;
2220
}
@@ -60,8 +58,7 @@ function passStringToWasm0(arg, malloc, realloc) {
6058
let offset = 0;
6159
for (; offset < len; offset++) {
6260
const code = arg.charCodeAt(offset);
63-
if (code > 127)
64-
break;
61+
if (code > 127) break;
6562
mem[ptr + offset] = code;
6663
}
6764
if (offset !== len) {
@@ -528,8 +525,7 @@ function __wbg_finalize_init(instance, module) {
528525
return wasm;
529526
}
530527
async function __wbg_init(input) {
531-
if (wasm !== void 0)
532-
return wasm;
528+
if (wasm !== void 0) return wasm;
533529
if (typeof input === "undefined") {
534530
input = new URL("index_bg.wasm", void 0);
535531
}
@@ -558,8 +554,7 @@ var Resvg2 = class extends Resvg {
558554
* @param {ResvgRenderOptions | undefined} options
559555
*/
560556
constructor(svg, options) {
561-
if (!initialized)
562-
throw new Error("Wasm has not been initialized. Call `initWasm()` function.");
557+
if (!initialized) throw new Error("Wasm has not been initialized. Call `initWasm()` function.");
563558
const font = options?.font;
564559
if (!!font && isCustomFontsOptions(font)) {
565560
const serializableOptions = {

wasm/index_bg.wasm

52.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)