mirror of
https://github.com/noodlapp/noodl.git
synced 2026-01-12 07:12:52 +01:00
Initial commit
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { build, Platform } from 'electron-builder';
|
||||
import { BuildTarget } from './build-platforms';
|
||||
|
||||
const config = require('../package.json').build;
|
||||
|
||||
function createTarget(buildTarget: BuildTarget) {
|
||||
switch (buildTarget.platform) {
|
||||
case 'darwin':
|
||||
return Platform.MAC.createTarget(undefined, buildTarget.arch as any);
|
||||
|
||||
case 'win32':
|
||||
return Platform.WINDOWS.createTarget();
|
||||
|
||||
case 'linux':
|
||||
return Platform.LINUX.createTarget(undefined, buildTarget.arch as any);
|
||||
|
||||
default:
|
||||
const targetName = `${buildTarget.platform}-${buildTarget.arch}`;
|
||||
throw 'Unsupported platform: ' + targetName;
|
||||
}
|
||||
}
|
||||
|
||||
export function execElectronBuilder(buildTarget: BuildTarget) {
|
||||
return build({
|
||||
targets: createTarget(buildTarget),
|
||||
config
|
||||
});
|
||||
}
|
||||
45
packages/noodl-editor/scripts/platform/build-platforms.ts
Normal file
45
packages/noodl-editor/scripts/platform/build-platforms.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { ArchType } from 'builder-util';
|
||||
|
||||
export interface BuildTarget {
|
||||
platform: NodeJS.Platform;
|
||||
arch: ArchType;
|
||||
}
|
||||
|
||||
export function isGitHubActions() {
|
||||
return process.env.GITHUB_ACTIONS === 'true';
|
||||
}
|
||||
|
||||
export function getDistArchitecture(): 'arm64' | 'x64' {
|
||||
// If a specific npm_config_arch is set, we use that one instead of the OS arch (to support cross compilation)
|
||||
if (process.env.npm_config_arch === 'arm64' || process.env.npm_config_arch === 'x64') {
|
||||
return process.env.npm_config_arch;
|
||||
}
|
||||
|
||||
if (process.arch === 'arm64') {
|
||||
return 'arm64';
|
||||
}
|
||||
|
||||
// TODO: Check if it's x64 running on an arm64 Windows with IsWow64Process2
|
||||
// More info: https://www.rudyhuyn.com/blog/2017/12/13/how-to-detect-that-your-x86-application-runs-on-windows-on-arm/
|
||||
// Right now (March 3, 2021) is not very important because support for x64
|
||||
// apps on an arm64 Windows is experimental. See:
|
||||
// https://blogs.windows.com/windows-insider/2020/12/10/introducing-x64-emulation-in-preview-for-windows-10-on-arm-pcs-to-the-windows-insider-program/
|
||||
|
||||
return 'x64';
|
||||
}
|
||||
|
||||
export function getDistPlatform(targetPlatform: string): 'win' | 'linux' | 'mac' {
|
||||
if (targetPlatform === 'win32') {
|
||||
return 'win';
|
||||
}
|
||||
|
||||
if (targetPlatform === 'linux') {
|
||||
return 'linux';
|
||||
}
|
||||
|
||||
if (targetPlatform === 'darwin') {
|
||||
return 'mac';
|
||||
}
|
||||
|
||||
throw new Error(`Unsupported platform: ${targetPlatform}`);
|
||||
}
|
||||
Reference in New Issue
Block a user