From bf4e413764fac93dba7431879d75393f736e2444 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 21:14:12 +0100 Subject: [PATCH 01/11] Improve hak & build ia32 again by default --- scripts/hak/copy.ts | 1 + scripts/hak/hakEnv.ts | 14 +++++--------- scripts/hak/index.ts | 8 ++++---- scripts/hak/target.ts | 1 + 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/scripts/hak/copy.ts b/scripts/hak/copy.ts index 4d3141867..3494f621c 100644 --- a/scripts/hak/copy.ts +++ b/scripts/hak/copy.ts @@ -31,6 +31,7 @@ export default async function copy(hakEnv: HakEnv, moduleInfo: DependencyInfo): // (and if you set glob.cwd it just breaks because it can't find the files) const oldCwd = process.cwd(); try { + await mkdirp(moduleInfo.moduleOutDir); process.chdir(moduleInfo.moduleOutDir); await new Promise((resolve, reject) => { rimraf(moduleInfo.cfg.prune, {}, err => { diff --git a/scripts/hak/hakEnv.ts b/scripts/hak/hakEnv.ts index 004446b26..61f836a3c 100644 --- a/scripts/hak/hakEnv.ts +++ b/scripts/hak/hakEnv.ts @@ -36,25 +36,21 @@ async function getRuntimeVersion(projectRoot: string): Promise { } export default class HakEnv { - public target: Target; - public projectRoot: string; + public readonly target: Target; public runtime: string; public runtimeVersion: string; public dotHakDir: string; - constructor(prefix: string, targetId: TargetId) { - let target; + constructor(public readonly projectRoot: string, targetId: TargetId | null) { if (targetId) { - target = TARGETS[targetId]; + this.target = TARGETS[targetId]; } else { - target = getHost(); + this.target = getHost(); } - if (!target) { + if (!this.target) { throw new Error(`Unknown target ${targetId}!`); } - this.target = target; - this.projectRoot = prefix; this.dotHakDir = path.join(this.projectRoot, '.hak'); } diff --git a/scripts/hak/index.ts b/scripts/hak/index.ts index afe678b7b..f65d92f42 100644 --- a/scripts/hak/index.ts +++ b/scripts/hak/index.ts @@ -61,7 +61,7 @@ async function main() { process.exit(1); } - const targetIds = [] as TargetId[]; + const targetIds: TargetId[] = []; // Apply `--target ` option if specified // Can be specified multiple times for the copy command to bundle // multiple archs into a single universal output module) @@ -84,13 +84,13 @@ async function main() { } const hakEnv = hakEnvs[0]; - const deps = {} as Record; + const deps: Record = {}; const hakDepsCfg = packageJson.hakDependencies || {}; for (const dep of Object.keys(hakDepsCfg)) { const hakJsonPath = path.join(prefix, 'hak', dep, 'hak.json'); - let hakJson; + let hakJson: Record; try { hakJson = await require(hakJsonPath); } catch (e) { @@ -125,7 +125,7 @@ async function main() { } } - let cmds; + let cmds: string[]; if (process.argv.length < 3) { cmds = ['check', 'fetch', 'fetchDeps', 'build', 'copy', 'link']; } else if (METACOMMANDS[process.argv[2]]) { diff --git a/scripts/hak/target.ts b/scripts/hak/target.ts index 50554faba..f56822de9 100644 --- a/scripts/hak/target.ts +++ b/scripts/hak/target.ts @@ -108,6 +108,7 @@ export const ENABLED_TARGETS: Target[] = [ TARGETS['universal-apple-darwin'], TARGETS['x86_64-unknown-linux-gnu'], TARGETS['x86_64-pc-windows-msvc'], + TARGETS['i686-pc-windows-msvc'], ]; export function getHost(): Target { From 10e2475a6ff38c0ebc8773f05a01d393a7051ea3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 21:30:20 +0100 Subject: [PATCH 02/11] Test both x86_64 and i686 in CI --- .github/workflows/build.yaml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f1ead7c6e..11aebdb44 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,10 +5,16 @@ on: branches: [ develop, master ] jobs: windows: - name: Windows + strategy: + matrix: + include: + - target: x86_64-pc-windows-msvc + - target: i686-pc-windows-msvc + build-args: --ia32 + name: Windows (${{ matrix.target }}) runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Cache .hak uses: actions/cache@v3 @@ -41,6 +47,7 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: stable + target: ${{ matrix.target }} - uses: actions/setup-node@v3 with: @@ -54,16 +61,16 @@ jobs: shell: pwsh run: | refreshenv - yarn build:native + yarn build:native --target ${{ matrix.target }} - name: Build App - run: "yarn build --publish never" + run: "yarn build --publish never -w ${{ matrix.build-args }}" linux: name: Linux runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Cache .hak uses: actions/cache@v3 @@ -95,7 +102,7 @@ jobs: name: macOS runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Cache .hak uses: actions/cache@v3 From 4571aa7fd60b2c414ba1771f704111efb27c19ae Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 21:31:48 +0100 Subject: [PATCH 03/11] Improve macOS job name --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 11aebdb44..3624f13c3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -99,7 +99,7 @@ jobs: run: "yarn build --publish never" macos: - name: macOS + name: macOS (universal) runs-on: macos-latest steps: - uses: actions/checkout@v3 From 81ea52e38644b8eba479ad855ad79932b1c0a966 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 21:53:36 +0100 Subject: [PATCH 04/11] Try other things --- .github/workflows/build.yaml | 10 +++++++--- scripts/hak/target.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3624f13c3..324479a3a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,7 +9,9 @@ jobs: matrix: include: - target: x86_64-pc-windows-msvc + arch: x64 - target: i686-pc-windows-msvc + arch: x86 build-args: --ia32 name: Windows (${{ matrix.target }}) runs-on: windows-latest @@ -26,9 +28,6 @@ jobs: - name: Install nmake uses: ilammy/msvc-dev-cmd@v1 - - name: Install Microsoft Build Tools - uses: microsoft/setup-msbuild@v1.1 - # ActiveTCL package on choco is from 2015, # this one is newer but includes more than we need - name: Choco install tclsh @@ -57,6 +56,11 @@ jobs: - name: Install Deps run: "yarn install --pure-lockfile" + - name: Set up Visual Studio shell + uses: egor-tensin/vs-shell@v2 + with: + arch: ${{ matrix.arch }} + - name: Build Natives shell: pwsh run: | diff --git a/scripts/hak/target.ts b/scripts/hak/target.ts index f56822de9..3f7bd8393 100644 --- a/scripts/hak/target.ts +++ b/scripts/hak/target.ts @@ -104,7 +104,7 @@ export const TARGETS: Record = { // The set of targets we build by default, sorted by increasing complexity so // that we fail fast when the native host target fails. -export const ENABLED_TARGETS: Target[] = [ +export const DEFAULT_TARGETS: Target[] = [ TARGETS['universal-apple-darwin'], TARGETS['x86_64-unknown-linux-gnu'], TARGETS['x86_64-pc-windows-msvc'], From 8476b751e32a4916fa53751998473bceca96f914 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 22:07:57 +0100 Subject: [PATCH 05/11] Iterating this is no fun --- .github/workflows/build.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 324479a3a..d339bf0f5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,11 +9,11 @@ jobs: matrix: include: - target: x86_64-pc-windows-msvc - arch: x64 + arch: amd64 - target: i686-pc-windows-msvc arch: x86 build-args: --ia32 - name: Windows (${{ matrix.target }}) + name: Windows (${{ matrix.arch }}) runs-on: windows-latest steps: - uses: actions/checkout@v3 @@ -56,15 +56,11 @@ jobs: - name: Install Deps run: "yarn install --pure-lockfile" - - name: Set up Visual Studio shell - uses: egor-tensin/vs-shell@v2 - with: - arch: ${{ matrix.arch }} - - name: Build Natives shell: pwsh run: | refreshenv + "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch }} yarn build:native --target ${{ matrix.target }} - name: Build App From 4f6f916375b009c41d54e22a33ff91868c277488 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 22:13:10 +0100 Subject: [PATCH 06/11] Attempt again --- .github/workflows/build.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d339bf0f5..609285ada 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -57,10 +57,9 @@ jobs: run: "yarn install --pure-lockfile" - name: Build Natives - shell: pwsh run: | refreshenv - "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch }} + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch }} yarn build:native --target ${{ matrix.target }} - name: Build App From f9d35a3c93ee39f847ff98d327d98c95481e6eec Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 22:19:49 +0100 Subject: [PATCH 07/11] pwsh is the default, use cmd --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 609285ada..1683eace8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -57,6 +57,7 @@ jobs: run: "yarn install --pure-lockfile" - name: Build Natives + shell: cmd run: | refreshenv call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch }} From 72712611bb6b781287a9ff2b91d6ea05738ac7fe Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 22:23:01 +0100 Subject: [PATCH 08/11] Update the incantation for 2022 --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1683eace8..975af0786 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -60,7 +60,7 @@ jobs: shell: cmd run: | refreshenv - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch }} + call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch }} yarn build:native --target ${{ matrix.target }} - name: Build App From a0e470666c300bbc4c54b26ffa69e3c0ecf4ef53 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 22:30:20 +0100 Subject: [PATCH 09/11] Avoid warning multiple times --- scripts/electron_afterSign.js | 4 +++- scripts/electron_winSign.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/electron_afterSign.js b/scripts/electron_afterSign.js index 100a4c704..6373b2f58 100644 --- a/scripts/electron_afterSign.js +++ b/scripts/electron_afterSign.js @@ -1,5 +1,6 @@ const { notarize } = require('electron-notarize'); +let warned = false; exports.default = async function(context) { const { electronPlatformName, appOutDir } = context; const appId = context.packager.info.appInfo.id; @@ -10,11 +11,12 @@ exports.default = async function(context) { // user IDs too, but apparently altool can't get the user ID // from the keychain, so we need to get it from the environment. const userId = process.env.NOTARIZE_APPLE_ID; - if (userId === undefined) { + if (userId === undefined && !warned) { console.log("*************************************"); console.log("* NOTARIZE_APPLE_ID is not set. *"); console.log("* This build will NOT be notarised. *"); console.log("*************************************"); + warned = true; return; } diff --git a/scripts/electron_winSign.js b/scripts/electron_winSign.js index 361a10228..408b9d885 100644 --- a/scripts/electron_winSign.js +++ b/scripts/electron_winSign.js @@ -46,15 +46,17 @@ function computeSignToolArgs(options, keyContainer) { return args; } +let warned = false; exports.default = async function(options) { const keyContainer = process.env.SIGNING_KEY_CONTAINER; - if (keyContainer === undefined) { + if (keyContainer === undefined && !warned) { console.warn( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" + "! Skipping Windows signing. !\n" + "! SIGNING_KEY_CONTAINER not defined. !\n" + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", ); + warned = true; return; } From 4ef796b284d887d3d93c50a3d98882a749795938 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 22:30:34 +0100 Subject: [PATCH 10/11] Consolidate build tool setup --- .github/workflows/build.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 975af0786..36bc30909 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,7 +9,7 @@ jobs: matrix: include: - target: x86_64-pc-windows-msvc - arch: amd64 + arch: x64 - target: i686-pc-windows-msvc arch: x86 build-args: --ia32 @@ -25,8 +25,10 @@ jobs: path: | ./.hak - - name: Install nmake + - name: Set up build tools uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} # ActiveTCL package on choco is from 2015, # this one is newer but includes more than we need @@ -57,10 +59,8 @@ jobs: run: "yarn install --pure-lockfile" - name: Build Natives - shell: cmd run: | refreshenv - call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch }} yarn build:native --target ${{ matrix.target }} - name: Build App From eb663cede797ff767e368f3f1436814557cb5ecf Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 May 2022 22:43:33 +0100 Subject: [PATCH 11/11] Move default targets to electron-builder and fix warnings --- scripts/electron_afterSign.js | 14 ++++++++------ scripts/electron_winSign.js | 18 ++++++++++-------- scripts/hak/target.ts | 12 +++--------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/scripts/electron_afterSign.js b/scripts/electron_afterSign.js index 6373b2f58..f79e37e46 100644 --- a/scripts/electron_afterSign.js +++ b/scripts/electron_afterSign.js @@ -11,12 +11,14 @@ exports.default = async function(context) { // user IDs too, but apparently altool can't get the user ID // from the keychain, so we need to get it from the environment. const userId = process.env.NOTARIZE_APPLE_ID; - if (userId === undefined && !warned) { - console.log("*************************************"); - console.log("* NOTARIZE_APPLE_ID is not set. *"); - console.log("* This build will NOT be notarised. *"); - console.log("*************************************"); - warned = true; + if (userId === undefined) { + if (!warned) { + console.log("*************************************"); + console.log("* NOTARIZE_APPLE_ID is not set. *"); + console.log("* This build will NOT be notarised. *"); + console.log("*************************************"); + warned = true; + } return; } diff --git a/scripts/electron_winSign.js b/scripts/electron_winSign.js index 408b9d885..e56843e15 100644 --- a/scripts/electron_winSign.js +++ b/scripts/electron_winSign.js @@ -49,14 +49,16 @@ function computeSignToolArgs(options, keyContainer) { let warned = false; exports.default = async function(options) { const keyContainer = process.env.SIGNING_KEY_CONTAINER; - if (keyContainer === undefined && !warned) { - console.warn( - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" + - "! Skipping Windows signing. !\n" + - "! SIGNING_KEY_CONTAINER not defined. !\n" + - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", - ); - warned = true; + if (keyContainer === undefined) { + if (!warned) { + console.warn( + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" + + "! Skipping Windows signing. !\n" + + "! SIGNING_KEY_CONTAINER not defined. !\n" + + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", + ); + warned = true; + } return; } diff --git a/scripts/hak/target.ts b/scripts/hak/target.ts index 3f7bd8393..7970bb3eb 100644 --- a/scripts/hak/target.ts +++ b/scripts/hak/target.ts @@ -94,23 +94,17 @@ const x8664UnknownLinuxGnu: Target = { }; export const TARGETS: Record = { + // macOS 'aarch64-apple-darwin': aarch64AppleDarwin, 'x86_64-apple-darwin': x8664AppleDarwin, 'universal-apple-darwin': universalAppleDarwin, + // Windows 'i686-pc-windows-msvc': i686PcWindowsMsvc, 'x86_64-pc-windows-msvc': x8664PcWindowsMsvc, + // Linux 'x86_64-unknown-linux-gnu': x8664UnknownLinuxGnu, }; -// The set of targets we build by default, sorted by increasing complexity so -// that we fail fast when the native host target fails. -export const DEFAULT_TARGETS: Target[] = [ - TARGETS['universal-apple-darwin'], - TARGETS['x86_64-unknown-linux-gnu'], - TARGETS['x86_64-pc-windows-msvc'], - TARGETS['i686-pc-windows-msvc'], -]; - export function getHost(): Target { return Object.values(TARGETS).find(target => ( target.platform === process.platform &&