diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f1ead7c..36bc309 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 diff --git a/scripts/electron_afterSign.js b/scripts/electron_afterSign.js index 100a4c7..f79e37e 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; @@ -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; } diff --git a/scripts/electron_winSign.js b/scripts/electron_winSign.js index 361a102..e56843e 100644 --- a/scripts/electron_winSign.js +++ b/scripts/electron_winSign.js @@ -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; } diff --git a/scripts/hak/copy.ts b/scripts/hak/copy.ts index 4d31418..3494f62 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 004446b..61f836a 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 afe678b..f65d92f 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 50554fa..7970bb3 100644 --- a/scripts/hak/target.ts +++ b/scripts/hak/target.ts @@ -94,22 +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 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 &&