Skip to content

Commit 34e817b

Browse files
committed
Add modifiers to version bundles (#137)
Allows modifying versions of tools for specific platforms, for example use 13.2.Rel1 toolchain instead of 13.3.Rel1 on Intel MacOS, as 13.3.Rel1 is linked against homebrew (https://forums.raspberrypi.com/viewtopic.php?t=380395)
1 parent 157ca83 commit 34e817b

File tree

2 files changed

+43
-24
lines changed

2 files changed

+43
-24
lines changed

data/0.18.0/versionBundles.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,35 @@
2525
"cmake": "v3.29.9",
2626
"picotool": "2.1.0",
2727
"toolchain": "13_3_Rel1",
28-
"riscvToolchain": "RISCV_RPI_2_0_0_5"
28+
"riscvToolchain": "RISCV_RPI_2_0_0_5",
29+
"modifiers": {
30+
"darwin_x64": {
31+
"toolchain": "13_2_Rel1"
32+
}
33+
}
2934
},
3035
"2.1.1": {
3136
"ninja": "v1.12.1",
3237
"cmake": "v3.31.5",
3338
"picotool": "2.1.1",
3439
"toolchain": "14_2_Rel1",
35-
"riscvToolchain": "RISCV_RPI_2_0_0_5"
40+
"riscvToolchain": "RISCV_RPI_2_0_0_5",
41+
"modifiers": {
42+
"darwin_x64": {
43+
"toolchain": "13_2_Rel1"
44+
}
45+
}
3646
},
3747
"2.2.0": {
3848
"ninja": "v1.12.1",
3949
"cmake": "v3.31.5",
4050
"picotool": "2.2.0-a4",
4151
"toolchain": "14_2_Rel1",
42-
"riscvToolchain": "RISCV_ZCB_RPI_2_1_1_3"
52+
"riscvToolchain": "RISCV_ZCB_RPI_2_1_1_3",
53+
"modifiers": {
54+
"darwin_x64": {
55+
"toolchain": "13_2_Rel1"
56+
}
57+
}
4358
}
4459
}

src/utils/versionBundles.mts

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@ const versionBundlesUrl =
1010
`${CURRENT_DATA_VERSION}/versionBundles.json`;
1111

1212
export interface VersionBundle {
13-
python: {
14-
version: string;
15-
macos: string;
16-
windowsAmd64: string;
17-
};
1813
ninja: string;
1914
cmake: string;
2015
picotool: string;
2116
toolchain: string;
2217
riscvToolchain: string;
18+
modifiers: { [triple: string] : {[tool: string]: string}};
2319
}
2420

2521
export interface VersionBundles {
@@ -103,24 +99,32 @@ export default class VersionBundlesLoader {
10399
await this.loadBundles();
104100
}
105101

106-
return (this.bundles ?? {})[version];
107-
}
102+
const chosenBundle = (this.bundles ?? {})[version];
108103

109-
public async getPythonWindowsAmd64Url(
110-
pythonVersion: string
111-
): Promise<VersionBundle | undefined> {
112-
if (this.bundles === undefined) {
113-
await this.loadBundles();
114-
}
115-
if (this.bundles === undefined) {
116-
return undefined;
117-
}
104+
if (chosenBundle !== undefined) {
105+
const modifiers = chosenBundle?.modifiers;
106+
if (modifiers !== undefined) {
107+
const platformDouble = `${process.platform}_${process.arch}`;
108+
if (modifiers[platformDouble] !== undefined) {
109+
chosenBundle.cmake =
110+
modifiers[platformDouble]["cmake"] ?? chosenBundle.cmake
111+
112+
chosenBundle.ninja =
113+
modifiers[platformDouble]["ninja"] ?? chosenBundle.ninja
114+
115+
chosenBundle.picotool =
116+
modifiers[platformDouble]["picotool"] ?? chosenBundle.picotool
118117

119-
const bundle = Object.values(this.bundles).find(
120-
bundle => bundle.python.version === pythonVersion
121-
);
118+
chosenBundle.toolchain =
119+
modifiers[platformDouble]["toolchain"] ?? chosenBundle.toolchain
120+
121+
chosenBundle.riscvToolchain =
122+
modifiers[platformDouble]["riscvToolchain"] ??
123+
chosenBundle.riscvToolchain
124+
}
125+
}
126+
}
122127

123-
//return bundle?.python.windowsAmd64;
124-
return bundle;
128+
return chosenBundle;
125129
}
126130
}

0 commit comments

Comments
 (0)