peachsim 0.1.2179 → 0.1.2182
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/package.ts +7 -2
- package/cli/commands/shell-url.ts +28 -22
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +225 -85
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +2 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +140 -48
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +201 -82
- package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +4 -4
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +11 -3
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +2 -2
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +53 -53
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +239 -176
- package/dist-lib/swift-compile.cjs +85 -16
- package/dist-lib/swift-compile.mjs +85 -16
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +87 -18
- package/dist-lib/vite.cjs +4 -4
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/cli-companion.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/ios/frame-art.d.ts +41 -0
- package/dist-types/packages/peach-engine/src/ios/frame-paint.d.ts +43 -0
- package/dist-types/packages/peach-engine/src/ios/frame-svg.d.ts +4 -0
- package/dist-types/packages/peach-engine/src/render-worker/map-command-channel.d.ts +14 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIScrollView.h +8 -25
- package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +26 -0
- package/src/expo-native-workspace.ts +17 -20
- package/src/expo-swift-bundle.ts +6 -1
- package/src/expo-swift-host.ts +35 -6
- package/src/expo-widgets-bundle.ts +12 -8
- package/src/expoSwiftContract.ts +3 -0
- package/src/kotlin-host.ts +10 -2
- package/src/native-bundles.ts +30 -10
- package/src/one-sdk/source.ts +10 -4
- package/src/one-sdk-bundle.ts +57 -24
- package/src/screenshots/frame-compose.ts +14 -109
- package/src/swift-compile.ts +105 -13
- package/src/swift-submit.ts +2 -1
- package/src/wasm-optimize.ts +13 -4
package/src/swift-compile.ts
CHANGED
|
@@ -1791,6 +1791,32 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1791
1791
|
const linkedObjects = Boolean(distribution || prebuilt)
|
|
1792
1792
|
const cxxFlagsFor = (flags: readonly string[]): readonly string[] =>
|
|
1793
1793
|
args.deferDarwinOverlay ? withoutWasmOverlayIsystem(flags) : flags
|
|
1794
|
+
// swiftpm writes the module map of a target with no swift sources, so an
|
|
1795
|
+
// installed pod's map of that module (a prebuilt React Native core target
|
|
1796
|
+
// the app's pods also list) would define it twice. a swift target imports
|
|
1797
|
+
// its underlying objective-c module through the pod's map and keeps it.
|
|
1798
|
+
const packageModules = new Set(
|
|
1799
|
+
targets
|
|
1800
|
+
.filter(({ name }) => !args.sourceSwiftTargets?.has(name))
|
|
1801
|
+
.map(({ name }) => swiftTargetModuleName(name)),
|
|
1802
|
+
)
|
|
1803
|
+
const mapsPackageModule = (flag: string): boolean => {
|
|
1804
|
+
if (!flag.startsWith('-fmodule-map-file=')) return false
|
|
1805
|
+
const file = flag
|
|
1806
|
+
.slice('-fmodule-map-file='.length)
|
|
1807
|
+
.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root)
|
|
1808
|
+
if (!file.includes('/Pods/Headers/')) return false
|
|
1809
|
+
const map =
|
|
1810
|
+
args.files.get(file) ?? (existsSync(file) ? readFileSync(file) : undefined)
|
|
1811
|
+
const name = map === undefined ? undefined : moduleMapName(map.toString())
|
|
1812
|
+
return name !== undefined && packageModules.has(name)
|
|
1813
|
+
}
|
|
1814
|
+
const withoutPackageModuleMaps = (flags: readonly string[]): string[] =>
|
|
1815
|
+
flags.filter((flag) => !mapsPackageModule(flag))
|
|
1816
|
+
const targetCFlags = (flags: readonly string[]) =>
|
|
1817
|
+
cFlagArray(withoutPackageModuleMaps(flags))
|
|
1818
|
+
const targetCxxFlags = (flags: readonly string[]) =>
|
|
1819
|
+
cxxFlagArray(withoutPackageModuleMaps(flags))
|
|
1794
1820
|
const reachedFrameworks = new Set<string>()
|
|
1795
1821
|
const reach = (name: string) => {
|
|
1796
1822
|
if (
|
|
@@ -1908,7 +1934,11 @@ export function emitSwiftPackageManifest(args: {
|
|
|
1908
1934
|
// swiftpm expands target settings into one command; large native import
|
|
1909
1935
|
// closures exceed exec's argument limit. keep their ordered bytes on disk.
|
|
1910
1936
|
const swiftFlagArray = (literal: string): string => {
|
|
1911
|
-
const flags: string[] = JSON.parse(literal.replace(/,\s*]$/, ']'))
|
|
1937
|
+
const flags: string[] = JSON.parse(literal.replace(/,\s*]$/, ']')).filter(
|
|
1938
|
+
(flag: string, index: number, all: string[]) =>
|
|
1939
|
+
!mapsPackageModule(flag) &&
|
|
1940
|
+
!(flag === '-Xcc' && mapsPackageModule(all[index + 1] ?? '')),
|
|
1941
|
+
)
|
|
1912
1942
|
const content = flags.map((flag) => JSON.stringify(flag)).join('\n') + '\n'
|
|
1913
1943
|
const digest = createHash('sha256').update(content).digest('hex')
|
|
1914
1944
|
const file = path.join(args.root, '.peach-swift-arguments', `${digest}.rsp`)
|
|
@@ -2182,7 +2212,7 @@ export function emitSwiftPackageManifest(args: {
|
|
|
2182
2212
|
.map((entry) => ` ${entry},`)
|
|
2183
2213
|
.join(
|
|
2184
2214
|
'',
|
|
2185
|
-
)} .unsafeFlags(${flagArray(
|
|
2215
|
+
)} .unsafeFlags(${flagArray(targetCFlags([...nativeFlags, ...native.clang.flags]))})]`,
|
|
2186
2216
|
...(nativeCxx
|
|
2187
2217
|
? [
|
|
2188
2218
|
`cxxSettings: [${cxxDefines}${clangSettingEntries(
|
|
@@ -2192,13 +2222,13 @@ export function emitSwiftPackageManifest(args: {
|
|
|
2192
2222
|
.map((entry) => ` ${entry},`)
|
|
2193
2223
|
.join(
|
|
2194
2224
|
'',
|
|
2195
|
-
)} .unsafeFlags(${flagArray(
|
|
2225
|
+
)} .unsafeFlags(${flagArray(targetCxxFlags([...cxxFlagsFor(nativeFlags), ...native.clang.cxxFlags]))})]`,
|
|
2196
2226
|
]
|
|
2197
2227
|
: []),
|
|
2198
2228
|
].join(', ')
|
|
2199
2229
|
: [
|
|
2200
|
-
`cSettings: [${cDefines}${declaredClangSettings(target, 'c')} .unsafeFlags(${flagArray(
|
|
2201
|
-
`cxxSettings: [${cxxDefines}${declaredClangSettings(target, 'cxx')} .unsafeFlags(${flagArray(
|
|
2230
|
+
`cSettings: [${cDefines}${declaredClangSettings(target, 'c')} .unsafeFlags(${flagArray(targetCFlags([...nativeFlags, ...(native?.flags ?? [])]))})]`,
|
|
2231
|
+
`cxxSettings: [${cxxDefines}${declaredClangSettings(target, 'cxx')} .unsafeFlags(${flagArray(targetCxxFlags([...cxxFlagsFor(nativeFlags), ...(native?.cxxFlags ?? [])]))})]`,
|
|
2202
2232
|
].join(', ')
|
|
2203
2233
|
const exclusions = native?.clang
|
|
2204
2234
|
? []
|
|
@@ -2287,10 +2317,10 @@ export function emitSwiftPackageManifest(args: {
|
|
|
2287
2317
|
` path: ${JSON.stringify(group.path)},`,
|
|
2288
2318
|
` sources: ${JSON.stringify(group.sources)},`,
|
|
2289
2319
|
` publicHeadersPath: ${JSON.stringify(native.groups ? 'include' : 'PeachSwiftImplementation')},`,
|
|
2290
|
-
` cSettings: [${macroSettings(owner?.cDefines)}${declaredClangSettings(owner, 'c')} .unsafeFlags(${flagArray(
|
|
2320
|
+
` cSettings: [${macroSettings(owner?.cDefines)}${declaredClangSettings(owner, 'c')} .unsafeFlags(${flagArray(targetCFlags([...nativeFlags, '-I', native.includeDirectory, ...(args.headerDirectory ? ['-I', args.headerDirectory] : []), ...group.flags]))})],`,
|
|
2291
2321
|
...(group.sources.some((source) => /\.(?:cc|cpp|cxx|mm)$/.test(source))
|
|
2292
2322
|
? [
|
|
2293
|
-
` cxxSettings: [${macroSettings(owner?.cxxDefines)}${declaredClangSettings(owner, 'cxx')} .unsafeFlags(${flagArray(
|
|
2323
|
+
` cxxSettings: [${macroSettings(owner?.cxxDefines)}${declaredClangSettings(owner, 'cxx')} .unsafeFlags(${flagArray(targetCxxFlags([...cxxFlagsFor(nativeFlags), '-I', native.includeDirectory, ...group.cxxFlags]))})]),`,
|
|
2294
2324
|
]
|
|
2295
2325
|
: [' ),']),
|
|
2296
2326
|
])
|
|
@@ -4300,7 +4330,11 @@ export function writeSwiftProject(
|
|
|
4300
4330
|
const target = bySourcePath.find(
|
|
4301
4331
|
(candidate) => candidate.path === '.' || file.startsWith(`${candidate.path}/`),
|
|
4302
4332
|
)
|
|
4303
|
-
|
|
4333
|
+
// swiftpm never compiles an excluded file (a prebuilt core's Swift)
|
|
4334
|
+
const excluded = target?.exclude?.some(
|
|
4335
|
+
(name) => file === path.posix.join(target.path, name),
|
|
4336
|
+
)
|
|
4337
|
+
if (target && !excluded) swiftTargets.add(target.name)
|
|
4304
4338
|
}
|
|
4305
4339
|
// swiftpm builds a clang target's module only for an importer: a swift
|
|
4306
4340
|
// import, or a framework-style include or @import in any original source.
|
|
@@ -5650,6 +5684,9 @@ export function writeSwiftProject(
|
|
|
5650
5684
|
frameworkLink,
|
|
5651
5685
|
[
|
|
5652
5686
|
...prebuilt.objects.map(quote),
|
|
5687
|
+
'-Wl,--start-lib',
|
|
5688
|
+
...prebuilt.lazyObjects.map(quote),
|
|
5689
|
+
'-Wl,--end-lib',
|
|
5653
5690
|
...darwinRecordsRegion(prebuilt.providers.map(quote)),
|
|
5654
5691
|
].join('\n') + '\n',
|
|
5655
5692
|
)
|
|
@@ -6016,7 +6053,7 @@ function readCompiledArtifact(
|
|
|
6016
6053
|
if (
|
|
6017
6054
|
createHash('sha256').update(bytes).digest('hex') !== receipt.wasm ||
|
|
6018
6055
|
createHash('sha256').update(gzip).digest('hex') !== receipt.icu ||
|
|
6019
|
-
bytes.length
|
|
6056
|
+
bytes.length <= 8 ||
|
|
6020
6057
|
bytes.readUInt32LE(0) !== 0x6d736100 ||
|
|
6021
6058
|
bytes.readUInt32LE(4) !== 1
|
|
6022
6059
|
)
|
|
@@ -6178,7 +6215,15 @@ function linkedFrameworkTargets(
|
|
|
6178
6215
|
)
|
|
6179
6216
|
const targets = compileTargets(input)
|
|
6180
6217
|
const planning = targets.length > 0 ? targets : [{ name: 'App', path: '.' }]
|
|
6181
|
-
|
|
6218
|
+
// a target's prebuilt library links the units its package excludes from
|
|
6219
|
+
// compilation (a React Native core), so their imports reach frameworks too
|
|
6220
|
+
const siblings = swiftTargetDependencies(
|
|
6221
|
+
input.files,
|
|
6222
|
+
planning.map((target) =>
|
|
6223
|
+
input.libraries?.[target.name] ? { ...target, exclude: [] } : target,
|
|
6224
|
+
),
|
|
6225
|
+
libraries.keys(),
|
|
6226
|
+
)
|
|
6182
6227
|
const reached = new Set<string>()
|
|
6183
6228
|
const reach = (name: string) => {
|
|
6184
6229
|
if (name === 'SwiftUI') return
|
|
@@ -6409,8 +6454,13 @@ function removeCaseCollidingModuleArtifacts(
|
|
|
6409
6454
|
|
|
6410
6455
|
/** a source checkout's framework build: what the app link reads from it. */
|
|
6411
6456
|
interface SwiftFrameworkProducts {
|
|
6457
|
+
/** the distribution-shaped root whose lib/ holds the framework objects */
|
|
6458
|
+
root: string
|
|
6412
6459
|
modules: string
|
|
6460
|
+
/** objects the link loads whole */
|
|
6413
6461
|
objects: string[]
|
|
6462
|
+
/** objects the link loads only for a symbol it resolves */
|
|
6463
|
+
lazyObjects: string[]
|
|
6414
6464
|
owners: Map<string, string>
|
|
6415
6465
|
/** the Darwin module's providers, linked as an archive ahead of the sdk's */
|
|
6416
6466
|
providers: string[]
|
|
@@ -6572,9 +6622,41 @@ async function buildFrameworkProducts(
|
|
|
6572
6622
|
.sort()
|
|
6573
6623
|
.map((file) => path.join(providerDir, file))
|
|
6574
6624
|
for (const provider of providers) linked.owners.set(provider, 'DarwinRecords')
|
|
6625
|
+
// the framework objects link as a distribution's do: under lib/ with the names
|
|
6626
|
+
// build-distribution.ts gives them, Objective-C roots whole and the rest as an
|
|
6627
|
+
// archive region the pruner trims (swift-wasm-prune.ts reads <root>/lib).
|
|
6628
|
+
// Darwin stays whole: a distribution leaves it to the sdk's image.
|
|
6629
|
+
const archive = path.join(scratch, 'lib')
|
|
6630
|
+
rmSync(archive, { recursive: true, force: true })
|
|
6631
|
+
mkdirSync(archive)
|
|
6632
|
+
const archived = new Map<string, string>()
|
|
6633
|
+
for (const object of objects) {
|
|
6634
|
+
const target = linked.owners.get(object)
|
|
6635
|
+
const dir = path.join(release, `${target}.build`)
|
|
6636
|
+
if (!target || target === 'Darwin' || !object.startsWith(dir + path.sep)) continue
|
|
6637
|
+
const name = `${target}-${path
|
|
6638
|
+
.relative(dir, object)
|
|
6639
|
+
.replaceAll(path.sep, '-')
|
|
6640
|
+
.replace(/\.swift\.o$/, '.o')}`
|
|
6641
|
+
symlinkSync(object, path.join(archive, name))
|
|
6642
|
+
archived.set(object, `lib/${name}`)
|
|
6643
|
+
}
|
|
6644
|
+
const roots = swiftObjcRootObjects(`${scratch}\n${args.frameworkKey}`, scratch, [
|
|
6645
|
+
...archived.values(),
|
|
6646
|
+
])
|
|
6647
|
+
const linkedObjects = objects.map((object) => {
|
|
6648
|
+
const name = archived.get(object)
|
|
6649
|
+
return name
|
|
6650
|
+
? { path: path.join(scratch, name), lazy: !roots.has(name) }
|
|
6651
|
+
: { path: object, lazy: false }
|
|
6652
|
+
})
|
|
6575
6653
|
return {
|
|
6654
|
+
root: scratch,
|
|
6576
6655
|
modules: path.join(release, 'Modules'),
|
|
6577
|
-
objects,
|
|
6656
|
+
objects: linkedObjects.filter((object) => !object.lazy).map((object) => object.path),
|
|
6657
|
+
lazyObjects: linkedObjects
|
|
6658
|
+
.filter((object) => object.lazy)
|
|
6659
|
+
.map((object) => object.path),
|
|
6578
6660
|
owners: linked.owners,
|
|
6579
6661
|
providers,
|
|
6580
6662
|
link,
|
|
@@ -6788,6 +6870,8 @@ function swiftLinkStamp(args: {
|
|
|
6788
6870
|
}
|
|
6789
6871
|
for (const object of args.prebuilt.objects)
|
|
6790
6872
|
hash.update(`object\n${object}\n${statOf(object)}`)
|
|
6873
|
+
for (const object of args.prebuilt.lazyObjects)
|
|
6874
|
+
hash.update(`lazy-object\n${object}\n${statOf(object)}`)
|
|
6791
6875
|
for (const object of args.prebuilt.providers)
|
|
6792
6876
|
hash.update(`provider\n${object}\n${statOf(object)}`)
|
|
6793
6877
|
for (const map of args.prebuilt.moduleMaps)
|
|
@@ -7302,7 +7386,7 @@ function compileSwiftProjectOnce(
|
|
|
7302
7386
|
pruneSwiftWasmLink(
|
|
7303
7387
|
root,
|
|
7304
7388
|
options.toolchainBin,
|
|
7305
|
-
frameworkRoot,
|
|
7389
|
+
prebuilt?.root ?? frameworkRoot,
|
|
7306
7390
|
input.staticClangTargets,
|
|
7307
7391
|
options.project,
|
|
7308
7392
|
undefined,
|
|
@@ -7328,11 +7412,19 @@ function compileSwiftProjectOnce(
|
|
|
7328
7412
|
optimized,
|
|
7329
7413
|
})
|
|
7330
7414
|
else if (input.optimize) await optimizeWasm(output, optimized)
|
|
7415
|
+
const executable = input.optimize ? optimized : output
|
|
7416
|
+
await runCompiler(
|
|
7417
|
+
path.join(options.toolchainBin, 'llvm-objcopy'),
|
|
7418
|
+
['--remove-section=.swift1_autolink_entries', executable],
|
|
7419
|
+
buildOptions,
|
|
7420
|
+
)
|
|
7331
7421
|
const artifact = {
|
|
7332
7422
|
hash,
|
|
7333
|
-
bytes: readFileSync(
|
|
7423
|
+
bytes: readFileSync(executable),
|
|
7334
7424
|
icu: await icu,
|
|
7335
7425
|
}
|
|
7426
|
+
if (artifact.bytes.length <= 8)
|
|
7427
|
+
throw new Error('swift-compile: deferred linker produced no executable')
|
|
7336
7428
|
if (!options.project) saveCompiledArtifact(root, artifact)
|
|
7337
7429
|
saveSharedArtifact(sharedRoot, artifact)
|
|
7338
7430
|
report('compiled artifact verified')
|
package/src/swift-submit.ts
CHANGED
|
@@ -146,7 +146,8 @@ export const MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024
|
|
|
146
146
|
// 68: fetch headers replies carry `setCookies`, the response's Set-Cookie list.
|
|
147
147
|
// 69: `peach.icu_item_v1` replaces `icu_data_v1`: the host fills icu's table of
|
|
148
148
|
// contents and places each item's pack the first time icu opens it.
|
|
149
|
-
|
|
149
|
+
// 70: full Objective-C forwarding uses exact typed IMPs (`peach.imp_forwarder_mint`).
|
|
150
|
+
export const SWIFT_HOST_ABI = 70
|
|
150
151
|
|
|
151
152
|
export interface SwiftImageUpload {
|
|
152
153
|
/** the raster file picked for the asset (has the extension). */
|
package/src/wasm-optimize.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { existsSync } from 'node:fs'
|
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
import { installVerifiedTarball } from '@contrast/runtime-delivery'
|
|
4
4
|
import { BINARYEN_VERSION, wasmOpt } from 'wasm-opt'
|
|
5
|
+
import { windowAdmission } from './admitted-mac-build'
|
|
5
6
|
import { rnxHomeDir } from './home-paths'
|
|
6
7
|
|
|
7
|
-
//
|
|
8
|
+
// packaged native executables, size-optimized. clang's own
|
|
8
9
|
// optimizer pass is off (-O0 on the link) so an edit never pays for it and the
|
|
9
10
|
// artifact never depends on the machine; this runs the pinned Binaryen once per
|
|
10
|
-
// cached artifact instead. the features are the ones the link declares
|
|
11
|
-
// pass drops the custom sections (autolink entries, producers) no host reads.
|
|
11
|
+
// cached artifact instead. the features are the ones the link declares.
|
|
12
12
|
const FEATURES = [
|
|
13
13
|
'threads',
|
|
14
14
|
'bulk-memory',
|
|
@@ -61,6 +61,15 @@ async function runWasmOpt(
|
|
|
61
61
|
skipPasses: readonly string[],
|
|
62
62
|
binary: string,
|
|
63
63
|
): Promise<void> {
|
|
64
|
+
const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES)
|
|
65
|
+
const requestedCores = Number(process.env.BINARYEN_CORES)
|
|
66
|
+
const environment: NodeJS.ProcessEnv = { ...process.env, WASM_OPT_PATH: binary }
|
|
67
|
+
if (Number.isInteger(admittedCores) && admittedCores > 0)
|
|
68
|
+
environment.BINARYEN_CORES = String(
|
|
69
|
+
Number.isInteger(requestedCores) && requestedCores > 0
|
|
70
|
+
? Math.min(admittedCores, requestedCores)
|
|
71
|
+
: admittedCores,
|
|
72
|
+
)
|
|
64
73
|
const result = await wasmOpt(
|
|
65
74
|
[
|
|
66
75
|
'-Oz',
|
|
@@ -70,7 +79,7 @@ async function runWasmOpt(
|
|
|
70
79
|
'-o',
|
|
71
80
|
output,
|
|
72
81
|
],
|
|
73
|
-
{ env:
|
|
82
|
+
{ env: environment },
|
|
74
83
|
)
|
|
75
84
|
if (result.status !== 0)
|
|
76
85
|
throw new Error(`wasm-opt exited ${result.status}: ${result.stderr}`)
|