diff --git a/Dotnet/VRCX-Electron.csproj b/Dotnet/VRCX-Electron.csproj index 2bbc981f..f37cc34b 100644 --- a/Dotnet/VRCX-Electron.csproj +++ b/Dotnet/VRCX-Electron.csproj @@ -8,7 +8,7 @@ net9.0 Library Debug;Release - x64 + x64;ARM64 x64 0 1.0.0.%2a @@ -35,10 +35,16 @@ LINUX - + full - + + full + + + pdbonly + + pdbonly diff --git a/package.json b/package.json index 850c30aa..c7351d52 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test:coverage": "jest --coverage", "prod": "cross-env PLATFORM=windows webpack --config webpack.config.js --mode production", "prod-linux": "cross-env PLATFORM=linux webpack --config webpack.config.js --mode production", - "build-electron": "node ./src-electron/download-dotnet-runtime.js && node ./src-electron/patch-package-version.js && electron-builder --x64 --publish never", + "build-electron": "node ./src-electron/download-dotnet-runtime.js && node ./src-electron/patch-package-version.js && electron-builder --publish never", "postbuild-electron": "node ./src-electron/patch-node-api-dotnet.js && node ./src-electron/rename-builds.js", "start-electron": "electron ." }, diff --git a/src-electron/download-dotnet-runtime.js b/src-electron/download-dotnet-runtime.js index f26288b4..e0d1da09 100644 --- a/src-electron/download-dotnet-runtime.js +++ b/src-electron/download-dotnet-runtime.js @@ -3,8 +3,29 @@ const path = require('path'); const https = require('https'); const { spawnSync } = require('child_process'); +let runnerArch = process.arch.toString(); +let runnerPlatform = process.platform.toString(); +const args = process.argv.slice(2); +for (let i = 0; i < args.length; i++) { + if (args[i] === '--arch' && i + 1 < args.length) { + runnerArch = args[i + 1]; + } else if (args[i] === '--platform' && i + 1 < args.length) { + runnerPlatform = args[i + 1]; + } +} +let platform = ''; +if (runnerPlatform === 'linux') { + platform = 'linux'; +} else if (runnerPlatform === 'darwin') { + platform = 'osx'; +} else if (runnerPlatform === 'win32') { + platform = 'win'; +} else { + throw new Error(`Unsupported platform: ${runnerPlatform}`); +} + const DOTNET_VERSION = '9.0.8'; -const DOTNET_RUNTIME_URL = `https://builds.dotnet.microsoft.com/dotnet/Runtime/${DOTNET_VERSION}/dotnet-runtime-${DOTNET_VERSION}-linux-x64.tar.gz`; +const DOTNET_RUNTIME_URL = `https://builds.dotnet.microsoft.com/dotnet/Runtime/${DOTNET_VERSION}/dotnet-runtime-${DOTNET_VERSION}-${platform}-${runnerArch}.tar.gz`; const DOTNET_RUNTIME_DIR = path.join( __dirname, '..', @@ -58,12 +79,14 @@ async function extractTarGz(tarGzPath, extractDir) { } async function main() { - if (process.platform !== 'linux') { - console.log('Skipping .NET runtime download on non-Linux platform'); + if (platform !== 'linux' && platform !== 'darwin') { + console.log('Skipping .NET runtime download on non supported platform'); return; } - console.log(`Downloading .NET ${DOTNET_VERSION} runtime...`); + console.log( + `Downloading .NET ${DOTNET_VERSION}-${platform}-${runnerArch} runtime...` + ); if (!fs.existsSync(DOTNET_RUNTIME_DIR)) { fs.mkdirSync(DOTNET_RUNTIME_DIR, { recursive: true }); diff --git a/src-electron/patch-node-api-dotnet.js b/src-electron/patch-node-api-dotnet.js index 1c9bc028..0c247e43 100644 --- a/src-electron/patch-node-api-dotnet.js +++ b/src-electron/patch-node-api-dotnet.js @@ -43,6 +43,9 @@ switch (process.platform) { platformName = 'linux'; break; } +if (process.arch === 'arm64') { + platformName += '-arm64'; +} const postBuildPath = path.join( __dirname, `./../build/${platformName}-unpacked/resources/app.asar.unpacked/node_modules/node-api-dotnet/init.js`