Skip to content

Commit cb669fe

Browse files
committed
dx: support building desktop on win
1 parent 8583673 commit cb669fe

3 files changed

Lines changed: 38 additions & 8 deletions

File tree

docs/getting-started.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ In the explanations below, we will constantly refer to "development" and "target
2020
- If your target OS is **iOS**, only **macOS** computers are supported
2121
- If your target OS is **Android**, only **Linux and macOS** computers are supported
2222
- _No Windows support_ so far, unfortunately; but you can always choose to install Linux for free if you have a Windows computer
23-
- If your target is **desktop**, **Linux and macOS** computers are supported
23+
- If your target is **desktop**, then **Linux**, **macOS** and **Windows** computers are supported
2424

2525
### Development Container
2626

@@ -60,6 +60,17 @@ The paragraph below is commented out because we use --no-rust for all iOS compil
6060
6161
️ **macOS Big Sur is not supported!** Manyverse only builds on macOS Catalina or older versions. This is because Apple made significant changes to how linking dynamic libraries work, and most non-Apple tooling (which we depend on) hasn't updated yet. For more information, read [issue 1371](https://gitlab.com/staltz/manyverse/-/issues/1371). You may have luck if you compile the backend without Rust, using `npm run build-backend-ios -- --no-rust` (read more about that some sections below). -->
6262

63+
### Windows specifics
64+
65+
If you are developing Manyverse desktop on a Windows computer, then we recommend [choco](https://chocolatey.org/) to install the required tools.
66+
67+
Then make sure you run the following commands to install the required tools for building Node.js native addons:
68+
69+
- `choco install python3`
70+
- `choco install visualstudio2017-workload-nodebuildtools`
71+
- `npm i -g windows-build-tools`
72+
73+
6374
### Node.js
6475

6576
Use node (preferably exactly) **`16.17.x`** and npm `8.x`. To manage node versions easily, we recommend [nvm](https://github.com/nvm-sh/nvm) and use its deep integration feature to install and load the required node version automatically.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"prebuild-desktop-release-macos": "cd desktop && cross-env DEBUG=electron-builder electron-builder install-app-deps --platform=darwin",
4242
"build-desktop-release-macos": "electron-builder build --config desktop/electron-builder.config.js --macos --publish $EB_PUBLISH",
4343
"clean-desktop-prebuilds": "rimraf ./desktop/node_modules/**/{bufferutil,sodium-native,leveldown,utf-8-validate}/{build,prebuilds}",
44-
"desktop": "cd desktop && MANYVERSE_DEVELOPMENT=1 npm run electron",
45-
"desktop-debug": "cd desktop && MANYVERSE_DEVELOPMENT=1 npm run debug-electron",
44+
"desktop": "cd desktop && cross-env MANYVERSE_DEVELOPMENT=1 npm run electron",
45+
"desktop-debug": "cd desktop && cross-env MANYVERSE_DEVELOPMENT=1 npm run debug-electron",
4646
"start": "npm run lib && npm run propagate-replacements && react-native start",
4747
"psdr": "./tools/print-service-desk-report.js",
4848
"report-libraries": "./tools/report-libraries.mjs",

tools/build-backend.mjs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
import util from 'util';
88
import ora from 'ora';
99
import childProcess from 'child_process';
10+
import {createRequire} from 'module';
11+
const require = createRequire(import.meta.url);
12+
13+
const fsExtra = require('fs-extra');
1014

1115
const exec = util.promisify(childProcess.exec);
1216
const loading = ora('...').start();
@@ -101,7 +105,6 @@ async function runAndReport(label, task) {
101105
}),
102106
);
103107
} else {
104-
105108
await runAndReport(
106109
'Apply patches to node modules',
107110
exec('npm run apply-patches', {
@@ -113,9 +116,13 @@ async function runAndReport(label, task) {
113116
if (targetPlatform === 'desktop') {
114117
await runAndReport(
115118
'Update package-lock.json in ./src/backend',
116-
exec(
117-
'cp ./desktop/package-lock.json ' + './src/backend/package-lock.json',
118-
),
119+
// Use fs-extra to support Windows
120+
fsExtra
121+
.copy('./desktop/package-lock.json', './src/backend/package-lock.json')
122+
.then(
123+
() => ({stdout: '', stderr: ''}),
124+
() => ({stdout: '', stderr: 'Failed to copy package-lock.json'}),
125+
),
119126
);
120127
} else {
121128
await runAndReport(
@@ -188,7 +195,19 @@ async function runAndReport(label, task) {
188195
if (targetPlatform === 'desktop') {
189196
await runAndReport(
190197
'Remove patches from the desktop folder',
191-
exec('rm -rf ./desktop/patches &&' + 'rm ./desktop/package-lock.json'),
198+
// Use fs-extra to support Windows
199+
fsExtra.rmdir('./desktop/patches', {recursive: true}).then(
200+
() => ({stdout: '', stderr: ''}),
201+
() => ({stdout: '', stderr: 'Failed to remove patches folder'}),
202+
),
203+
);
204+
await runAndReport(
205+
'Remove package-lock.json from the desktop folder',
206+
// Use fs-extra to support Windows
207+
fsExtra.rm('./desktop/package-lock.json').then(
208+
() => ({stdout: '', stderr: ''}),
209+
() => ({stdout: '', stderr: 'Failed to remove package-lock.json'}),
210+
),
192211
);
193212
}
194213
})();

0 commit comments

Comments
 (0)