Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:
WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: 1
steps:
- uses: actions/checkout@v4
- name: Install Cairo, FreeType, fontconfig and Wayland for Cacao, Mesa for GL, WPE WebKit, and GStreamer
- name: Install Cairo, FreeType, fontconfig and Wayland for Cacao, HarfBuzz for fonts, Mesa for GL, WPE WebKit, and GStreamer
run: |
apt-get update
apt-get install -y --no-install-recommends cmake ninja-build git libcairo2-dev libfreetype-dev \
libfontconfig-dev libwayland-dev wayland-protocols fonts-dejavu-core \
libfontconfig-dev libharfbuzz-dev libwayland-dev wayland-protocols fonts-dejavu-core \
libegl1 libegl-mesa0 libgles-dev libgl1-mesa-dri \
libwpewebkit-2.0-1 libwpebackend-fdo-1.0-1 libwayland-server0 \
libgstreamer1.0-0 libgstreamer-plugins-base1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Linux environment for building and testing the host: Swift 6.4.2 on
# Debian 13, SDL3, Cairo, FreeType, fontconfig and Wayland for Cacao, a font,
# HarfBuzz for fonts,
# Mesa's EGL and GLES 2.0 for GL surfaces (llvmpipe without a GPU), WPE WebKit
# and its FreeDesktop.org backend for web views and GStreamer for media, which
# the host loads at run time, Python for AppRuntime's scripts, and WABT for its
Expand All @@ -11,7 +12,7 @@ FROM swift:6.4.2-trixie

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
cmake ninja-build git libfontconfig-dev fonts-dejavu-core \
cmake ninja-build git libfontconfig-dev libharfbuzz-dev fonts-dejavu-core \
libcairo2-dev libfreetype-dev libwayland-dev wayland-protocols \
libegl1 libegl-mesa0 libgles-dev libgl1-mesa-dri \
libwpewebkit-2.0-1 libwpebackend-fdo-1.0-1 libwayland-server0 \
Expand Down
31 changes: 27 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ let package = Package(
.library(name: "LinuxMotion", targets: ["LinuxMotion"]),
.library(name: "LinuxNFC", targets: ["LinuxNFC"]),
.library(name: "LinuxMedia", targets: ["LinuxMedia"]),
.library(name: "LinuxFonts", targets: ["LinuxFonts"]),
.library(name: "LinuxHostApp", targets: ["LinuxHostApp"]),
.executable(name: "linux-app-host", targets: ["LinuxAppHost"]),
.executable(name: "linux-app", targets: ["LinuxAppTool"]),
Expand All @@ -92,8 +93,9 @@ let package = Package(
cacao,
webKit,
// D-Bus, in Swift without libdbus, which Bluetooth talks to BlueZ
// over, and Location to GeoClue; it has no releases.
.package(url: "https://github.com/PureSwift/DBus.git", revision: "d34567d64bb553a35e5b263f344c6963a5170ca3"),
// over, and Location to GeoClue. 0.3.1 is the release Cacao needs,
// with the StatusNotifier service.
.package(url: "https://github.com/PureSwift/DBus.git", from: "0.3.1"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"),
// SHA-256, for bundles' CodeResources.
.package(url: "https://github.com/apple/swift-crypto.git", "3.0.0"..<"5.0.0"),
Expand All @@ -104,6 +106,11 @@ let package = Package(
.package(url: "https://github.com/PureSwift/CoreModel-SQLite.git", branch: "master"),
.package(url: "https://github.com/PureSwift/CoreModel.git", branch: "master"),
.package(url: "https://github.com/PureSwift/SQLite.git", from: "0.2.2"),
// Fonts: faces, images and outlines from FreeType, shaping from
// HarfBuzz, and finding fonts and fallbacks with Fontconfig.
.package(url: "https://github.com/PureSwift/swift-freetype.git", from: "0.1.1"),
.package(url: "https://github.com/PureSwift/swift-harfbuzz.git", from: "0.1.1"),
.package(url: "https://github.com/PureSwift/FontConfig.git", from: "2.0.0"),
],
targets: [

Expand Down Expand Up @@ -246,14 +253,28 @@ let package = Package(
swiftSettings: host
),

// MARK: - Fonts

// The platform's fonts, for a guest that draws text itself.
.target(
name: "LinuxFonts",
dependencies: [
"LinuxHost", runtime("DynamicFonts"), runtime("RuntimeFonts"), runtime("DynamicRuntime"), runtime("RuntimeHost"),
.product(name: "FreeTypeSwift", package: "swift-freetype"),
.product(name: "HarfBuzzSwift", package: "swift-harfbuzz"),
.product(name: "FontConfig", package: "FontConfig"),
],
swiftSettings: host
),

// MARK: - App

// What the runner's process supplies that libc may not
// (arc4random_buf), and prctl, which Swift can't call.
.target(name: "CLinuxHost"),
.target(
name: "LinuxHostApp",
dependencies: ["LinuxHost", "LinuxUI", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", "LinuxDevice", "LinuxLocation", "LinuxDocuments", "LinuxMotion", "LinuxNFC", "LinuxMedia", "CLinuxHost", runtime("CRuntime"), runtime("RuntimeFormatting"), runtime("RuntimeNetworking"),
dependencies: ["LinuxHost", "LinuxUI", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", "LinuxDevice", "LinuxLocation", "LinuxDocuments", "LinuxMotion", "LinuxNFC", "LinuxMedia", "LinuxFonts", "CLinuxHost", runtime("CRuntime"), runtime("RuntimeFormatting"), runtime("RuntimeNetworking"),
runtime("DynamicGraphics"), .product(name: "CacaoSDL", package: "Cacao")],
swiftSettings: host
),
Expand All @@ -277,7 +298,7 @@ let package = Package(
// doesn't build Cacao.
.target(
name: "LinuxPackager",
dependencies: ["LinuxHost", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", "LinuxDevice", "LinuxLocation", "LinuxDocuments", "LinuxMotion", "LinuxNFC", "LinuxMedia", runtime("RuntimeFormatting"), runtime("RuntimeNetworking"), runtime("DynamicUI"),
dependencies: ["LinuxHost", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", "LinuxDevice", "LinuxLocation", "LinuxDocuments", "LinuxMotion", "LinuxNFC", "LinuxMedia", "LinuxFonts", runtime("RuntimeFormatting"), runtime("RuntimeNetworking"), runtime("DynamicUI"),
.product(name: "Crypto", package: "swift-crypto")]
),
.executableTarget(
Expand Down Expand Up @@ -316,6 +337,8 @@ let package = Package(
swiftSettings: host),
.testTarget(name: "LinuxMediaTests", dependencies: ["LinuxMedia", runtime("DynamicMedia"), runtime("RuntimeMedia"), runtime("RuntimeHost")],
swiftSettings: host),
.testTarget(name: "LinuxFontsTests", dependencies: ["LinuxFonts", runtime("DynamicFonts"), runtime("RuntimeFonts"), runtime("DynamicRuntime")],
resources: [.copy("Fixtures")], swiftSettings: host),
.testTarget(name: "LinuxMotionTests", dependencies: ["LinuxMotion", runtime("DynamicMotion")], swiftSettings: host),
.testTarget(name: "LinuxWebKitTests", dependencies: ["LinuxWebKit", runtime("DynamicWebKit"), .product(name: "WPEWebKit", package: "WebKit")],
swiftSettings: host),
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,20 @@ added to its database between launches:
| `LinuxMotion` | Motion: the accelerometer, gyroscope, magnetometer and barometer from the kernel's IIO sensors in sysfs, device motion fused from them, and a pedometer and activity recognizer that are unavailable ([plan](Documentation/Plan.md) §13) |
| `LinuxNFC` | `NFCReader`, `NFCTag`, `NDEFMessage`, `NDEFRecord`: reading and writing NDEF tags through neard on the system bus; no raw commands or locking ([plan](Documentation/Plan.md) §14) |
| `LinuxMedia` | `MediaPlayback`: songs and videos through GStreamer's `playbin`, opened at run time, from files, bytes or URLs; the player's `VideoPlayer` view shows the pictures, with play, pause and a scrubber ([plan](Documentation/Plan.md) §15) |
| `LinuxFonts` | `FontFace`: the system's fonts and the bundle's for a guest that draws text itself (glyphs, shaped lines, glyph images, outlines): FreeType, HarfBuzz and Fontconfig, through AppRuntime's `HostFontFace` |
| `LinuxHostApp`, `linux-app-host` | The app's `main`: the host, and Cacao's window and loop. It also registers AppRuntime's `RuntimeFormatting`, dates and numbers over Swift Foundation, and `RuntimeNetworking`, HTTP over `URLSession` and libcurl ([plan](Documentation/Plan.md) §3) |
| `LinuxPackager`, `linux-app` | The packager: validation, thinning a bundle to one target, the install tree, PortMaster ports |

## Building

Swift 6.4.2 (`.swift-version`) on Debian 13; SDL 3.4, Cairo, FreeType,
fontconfig and Wayland for Cacao; EGL and GLES 2.0, which GL surfaces load
fontconfig and Wayland for Cacao; HarfBuzz for fonts; EGL and GLES 2.0, which GL surfaces load
at run time and apps that draw link (Mesa's draw without a GPU); WPE
WebKit, which web views load at run time; and GStreamer, with its base and
good plugins and libav's decoders, which media players load at run time:

```sh
apt-get install cmake ninja-build git libcairo2-dev libfreetype-dev libfontconfig-dev \
apt-get install cmake ninja-build git libcairo2-dev libfreetype-dev libfontconfig-dev libharfbuzz-dev \
libwayland-dev wayland-protocols fonts-dejavu-core \
libegl1 libegl-mesa0 libgles-dev libgl1-mesa-dri \
libwpewebkit-2.0-1 libwpebackend-fdo-1.0-1 libwayland-server0 \
Expand Down
16 changes: 1 addition & 15 deletions Sources/LinuxBluetooth/BlueZBus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,14 @@ enum BlueZInterface {
// MARK: - Values

/// BlueZ's values; the rest are LinuxDBus's (`text`, `flag`, `entries`,
/// `vardict`).
/// `vardict`) and DBus's (`intValue`, `bytes`, `byteArray`).
public extension DBusMessageArgument {

var intValue: Int? {
int64Value.map(Int.init)
}

/// `ay`.
var bytes: [UInt8]? {
elements?.compactMap { if case .byte(let byte) = $0.contents { byte } else { nil } }
}

/// `as` or `ao`.
var strings: [String] {
elements?.compactMap(\.text) ?? []
}

/// `ay`.
static func byteArray(_ bytes: [UInt8]) -> DBusMessageArgument {
.list(of: .byte, bytes.map { .byte($0) })
}

/// `a{sa{sv}}` as interfaces and their properties.
func interfaces() -> BlueZInterfaces {
var interfaces: BlueZInterfaces = [:]
Expand Down
Loading
Loading