serve-sim 0.1.44-beta.99.3 → 0.1.44

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.swift CHANGED
@@ -23,7 +23,7 @@ let package = Package(
23
23
  .library(
24
24
  name: "serve-sim-native",
25
25
  type: .dynamic,
26
- targets: ["SimNativeModule"]
26
+ targets: ["SimNative"]
27
27
  ),
28
28
  ],
29
29
  dependencies: [
@@ -31,40 +31,19 @@ let package = Package(
31
31
  ],
32
32
  targets: [
33
33
  .target(
34
- name: "SimNativeModule",
34
+ name: "SimNative",
35
35
  dependencies: [
36
36
  .product(name: "NodeAPI", package: "node-swift"),
37
37
  .product(name: "NodeModuleSupport", package: "node-swift"),
38
38
  ],
39
- path: "Sources",
40
- // Sibling targets built by their own build.sh (Obj-C/ObjC++), not
41
- // part of this SwiftPM package.
42
39
  exclude: [
43
- "SimCameraInjector",
44
- "SimCameraHelper",
45
- "SimAXSettings",
46
- "SimNative/build.sh",
47
- ],
48
- sources: [
49
- "SimNative/sim-module.swift",
50
- "SimNative/sim-capture.swift",
51
- "SimStreamHelper/HIDInjector.swift",
52
- "SimStreamHelper/FrameCapture.swift",
53
- "SimStreamHelper/VideoEncoder.swift",
54
- "SimStreamHelper/H264Encoder.swift",
55
- "SimStreamHelper/StreamFormat.swift",
56
- "SimStreamHelper/AccessibilityBridge.swift",
57
- "SimStreamHelper/SimFrameworks.swift",
58
- "SimStreamHelper/Xcode.swift",
40
+ "build.sh",
59
41
  ],
60
42
  linkerSettings: [
61
- .linkedFramework("CoreVideo"),
62
- .linkedFramework("CoreMedia"),
63
- .linkedFramework("IOSurface"),
64
- .linkedFramework("CoreGraphics"),
65
- .linkedFramework("VideoToolbox"),
66
- .linkedFramework("ImageIO"),
67
- .linkedFramework("AppKit"),
43
+ .unsafeFlags([
44
+ "-Xlinker", "-undefined",
45
+ "-Xlinker", "dynamic_lookup",
46
+ ])
68
47
  ]
69
48
  ),
70
49
  ],
@@ -3,15 +3,11 @@
3
3
  # spawned serve-sim-bin helper. The JS bindings are written in Swift with
4
4
  # node-swift (see ../../Package.swift and sim-module.swift).
5
5
  #
6
- # Host-arch only (arm64 on Apple Silicon / CI). We use a plain `swift build`,
7
- # i.e. the NATIVE SwiftPM build system, because that is the only mode that
8
- # resolves node-swift's #NodeModule macro plugin: both `--arch X --arch Y`
9
- # (universal) and `--triple <other-arch>` force Xcode's XCBuild, which fails to
10
- # resolve the NodeAPIMacros plugin on stock toolchains ("missing target
11
- # NodeAPIMacros" / "unable to resolve module SwiftSyntax"). Cross-compiling the
12
- # x86_64 slice would therefore require an x86_64-native toolchain (Rosetta),
13
- # which isn't available everywhere; serve-sim targets Apple Silicon. napi_* stay
14
- # undefined and resolve against the host (Node/Bun) at dlopen via
6
+ # We opt into the new `swiftbuild` build system, because it supports building universal
7
+ # binaries with macros, which neither the legacy `native` build system nor the
8
+ # perennially-janky legacy `xcode` build system had support for.
9
+ #
10
+ # napi_* stay undefined and resolve against the host (Node/Bun) at dlopen via
15
11
  # `-undefined dynamic_lookup`.
16
12
  set -euo pipefail
17
13
  HERE="$(cd "$(dirname "$0")" && pwd)"
@@ -26,25 +22,23 @@ if [ ! -d "$PKG/node_modules/node-swift" ]; then
26
22
  exit 1
27
23
  fi
28
24
 
29
- swift build \
30
- -c release \
31
- --product "$PRODUCT" \
32
- --package-path "$PKG" \
33
- --build-path "$BUILD_DIR" \
34
- -Xlinker -undefined -Xlinker dynamic_lookup
35
-
36
- # `-print -quit` (not `| head`): under `pipefail`, head closing the pipe early
37
- # would SIGPIPE find and fail the script. Match by name rather than a fixed
38
- # subpath: the product dir varies by toolchain (native SwiftPM emits
39
- # .build/release/, the Xcode build system emits .build/out/Products/Release/).
40
- DYLIB="$(find "$BUILD_DIR" -name "lib${PRODUCT}.dylib" -type f -not -path '*.dSYM*' -print -quit)"
41
- if [ -z "$DYLIB" ]; then
42
- echo "Build succeeded but lib${PRODUCT}.dylib was not found under $BUILD_DIR" >&2
25
+ build_flags=(
26
+ -c release
27
+ --product "$PRODUCT"
28
+ --package-path "$PKG"
29
+ --build-path "$BUILD_DIR"
30
+ --build-system swiftbuild
31
+ )
32
+ swift build "${build_flags[@]}" >&2
33
+ DYLIB="$(swift build --show-bin-path "${build_flags[@]}")/lib${PRODUCT}.dylib"
34
+ if [ ! -f "$DYLIB" ]; then
35
+ echo "Expected build product not found at $DYLIB" >&2
43
36
  exit 1
44
37
  fi
45
38
 
46
39
  OUT="$OUT_DIR/${PRODUCT}.node"
47
- cp "$DYLIB" "$OUT"
40
+ cp -a "$DYLIB" "$OUT"
41
+ strip -x "$OUT"
48
42
  codesign -s - -f "$OUT" 2>/dev/null || true
49
43
 
50
44
  echo "Built: $OUT"