From 5a95e8a0769bbc7991222cf9cf7870dc6b43d94a Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Fri, 30 Oct 2026 03:43:48 -0500 Subject: [PATCH] Compile scr_intl.c with the ICU headers in the COMMON-symbol test common-symbols.test.ts compiles every runtime source with the vendored include paths only. scr_intl.c includes ICU's C API headers, which the runtime pack build takes from the fetched ICU release, so on a host without system ICU headers both of the test's compiles failed with "'unicode/ubrk.h' file not found", and the aarch64-macos compile failed on every host. The test now passes the same source/common and source/i18n include paths for scr_intl.c, through icu-data.mjs's ensureIcuSources. --- packages/runtime/test/common-symbols.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/runtime/test/common-symbols.test.ts b/packages/runtime/test/common-symbols.test.ts index 344bd01d6..33930c2a4 100644 --- a/packages/runtime/test/common-symbols.test.ts +++ b/packages/runtime/test/common-symbols.test.ts @@ -2,6 +2,7 @@ import { execFile, spawnSync } from "node:child_process"; import { mkdir, readdir, readFile } from "node:fs/promises"; import { availableParallelism } from "node:os"; import { join } from "node:path"; +import { pathToFileURL } from "node:url"; import { promisify } from "node:util"; import { expect, test } from "vitest"; @@ -10,6 +11,19 @@ const testDir = import.meta.dirname; const srcDir = join(testDir, "../src"); const vendorDir = join(testDir, "../vendor"); const buildDir = join(testDir, "build", "common-symbols"); +const repoRoot = join(testDir, "../../.."); + +/** scr_intl.c includes ICU's C API headers from the fetched ICU release, as + * the runtime pack build compiles it (runtime-pack-common's icu-data.mjs). */ +async function icuIncludeFlags(): Promise { + const { ensureIcuSources } = (await import( + pathToFileURL(join(repoRoot, "packages/runtime-pack-common/scripts/icu-data.mjs")).href + )) as { ensureIcuSources: (cacheDir: string) => Promise }; + const root = await ensureIcuSources( + join(repoRoot, "node_modules", ".cache", "scriptc-icu-sources"), + ); + return ["-I", join(root, "source", "common"), "-I", join(root, "source", "i18n")]; +} /** COMMON globals in every runtime source compiled with `compiler`, in the * plain and worker configurations, as "file (defines): symbol" lines. */ @@ -22,6 +36,7 @@ async function commonSymbols(label: string, compiler: string[]): Promise [[], ["-DSCR_WORKERS"]].map((defines) => ({ name, defines })), ); + const icu = await icuIncludeFlags(); const common: string[] = []; let next = 0; const worker = async (): Promise => { @@ -39,6 +54,7 @@ async function commonSymbols(label: string, compiler: string[]): Promise