Skip to content

Commit

Permalink
Second commit
Browse files Browse the repository at this point in the history
Second commit
  • Loading branch information
quentinfasquel committed Apr 18, 2022
1 parent 6ce9c93 commit 75764fb
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Created by https://www.toptal.com/developers/gitignore/api/swiftpm
# Edit at https://www.toptal.com/developers/gitignore?templates=swiftpm

### SwiftPM ###
Packages
.build/
.swiftpm
xcuserdata
DerivedData/
*.xcodeproj

# End of https://www.toptal.com/developers/gitignore/api/swiftpm
24 changes: 24 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let rswiftRepository = "https://github.com/quentinfasquel/R.swift"

let package = Package(
name: "R.swift-Plugin",
platforms: [.iOS(.v11)],
products: [
.plugin(name: "RswiftPlugin", targets: ["RswiftPlugin"])
],
targets: [
.plugin(
name: "RswiftPlugin",
capability: .buildTool(),
dependencies: ["rswift"]),
.binaryTarget(
name: "rswift",
url: "\(rswiftRepository)/releases/download/5.4.0-spm/rswift.artifactbundle.zip",
checksum: "0c2b7f766076b398eddc9b61d2d040e2806f3105894a48b4328a506f81d081bc")
]
)
26 changes: 26 additions & 0 deletions Plugins/RswiftPlugin/plugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// RswiftPlugin.swift
//
//
// Created by Quentin Fasquel on 01/04/2022.
//

import PackagePlugin
import Foundation

@main struct RswiftPlugin: BuildToolPlugin {
/// This plugin's implementation returns a single `prebuild` command to run `rswift`.
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
return [.prebuildCommand(
displayName: "Running R.swift",
executable: try context.tool(named: "rswift").path,
arguments: [
"generate", context.pluginWorkDirectory.appending("R.generated.swift"),
"--swiftPackage", context.package.directory.string,
"--target", target.name,
"--accessLevel", "public"
],
// environment: ["SWIFT_PACKAGE": "\(context.package.directory)", "TARGET_NAME": "\(target.name)"],
outputFilesDirectory: context.pluginWorkDirectory)]
}
}

0 comments on commit 75764fb

Please sign in to comment.