forked from Cocoanetics/SwiftScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.swift
More file actions
100 lines (99 loc) · 4.2 KB
/
Package.swift
File metadata and controls
100 lines (99 loc) · 4.2 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
// swift-tools-version:6.0
import PackageDescription
let package = Package(
name: "SwiftScript",
platforms: [
.macOS("26.0"),
.iOS("26.0"),
],
products: [
.library(name: "SwiftScriptAST", targets: ["SwiftScriptAST"]),
.library(name: "SwiftScriptInterpreter", targets: ["SwiftScriptInterpreter"]),
// Distributed as a dynamic library so a stock-`swift` script can
// pick it up via `-I .build/.../debug -L ... -lMathExtras`. The
// SwiftScript interpreter recognizes `import MathExtras` and
// registers the equivalent functions in its bridge table, so the
// same source runs under both runtimes.
.library(name: "MathExtras", type: .dynamic, targets: ["MathExtras"]),
.executable(name: "swift-script", targets: ["swift-script"]),
],
dependencies: [
.package(url: "https://github.com/swiftlang/swift-syntax", from: "603.0.0"),
],
targets: [
.target(
name: "SwiftScriptAST",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax"),
.product(name: "SwiftOperators", package: "swift-syntax"),
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
.product(name: "SwiftParserDiagnostics", package: "swift-syntax"),
],
path: "Sources/SwiftScriptAST"
),
.target(
name: "SwiftScriptInterpreter",
dependencies: [
"SwiftScriptAST",
.product(name: "SwiftSyntax", package: "swift-syntax"),
],
path: "Sources/SwiftScriptInterpreter"
),
.executableTarget(
name: "swift-script",
dependencies: [
"SwiftScriptInterpreter",
],
path: "Sources/swift-script"
),
// Real Swift module — same source signature as the interpreter's
// `MathExtras` bridge, so `import MathExtras` resolves under both
// stock `swift` (linked dylib) and `swift-script` (interpreter
// bridge).
.target(
name: "MathExtras",
path: "Sources/MathExtras",
swiftSettings: [
// Embed a LC_LINKER_OPTION autolink record into the
// .swiftmodule so a consumer that does `import MathExtras`
// also auto-links `libMathExtras` — without this, stock
// `swift script.swift` (which uses JIT) finds the module
// but fails to resolve the symbols at run time.
.unsafeFlags([
"-Xfrontend", "-public-autolink-library",
"-Xfrontend", "MathExtras",
]),
]
),
// Generator: reads `swift-symbolgraph-extract` JSON, filters by an
// allowlist + value-shaped signature predicate, emits Swift bridge
// code that registers boxing/unboxing wrappers with the interpreter.
// Run manually for now; future SwiftPM build plugin will invoke
// this on every clean build.
.executableTarget(
name: "BridgeGeneratorTool",
dependencies: [],
path: "Sources/BridgeGeneratorTool"
),
// Walks a swift-corelibs-foundation source tree (or any other
// Swift package) and emits the public-member set as a flat
// text file. The bridge generator consumes that file to
// classify each Apple-side bridge as cross-platform vs Apple-
// only, eliminating the hand-curated Apple/Linux gating files.
// Run via `Tools/regen-foundation-bridge.sh`.
.executableTarget(
name: "SCLSymbolExtractor",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax"),
],
path: "Sources/SCLSymbolExtractor"
),
.testTarget(
name: "SwiftScriptInterpreterTests",
dependencies: ["SwiftScriptInterpreter", "SwiftScriptAST"],
path: "Tests/SwiftScriptInterpreterTests"
),
]
)