gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
91 stars 8 forks source link

Port wifimon swift project to gradle #1091

Open bric3 opened 2 years ago

bric3 commented 2 years ago

This more of an open question in regards of the steps necessary to port the build system to gradle for a really simple terminal application written in swift.

The original repository is https://github.com/attheodo/wifimon Gradle 7.2

I created the two files build.gradle.kts

plugins {
    `swift-application`
    xctest
}

application {
    targetMachines.add(machines.macOS.x86_64)
}

extensions.configure<SwiftApplication> {
    source.from(file("Sources/wifimon"))
}

dependencies {
    implementation("ConsoleKit:ConsoleKit") {
        version {
            branch = "main"
        }
    }
}

And settings.gradle.kts

rootProject.name = "wifimon"

sourceControl {
    gitRepository(java.net.URI.create("https://github.com/vapor/console-kit.git")) {
        producesModule("ConsoleKit:ConsoleKit")

    }
}

However the build fails with the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':installDebug'.
> Could not resolve all task dependencies for configuration ':nativeRuntimeDebug'.
   > Git repository at https://github.com/vapor/console-kit.git did not contain a project publishing the specified dependency.
     Required by:
         project :

I am not quite sure how to declare a source repository, but I think I followed the documentation :

For reference the Package.swift looks like this

https://github.com/attheodo/wifimon/blob/2362dc2256574ea2d1fb22c5c5e126c23623708d/Package.swift

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription

let package = Package(
    name: "wifimon",
    platforms: [
        .macOS(.v10_15)
    ],
    dependencies: [
        .package(url: "https://github.com/vapor/console-kit", .branch("main")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .executableTarget(
            name: "wifimon",
            dependencies: [.product(name: "ConsoleKit", package: "console-kit")]),
        .testTarget(
            name: "wifimonTests",
            dependencies: ["wifimon"]),
    ]
)

I tried to provide a build scan, but this fails for a reason I'm not able to determine or work around.

This build uses Gradle features that are incompatible with build scans (code: late-load-build-op).
bric3 commented 2 years ago

Answered on the nokee gradle native plugins : https://github.com/nokeedev/gradle-native/issues/348#issuecomment-934475561 In particular this commit : https://github.com/lacasseio/wifimon/commit/02cfdf5fdf38f017fab163ec93bcf74957394e1f