Skip to content

Commit 3929fbd

Browse files
garrettsummerfi3ldqwertychouskie
authored andcommitted
Fix multiarch movement for CANBridge
1 parent 50943a3 commit 3929fbd

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

scripts/download-CanBridge.mjs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ try {
5454
}
5555
process.exit(1);
5656
} finally {
57-
if (fs.existsSync(tempDir)) {
58-
fs.rmSync(tempDir, { recursive: true, force: true});
59-
}
57+
//if (fs.existsSync(tempDir)) {
58+
// fs.rmSync(tempDir, { recursive: true, force: true});
59+
//}
6060
}
6161

6262
/**
@@ -66,6 +66,9 @@ try {
6666
*/
6767
function moveCompileTimeDeps() {
6868
console.log("Moving external compile time dependencies to correct directories");
69+
if (!fs.existsSync(externalCompileTimeDepsPath)) {
70+
fs.mkdirSync(externalCompileTimeDepsPath, { recursive: true });
71+
}
6972
if (platform() === 'win32') {
7073
const deps = ['CANBridge.lib', 'wpiHal.lib', 'wpiutil.lib'];
7174
deps.forEach(dep => moveExternalCompileTimeDeps(path.join('win32-x64', dep)));
@@ -95,24 +98,31 @@ function moveCompileTimeDeps() {
9598
*/
9699
function moveRuntimeDeps() {
97100
console.log("Moving artifacts to correct directories");
101+
if (!fs.existsSync('prebuilds')) {
102+
fs.mkdirSync('prebuilds', { recursive: true });
103+
}
98104
if (platform() === 'win32') {
99105
const deps = ['CANBridge.dll', 'wpiHal.dll', 'wpiutil.dll'];
100106
deps.forEach(dep => moveRuntimeArtifactsDeps(path.join('win32-x64', dep), runtimeArtifactsPath.win));
101107
} else if (platform() === 'darwin') {
102108
const deps = ['libCANBridge.dylib', 'libwpiHal.dylib', 'libwpiutil.dylib'];
103-
const archDepMap = {
104-
x64: runtimeArtifactsPath.osx,
105-
arm64: runtimeArtifactsPath.osxArm
106-
};
107-
deps.forEach(dep => moveRuntimeArtifactsDeps(path.join(archDepMap[arch()], dep), archDepMap[arch()]));
109+
if (arch() === 'x64') {
110+
deps.forEach(dep => moveRuntimeArtifactsDeps(path.join('darwin-x64', dep), runtimeArtifactsPath.osx));
111+
}
112+
if (arch() === 'arm64') {
113+
deps.forEach(dep => moveRuntimeArtifactsDeps(path.join('darwin-arm64', dep), runtimeArtifactsPath.osxArm));
114+
}
108115
} else if (platform() === 'linux') {
109116
const deps = ['libCANBridge.so', 'libwpiHal.so', 'libwpiutil.so'];
110-
const archDepMap = {
111-
x64: runtimeArtifactsPath.linux,
112-
arm64: runtimeArtifactsPath.linuxArm,
113-
arm: runtimeArtifactsPath.linuxArm32
114-
};
115-
deps.forEach(dep => moveRuntimeArtifactsDeps(path.join(archDepMap[arch()], dep), archDepMap[arch()]));
117+
if (arch() === 'x64') {
118+
deps.forEach(dep => moveRuntimeArtifactsDeps(path.join('linux-x64', dep), runtimeArtifactsPath.linux));
119+
}
120+
if (arch() === 'arm64') {
121+
deps.forEach(dep => moveRuntimeArtifactsDeps(path.join('linux-arm64', dep), runtimeArtifactsPath.linuxArm));
122+
}
123+
if (arch() === 'arm') {
124+
deps.forEach(dep => moveRuntimeArtifactsDeps(path.join('linux-arm32', dep), runtimeArtifactsPath.linuxArm32));
125+
}
116126
}
117127
console.log("CANBridge artifacts moved to correct directories");
118128
}

0 commit comments

Comments
 (0)