Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download and use MSYS/make locally for Windows postinstall #792

Merged
merged 24 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion npm-scripts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const process = require('process');
const os = require('os');
const fs = require('fs');
const { execSync } = require('child_process');
const { execSync, spawnSync } = require('child_process');
const { version } = require('./package.json');

const isFreeBSD = os.platform() === 'freebsd';
Expand Down Expand Up @@ -120,13 +120,34 @@ switch (task)
{
if (!process.env.MEDIASOUP_WORKER_BIN)
{
if (isWindows)
nazar-pc marked this conversation as resolved.
Show resolved Hide resolved
{
var res = spawnSync('where', [ 'python3.exe' ]);
if (res.status !== 0)
{
res = spawnSync('where', [ 'python.exe' ]);
if (res.status !== 0)
{
console.log('Cannot find Python executable.');
process.exit(1);
}
}
execute(String(res.stdout).trim() + ' worker\\scripts\\getmake.py');
process.env['PATH'] = process.cwd() + '\\worker\\out\\msys\\bin;' + process.env['PATH'];
}

execute('node npm-scripts.js worker:build');
// Clean build artifacts except `mediasoup-worker`.
execute(`${MAKE} clean-build -C worker`);
// Clean downloaded dependencies.
execute(`${MAKE} clean-subprojects -C worker`);
// Clean PIP/Meson/Ninja.
execute(`${MAKE} clean-pip -C worker`);

if (isWindows)
{
execute('rd /s /q worker\\out\\msys');
}
}

break;
Expand Down
17 changes: 17 additions & 0 deletions worker/scripts/getmake.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import io, hashlib, tarfile, urllib.request

def get(url, sha1):
nazar-pc marked this conversation as resolved.
Show resolved Hide resolved
data = urllib.request.urlopen(url).read()
assert hashlib.sha1(data).hexdigest() == sha1
tar = tarfile.open(fileobj=io.BytesIO(data))
tar.extractall('worker/out/msys')
tar.close()

get('https://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.19-1/msysCORE-1.0.19-1-msys-1.0.19-bin.tar.xz/download', '9200450ad3df8c83be323c9b14ae344d5c1ca784')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/libiconv/libiconv-1.14-1/libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma/download', '056d16bfb7a91c3e3b1acf8adb20edea6fceecdd')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/gettext/gettext-0.18.1.1-1/libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma/download', '4000b935a5bc30b4c757fde69d27716fa3c2c269')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/coreutils-5.97-3/coreutils-5.97-3-msys-1.0.13-bin.tar.lzma/download', '54ac256a8f0c6a89f1b3c7758f3703b4e56382be')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/regex/regex-1.20090805-2/libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma/download', 'd95faa144cf06625b3932a8e84ed1a6ab6bbe644')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/termcap/termcap-0.20050421_1-2/libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma/download', 'e4273ccfde8ecf3a7631446fb2b01971a24ff9f7')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/bash/bash-3.1.23-1/bash-3.1.23-1-msys-1.0.18-bin.tar.xz/download', 'b6ef3399b8d76b5fbbd0a88774ebc2a90e8af13a')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/make/make-3.81-3/make-3.81-3-msys-1.0.13-bin.tar.lzma/download', 'c7264eb13b05cf2e1a982a3c2619837b96203a27')