Skip to content

Commit f1f659b

Browse files
authored
Improve hak & build ia32 again by default (#369)
* Improve hak & build ia32 again by default * Test both x86_64 and i686 in CI * Improve macOS job name * Try other things * Iterating this is no fun * Attempt again * pwsh is the default, use cmd * Update the incantation for 2022 * Avoid warning multiple times * Consolidate build tool setup * Move default targets to electron-builder and fix warnings
1 parent ec62b8b commit f1f659b

File tree

7 files changed

+50
-43
lines changed

7 files changed

+50
-43
lines changed

.github/workflows/build.yaml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ on:
55
branches: [ develop, master ]
66
jobs:
77
windows:
8-
name: Windows
8+
strategy:
9+
matrix:
10+
include:
11+
- target: x86_64-pc-windows-msvc
12+
arch: x64
13+
- target: i686-pc-windows-msvc
14+
arch: x86
15+
build-args: --ia32
16+
name: Windows (${{ matrix.arch }})
917
runs-on: windows-latest
1018
steps:
11-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
1220

1321
- name: Cache .hak
1422
uses: actions/cache@v3
@@ -17,11 +25,10 @@ jobs:
1725
path: |
1826
./.hak
1927
20-
- name: Install nmake
28+
- name: Set up build tools
2129
uses: ilammy/msvc-dev-cmd@v1
22-
23-
- name: Install Microsoft Build Tools
24-
uses: microsoft/[email protected]
30+
with:
31+
arch: ${{ matrix.arch }}
2532

2633
# ActiveTCL package on choco is from 2015,
2734
# this one is newer but includes more than we need
@@ -41,6 +48,7 @@ jobs:
4148
uses: actions-rs/toolchain@v1
4249
with:
4350
toolchain: stable
51+
target: ${{ matrix.target }}
4452

4553
- uses: actions/setup-node@v3
4654
with:
@@ -51,19 +59,18 @@ jobs:
5159
run: "yarn install --pure-lockfile"
5260

5361
- name: Build Natives
54-
shell: pwsh
5562
run: |
5663
refreshenv
57-
yarn build:native
64+
yarn build:native --target ${{ matrix.target }}
5865
5966
- name: Build App
60-
run: "yarn build --publish never"
67+
run: "yarn build --publish never -w ${{ matrix.build-args }}"
6168

6269
linux:
6370
name: Linux
6471
runs-on: ubuntu-latest
6572
steps:
66-
- uses: actions/checkout@v2
73+
- uses: actions/checkout@v3
6774

6875
- name: Cache .hak
6976
uses: actions/cache@v3
@@ -92,10 +99,10 @@ jobs:
9299
run: "yarn build --publish never"
93100

94101
macos:
95-
name: macOS
102+
name: macOS (universal)
96103
runs-on: macos-latest
97104
steps:
98-
- uses: actions/checkout@v2
105+
- uses: actions/checkout@v3
99106

100107
- name: Cache .hak
101108
uses: actions/cache@v3

scripts/electron_afterSign.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { notarize } = require('electron-notarize');
22

3+
let warned = false;
34
exports.default = async function(context) {
45
const { electronPlatformName, appOutDir } = context;
56
const appId = context.packager.info.appInfo.id;
@@ -11,10 +12,13 @@ exports.default = async function(context) {
1112
// from the keychain, so we need to get it from the environment.
1213
const userId = process.env.NOTARIZE_APPLE_ID;
1314
if (userId === undefined) {
14-
console.log("*************************************");
15-
console.log("* NOTARIZE_APPLE_ID is not set. *");
16-
console.log("* This build will NOT be notarised. *");
17-
console.log("*************************************");
15+
if (!warned) {
16+
console.log("*************************************");
17+
console.log("* NOTARIZE_APPLE_ID is not set. *");
18+
console.log("* This build will NOT be notarised. *");
19+
console.log("*************************************");
20+
warned = true;
21+
}
1822
return;
1923
}
2024

scripts/electron_winSign.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,19 @@ function computeSignToolArgs(options, keyContainer) {
4646
return args;
4747
}
4848

49+
let warned = false;
4950
exports.default = async function(options) {
5051
const keyContainer = process.env.SIGNING_KEY_CONTAINER;
5152
if (keyContainer === undefined) {
52-
console.warn(
53-
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +
54-
"! Skipping Windows signing. !\n" +
55-
"! SIGNING_KEY_CONTAINER not defined. !\n" +
56-
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
57-
);
53+
if (!warned) {
54+
console.warn(
55+
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +
56+
"! Skipping Windows signing. !\n" +
57+
"! SIGNING_KEY_CONTAINER not defined. !\n" +
58+
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
59+
);
60+
warned = true;
61+
}
5862
return;
5963
}
6064

scripts/hak/copy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default async function copy(hakEnv: HakEnv, moduleInfo: DependencyInfo):
3131
// (and if you set glob.cwd it just breaks because it can't find the files)
3232
const oldCwd = process.cwd();
3333
try {
34+
await mkdirp(moduleInfo.moduleOutDir);
3435
process.chdir(moduleInfo.moduleOutDir);
3536
await new Promise<void>((resolve, reject) => {
3637
rimraf(moduleInfo.cfg.prune, {}, err => {

scripts/hak/hakEnv.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,21 @@ async function getRuntimeVersion(projectRoot: string): Promise<string> {
3636
}
3737

3838
export default class HakEnv {
39-
public target: Target;
40-
public projectRoot: string;
39+
public readonly target: Target;
4140
public runtime: string;
4241
public runtimeVersion: string;
4342
public dotHakDir: string;
4443

45-
constructor(prefix: string, targetId: TargetId) {
46-
let target;
44+
constructor(public readonly projectRoot: string, targetId: TargetId | null) {
4745
if (targetId) {
48-
target = TARGETS[targetId];
46+
this.target = TARGETS[targetId];
4947
} else {
50-
target = getHost();
48+
this.target = getHost();
5149
}
5250

53-
if (!target) {
51+
if (!this.target) {
5452
throw new Error(`Unknown target ${targetId}!`);
5553
}
56-
this.target = target;
57-
this.projectRoot = prefix;
5854
this.dotHakDir = path.join(this.projectRoot, '.hak');
5955
}
6056

scripts/hak/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async function main() {
6161
process.exit(1);
6262
}
6363

64-
const targetIds = [] as TargetId[];
64+
const targetIds: TargetId[] = [];
6565
// Apply `--target <target>` option if specified
6666
// Can be specified multiple times for the copy command to bundle
6767
// multiple archs into a single universal output module)
@@ -84,13 +84,13 @@ async function main() {
8484
}
8585
const hakEnv = hakEnvs[0];
8686

87-
const deps = {} as Record<string, DependencyInfo>;
87+
const deps: Record<string, DependencyInfo> = {};
8888

8989
const hakDepsCfg = packageJson.hakDependencies || {};
9090

9191
for (const dep of Object.keys(hakDepsCfg)) {
9292
const hakJsonPath = path.join(prefix, 'hak', dep, 'hak.json');
93-
let hakJson;
93+
let hakJson: Record<string, any>;
9494
try {
9595
hakJson = await require(hakJsonPath);
9696
} catch (e) {
@@ -125,7 +125,7 @@ async function main() {
125125
}
126126
}
127127

128-
let cmds;
128+
let cmds: string[];
129129
if (process.argv.length < 3) {
130130
cmds = ['check', 'fetch', 'fetchDeps', 'build', 'copy', 'link'];
131131
} else if (METACOMMANDS[process.argv[2]]) {

scripts/hak/target.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,17 @@ const x8664UnknownLinuxGnu: Target = {
9494
};
9595

9696
export const TARGETS: Record<TargetId, Target> = {
97+
// macOS
9798
'aarch64-apple-darwin': aarch64AppleDarwin,
9899
'x86_64-apple-darwin': x8664AppleDarwin,
99100
'universal-apple-darwin': universalAppleDarwin,
101+
// Windows
100102
'i686-pc-windows-msvc': i686PcWindowsMsvc,
101103
'x86_64-pc-windows-msvc': x8664PcWindowsMsvc,
104+
// Linux
102105
'x86_64-unknown-linux-gnu': x8664UnknownLinuxGnu,
103106
};
104107

105-
// The set of targets we build by default, sorted by increasing complexity so
106-
// that we fail fast when the native host target fails.
107-
export const ENABLED_TARGETS: Target[] = [
108-
TARGETS['universal-apple-darwin'],
109-
TARGETS['x86_64-unknown-linux-gnu'],
110-
TARGETS['x86_64-pc-windows-msvc'],
111-
];
112-
113108
export function getHost(): Target {
114109
return Object.values(TARGETS).find(target => (
115110
target.platform === process.platform &&

0 commit comments

Comments
 (0)