-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathdawn.ts
More file actions
136 lines (122 loc) · 3.87 KB
/
dawn.ts
File metadata and controls
136 lines (122 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* eslint-disable camelcase */
import { chdir } from "process";
import type { Platform } from "./dawn-configuration";
import { $, mapKeys } from "./util";
import {
build,
checkBuildArtifacts,
copyHeaders,
copyLib,
libs,
projectRoot,
} from "./dawn-configuration";
const commonArgs = {
CMAKE_BUILD_TYPE: "Release",
BUILD_SAMPLES: "OFF",
TINT_BUILD_TESTS: "OFF",
TINT_BUILD_CMD_TOOLS: "OFF",
TINT_BUILD_IR_BINARY: "OFF",
DAWN_BUILD_SAMPLES: "OFF",
DAWN_USE_GLFW: "OFF",
DAWN_FETCH_DEPENDENCIES: "ON",
DAWN_ENABLE_DESKTOP_GL: "OFF",
BUILD_SHARED_LIBS: "OFF",
};
const PLATFORM_MAP: Record<string, string> = {
arm64_iphoneos: "OS64",
arm64_iphonesimulator: "SIMULATORARM64",
x86_64_iphonesimulator: "SIMULATOR64",
arm64_xros: "VISIONOS",
arm64_xrsimulator: "SIMULATOR_VISIONOS",
x86_64_xrsimulator: "SIMULATOR64_VISIONOS",
universal_macosx: "MAC_UNIVERSAL",
};
const android = {
platforms: ["arm64-v8a", "armeabi-v7a", "x86", "x86_64"] as Platform[],
args: {
CMAKE_TOOLCHAIN_FILE: "$ANDROID_NDK/build/cmake/android.toolchain.cmake",
ANDROID_PLATFORM: "android-26",
DAWN_ENABLE_OPENGLES: "ON",
DAWN_BUILD_MONOLITHIC_LIBRARY: "SHARED",
CMAKE_EXE_LINKER_FLAGS: "-llog",
CMAKE_SHARED_LINKER_FLAGS: "-llog",
...commonArgs,
},
};
const apple = {
matrix: {
arm64: ["iphoneos", "iphonesimulator", "xros", "xrsimulator"],
x86_64: ["iphonesimulator"],
universal: ["macosx"],
},
args: {
CMAKE_TOOLCHAIN_FILE: `${__dirname}/apple.toolchain.cmake`,
DAWN_ENABLE_OPENGLES: "OFF",
DAWN_BUILD_MONOLITHIC_LIBRARY: "STATIC",
// -DPLATFORM=OS64 -DDEPLOYMENT_TARGET=13.0 -DENABLE_BITCODE=OFF -DENABLE_ARC=OFF -DENABLE_VISIBILITY=OFF
...commonArgs,
},
};
(async () => {
process.chdir("../..");
// Build Android
for (const platform of android.platforms) {
console.log(`Build Android: ${platform}`);
await build(
`android_${platform}`,
{
ANDROID_ABI: platform,
...android.args,
},
`🤖 ${platform}`,
);
copyLib("android", platform);
}
// Build Apple
for (const platform of mapKeys(apple.matrix)) {
console.log(`Build Apple: ${platform}`);
for (const sdk of apple.matrix[platform]) {
await build(
`apple_${platform}_${sdk}`,
{
PLATFORM: PLATFORM_MAP[`${platform}_${sdk}`],
...apple.args,
},
`🍏 ${platform} ${sdk}`,
);
copyLib("apple", platform, sdk);
}
}
$(`mkdir -p ${projectRoot}/libs/apple/iphonesimulator`);
libs.forEach((lib) => {
console.log(`📱 Building fat binary for iphone simulator: ${lib}`);
$(
`lipo -create ${projectRoot}/libs/apple/x86_64_iphonesimulator/${lib}.a ${projectRoot}/libs/apple/arm64_iphonesimulator/${lib}.a -output ${projectRoot}/libs/apple/iphonesimulator/${lib}.a`,
);
});
libs.forEach((lib) => {
console.log(`📱 Building ${lib} (XCFramework) for iOS, visionOS and macOS`);
$(`rm -rf ${projectRoot}/libs/apple/${lib}.xcframework`);
$(
"xcodebuild -create-xcframework " +
`-library ${projectRoot}/libs/apple/iphonesimulator/${lib}.a ` +
`-library ${projectRoot}/libs/apple/arm64_iphoneos/${lib}.a ` +
`-library ${projectRoot}/libs/apple/arm64_xros/${lib}.a ` +
`-library ${projectRoot}/libs/apple/arm64_xrsimulator/${lib}.a ` +
`-library ${projectRoot}/libs/apple/universal_macosx/${lib}.a ` +
` -output ${projectRoot}/libs/apple/${lib}.xcframework `,
);
// Remove intermediate libraries
$(
"rm -rf " +
`${projectRoot}/libs/apple/iphonesimulator` +
`${projectRoot}/libs/apple/arm64_iphoneos` +
`${projectRoot}/libs/apple/arm64_xros` +
`${projectRoot}/libs/apple/arm64_xrsimulator` +
`${projectRoot}/libs/apple/universal_macosx`,
);
});
copyHeaders();
chdir(projectRoot);
checkBuildArtifacts();
})();