Skip to content

Commit 1429c00

Browse files
committed
Try making a universal build for Mac
Github has effectively deprecated Intel Mac so we need to find other solutions.
1 parent a11e8a9 commit 1429c00

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ jobs:
3333
- {
3434
name: "macOS Latest Clang",
3535
os: macos-latest,
36-
artifact: darwin-arm64,
37-
}
38-
- {
39-
name: "macOS Intel?",
40-
os: macos-13,
41-
artifact: darwin-x64,
36+
artifact: darwin-universal,
4237
}
4338

4439
steps:

build/build.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async function compile() {
3838
async function createProject() {
3939
await processThenRestoreCWD(async () => {
4040
process.env.DEPOT_TOOLS_WIN_TOOLCHAIN = '0'
41+
//process.env.DEPOT_TOOLS_UPDATE = '0'
4142
process.chdir(kDawnPath);
4243
fs.copyFileSync('scripts/standalone-with-node.gclient', '.gclient');
4344
await execute('gclient', ['metrics', '--opt-out']);
@@ -54,6 +55,7 @@ async function createProject() {
5455
'-DDAWN_BUILD_NODE_BINDINGS=1',
5556
'-DDAWN_USE_X11=OFF',
5657
`-DCMAKE_BUILD_TYPE=${kConfig}`,
58+
...addElemIf(isMac, '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"'),
5759
...addElemIf(isWin, '-DCMAKE_SYSTEM_VERSION=10.0.26100.0'),
5860
...addElemIf(isMac, '-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk'),
5961
]);
@@ -71,7 +73,8 @@ async function copyResult(filepath, target) {
7173
async function main() {
7274
const compileOnly = process.argv[2] === '--compile-only';
7375
try {
74-
const target = `${process.platform}-${process.arch}`;
76+
const arch = isMac ? 'universal' : process.arch;
77+
const target = `${process.platform}-${arch}`;
7578
console.log('building for:', target);
7679
if (!compileOnly) {
7780
await execute('git', ['submodule', 'update', '--init']);

build/postinstall.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import path from 'node:path';
2+
import fs from 'node:fs';
3+
4+
import {execute} from './execute.js';
5+
import {isMac} from './constants.js';
6+
7+
async function main() {
8+
if (isMac) {
9+
// The user has already indicated they trust this by installing it,
10+
// This executable can not do anything a JavaScript node script couldn't also do.
11+
await execute('xattr', ['-d', 'com.apple.quarantine', 'dist/darwin-universal.dawn.node']);
12+
}
13+
}
14+
15+
main();

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { dirname, join } from 'node:path';
22
import { fileURLToPath } from 'node:url';
33
import { createRequire } from 'module';
44
const require = createRequire(import.meta.url);
5+
export const isMac = process.platform === 'darwin';
56

67
const __dirname = dirname(fileURLToPath(import.meta.url));
7-
const dawnNodePath = join(__dirname, 'dist', `${process.platform}-${process.arch}.dawn.node`);
8+
const arch = isMac ? 'universal' : process.arch;
9+
const dawnNodePath = join(__dirname, 'dist', `${process.platform}-${arch}.dawn.node`);
810
const { create, globals } = require(dawnNodePath);
911
export { create, globals }

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build": "node build/build.js",
1010
"compile": "node build/build.js --compile-only",
1111
"cts": "node build/run-cts.js",
12+
"postinstall": "node build/postinstall.js",
1213
"test": "node test/test.js",
1314
"update": "node build/update.js"
1415
},

0 commit comments

Comments
 (0)