From 96beff8970a25b529b4caf7b2a6d5d9d2260e0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Tue, 18 Jun 2024 17:05:44 +0200 Subject: [PATCH] Use platform conditions for SQLite3 syslib Instead of conditionals, which won't work in cross compiles. --- Makefile | 4 +++- Package@swift-5.10.swift | 37 ++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 3fa37e5..03f2890 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,9 @@ CONFIGURATION=debug DOCKER=/usr/local/bin/docker # docker config (5.6.1 seems the first w/ aarch64) -SWIFT_BUILD_IMAGE="swift:5.6.2-focal" +#SWIFT_BUILD_IMAGE="swift:5.6.2-focal" +#SWIFT_BUILD_IMAGE=swift:5.9.0-focal +SWIFT_BUILD_IMAGE=swift:5.10.1-noble DOCKER_BUILD_DIR=".docker$(SWIFT_BUILD_DIR)" SWIFT_DOCKER_BUILD_DIR="$(DOCKER_BUILD_DIR)/aarch64-unknown-linux/$(CONFIGURATION)" DOCKER_BUILD_PRODUCT="$(DOCKER_BUILD_DIR)/$(TOOL_NAME)" diff --git a/Package@swift-5.10.swift b/Package@swift-5.10.swift index 235a6ce..0dea94c 100644 --- a/Package@swift-5.10.swift +++ b/Package@swift-5.10.swift @@ -27,14 +27,32 @@ var package = Package( ], targets: [ + .systemLibrary(name: "SQLite3", + path: "Sources/SQLite3-Linux", + providers: [ .apt(["libsqlite3-dev"]) ]), + // A small library used to fetch schema information from SQLite3 databases. - .target(name: "SQLite3Schema", exclude: [ "README.md" ]), + .target(name: "SQLite3Schema", + dependencies: [ + .target(name: "SQLite3", + condition: .when(platforms: [ + .linux, .android, .windows, .openbsd + ])), + ], + exclude: [ "README.md" ]), // Lighter is a shared lib providing common protocols used by Enlighter // generated models and such. // Note that Lighter isn't that useful w/o code generation (i.e. as a // standalone lib). - .target(name: "Lighter", swiftSettings: settings), + .target(name: "Lighter", + dependencies: [ + .target(name: "SQLite3", + condition: .when(platforms: [ + .linux, .android, .windows, .openbsd + ])), + ], + swiftSettings: settings), // MARK: - Plugin Support @@ -124,18 +142,3 @@ var package = Package( dependencies: [ "LighterGeneration" ]) ] ) - -#if !(os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) -package.products += [ .library(name: "SQLite3", targets: [ "SQLite3" ]) ] -package.targets += [ - .systemLibrary(name: "SQLite3", - path: "Sources/SQLite3-Linux", - providers: [ .apt(["libsqlite3-dev"]) ]) -] -package.targets - .first(where: { $0.name == "SQLite3Schema" })? - .dependencies.append("SQLite3") -package.targets - .first(where: { $0.name == "Lighter" })? - .dependencies.append("SQLite3") -#endif // not-Darwin