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
This commit is contained in:
Michael Telatynski 2022-05-26 23:05:59 +01:00 committed by GitHub
parent ec62b8b2cf
commit f1f659b6a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 43 deletions

View File

@ -5,10 +5,18 @@ on:
branches: [ develop, master ]
jobs:
windows:
name: Windows
strategy:
matrix:
include:
- target: x86_64-pc-windows-msvc
arch: x64
- target: i686-pc-windows-msvc
arch: x86
build-args: --ia32
name: Windows (${{ matrix.arch }})
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Cache .hak
uses: actions/cache@v3
@ -17,11 +25,10 @@ jobs:
path: |
./.hak
- name: Install nmake
- name: Set up build tools
uses: ilammy/msvc-dev-cmd@v1
- name: Install Microsoft Build Tools
uses: microsoft/setup-msbuild@v1.1
with:
arch: ${{ matrix.arch }}
# ActiveTCL package on choco is from 2015,
# this one is newer but includes more than we need
@ -41,6 +48,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: actions/setup-node@v3
with:
@ -51,19 +59,18 @@ jobs:
run: "yarn install --pure-lockfile"
- name: Build Natives
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
@ -92,10 +99,10 @@ jobs:
run: "yarn build --publish never"
macos:
name: macOS
name: macOS (universal)
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Cache .hak
uses: actions/cache@v3

View File

@ -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;
@ -11,10 +12,13 @@ exports.default = async function(context) {
// from the keychain, so we need to get it from the environment.
const userId = process.env.NOTARIZE_APPLE_ID;
if (userId === undefined) {
console.log("*************************************");
console.log("* NOTARIZE_APPLE_ID is not set. *");
console.log("* This build will NOT be notarised. *");
console.log("*************************************");
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;
}

View File

@ -46,15 +46,19 @@ function computeSignToolArgs(options, keyContainer) {
return args;
}
let warned = false;
exports.default = async function(options) {
const keyContainer = process.env.SIGNING_KEY_CONTAINER;
if (keyContainer === undefined) {
console.warn(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +
"! Skipping Windows signing. !\n" +
"! SIGNING_KEY_CONTAINER not defined. !\n" +
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
);
if (!warned) {
console.warn(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +
"! Skipping Windows signing. !\n" +
"! SIGNING_KEY_CONTAINER not defined. !\n" +
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
);
warned = true;
}
return;
}

View File

@ -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<void>((resolve, reject) => {
rimraf(moduleInfo.cfg.prune, {}, err => {

View File

@ -36,25 +36,21 @@ async function getRuntimeVersion(projectRoot: string): Promise<string> {
}
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');
}

View File

@ -61,7 +61,7 @@ async function main() {
process.exit(1);
}
const targetIds = [] as TargetId[];
const targetIds: TargetId[] = [];
// Apply `--target <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<string, DependencyInfo>;
const deps: Record<string, DependencyInfo> = {};
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<string, any>;
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]]) {

View File

@ -94,22 +94,17 @@ const x8664UnknownLinuxGnu: Target = {
};
export const TARGETS: Record<TargetId, Target> = {
// 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 ENABLED_TARGETS: Target[] = [
TARGETS['universal-apple-darwin'],
TARGETS['x86_64-unknown-linux-gnu'],
TARGETS['x86_64-pc-windows-msvc'],
];
export function getHost(): Target {
return Object.values(TARGETS).find(target => (
target.platform === process.platform &&