nomen-lang 0.5.0 → 0.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nomen-lang",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "The CLI for the Nomen programming language.",
5
5
  "keywords": [],
6
6
  "license": "ISC",
package/src/test.ts CHANGED
@@ -3,7 +3,7 @@ import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
- import build from "../../src/build.ts";
6
+ import build, { default_platform } from "../../src/build.ts";
7
7
  import join from "../../src/join.ts";
8
8
  import { get_library } from "../../src/lib.ts";
9
9
  import parse from "../../src/parse.ts";
@@ -329,7 +329,12 @@ export function run_test_file(
329
329
  audit_obj = path.join(buildDir, "audit_runtime.o");
330
330
  execFileSync("clang", ["-c", runtime_src, "-o", audit_obj]);
331
331
  }
332
- const ext = arch === "aarch64" ? ".s" : ".c";
332
+ const platform = default_platform();
333
+ // Match the run/build command's emission: ObjC-bearing sources (GUI code
334
+ // pulled in through the library graph) must land in a `.m` TU on Apple
335
+ // platforms — the ObjC framework headers are Objective-C, and including
336
+ // them from a plain `.c` TU fails with `@class NSString` syntax errors.
337
+ const ext = arch === "aarch64" ? ".s" : platform === "macos" || platform === "ios" ? ".m" : ".c";
333
338
  const codefile = path.join(buildDir, path.basename(entry_path, ".nm") + ext);
334
339
  const outfile = path.join(buildDir, path.basename(entry_path, ".nm"));
335
340
  // The C backend's generated source does `#include "main.h"`, so write the
@@ -337,10 +342,23 @@ export function run_test_file(
337
342
  fs.writeFileSync(path.join(buildDir, "main.h"), buildResult.headers ?? "");
338
343
  fs.writeFileSync(codefile, buildResult.code);
339
344
 
340
- // Link the harness binary. The harness uses only Console/Time (printf,
341
- // clock_gettime), so no platform frameworks are required.
345
+ // Link the harness binary. Frameworks are passed on Apple platforms for
346
+ // the same reason as the run/build command: the joined source may reference
347
+ // ObjC runtime symbols even when the test body doesn't, and unused
348
+ // frameworks cost nothing at link time.
342
349
  const link_args = ["-o", outfile, codefile];
343
350
  if (audit_obj) link_args.push(audit_obj);
351
+ if (platform === "macos" || platform === "ios") {
352
+ link_args.push(
353
+ "-framework",
354
+ "CoreGraphics",
355
+ "-framework",
356
+ "Foundation",
357
+ "-framework",
358
+ "AppKit",
359
+ "-lobjc",
360
+ );
361
+ }
344
362
  try {
345
363
  execFileSync("clang", link_args, {
346
364
  encoding: "utf8",