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

Improve hak & build ia32 again by default #369

Merged
merged 11 commits into from
May 26, 2022
31 changes: 19 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -41,6 +48,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}

- uses: actions/setup-node@v3
with:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions scripts/electron_afterSign.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}

Expand Down
16 changes: 10 additions & 6 deletions scripts/electron_winSign.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions scripts/hak/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
14 changes: 5 additions & 9 deletions scripts/hak/hakEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
8 changes: 4 additions & 4 deletions scripts/hak/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down Expand Up @@ -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]]) {
Expand Down
11 changes: 3 additions & 8 deletions scripts/hak/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down