Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

3.4 KB
Raw Blame
// swift-tools-version:5.10
import PackageDescription

// CEF (Chromium Embedded Framework) lives in vendor/cef, fetched by
// scripts/fetch-cef.sh, with its C++ wrapper built by CMake into
// vendor/cef/build/libcef_dll_wrapper.
let cefRoot = "\(Context.packageDirectory)/vendor/cef"

// Same flags CEF uses for its own wrapper (vendor/cef/cmake/cef_variables.cmake),
// so the ABI of the wrapper classes matches.
let cefCXXFlags: [String] = [
    "-fno-exceptions", "-fno-rtti", "-fno-threadsafe-statics",
    "-fobjc-call-cxx-cdtors", "-fno-strict-aliasing",
    "-Wno-unused-parameter", "-Wno-deprecated-declarations",
    "-I", cefRoot,
]

let cefLinkerFlags: [String] = [
    "-L\(cefRoot)/build/libcef_dll_wrapper",
]

// Sparkle, the updater framework Arc ships, lives in vendor/sparkle (scripts/fetch-sparkle.sh);
// scripts/build.sh copies Sparkle.framework into Cra.app/Contents/Frameworks.
let sparkleRoot = "\(Context.packageDirectory)/vendor/sparkle"

let package = Package(
    name: "Cra",
    platforms: [.macOS(.v14)],
    products: [
        .executable(name: "Cra", targets: ["Cra"]),
        .executable(name: "CraHelper", targets: ["CraHelper"]),
        // Loaded by the Dock, not by Cra; scripts/build.sh wraps it in
        // Cra.app/Contents/PlugIns/CraDockTile.docktileplugin.
        .library(name: "CraDockTile", type: .dynamic, targets: ["CraDockTile"]),
    ],
    // Models and decisions that need no AppKit or CEF, with tests that run without vendor/cef.
    dependencies: [.package(path: "Packages/CraCore")],
    targets: [
        // Objective-C++ bridge between Swift and CEF.
        .target(
            name: "CraCEF",
            path: "Sources/CraCEF",
            publicHeadersPath: "include",
            cxxSettings: [.unsafeFlags(cefCXXFlags + ["-fobjc-arc"])],
            linkerSettings: [
                .unsafeFlags(cefLinkerFlags),
                .linkedLibrary("cef_dll_wrapper"),
                .linkedFramework("AppKit"),
                .linkedFramework("IOSurface"),
            ]
        ),
        // Subprocess executable (renderer, GPU, utility...). Bundled five
        // times as "Cra Helper*.app" inside Cra.app/Contents/Frameworks.
        .executableTarget(
            name: "CraHelper",
            path: "Sources/CraHelper",
            cxxSettings: [.unsafeFlags(cefCXXFlags)],
            linkerSettings: [
                .unsafeFlags(cefLinkerFlags),
                .linkedLibrary("cef_dll_wrapper"),
                .linkedFramework("AppKit"),
                .linkedFramework("IOSurface"),
            ]
        ),
        // Dock tile plug-in: keeps the icon picked in Settings after Cra quits.
        .target(
            name: "CraDockTile",
            path: "Sources/CraDockTile",
            linkerSettings: [.linkedFramework("AppKit")]
        ),
        // The browser itself: AppKit window, SwiftUI sidebar and command bar.
        .executableTarget(
            name: "Cra",
            dependencies: ["CraCEF", .product(name: "CraCore", package: "CraCore")],
            path: "Sources/Cra",
            swiftSettings: [.unsafeFlags(["-F", sparkleRoot]), .unsafeFlags(["-Onone"], .when(configuration: .debug))],
            linkerSettings: [.unsafeFlags(["-F", sparkleRoot, "-framework", "Sparkle",
                                           "-Xlinker", "-rpath", "-Xlinker", "@executable_path/../Frameworks"])]
        ),
    ],
    swiftLanguageVersions: [.v5],
    cxxLanguageStandard: .cxx20
)