Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
finnvoor committed Nov 22, 2024
1 parent 139f2dc commit d76c975
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
25 changes: 13 additions & 12 deletions Plugins/PDCPlugin/PDCPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ struct ModuleBuildRequest {
var productModule: (any SourceModuleTarget)! = nil
if productModule == nil, let productNameArg = arguments.extractOption(named: "product").first {
if let argModule = context.package.products.first(where: {
return $0.name == productNameArg
$0.name == productNameArg
})?.sourceModules.first {
productModule = argModule
print("Found product named \(productNameArg).")
}else{
} else {
// If the provided product was not found, error out
print("Failed to locate product named \(productNameArg).")
throw Error.productNotFound
Expand All @@ -64,7 +64,7 @@ struct ModuleBuildRequest {
if let searchedModule = context.package.products.first(where: {
$0.targets.first(where: {
$0.dependencies.first(where: {
if case .product(let product) = $0 {
if case let .product(product) = $0 {
return product.name == "PlaydateKit"
}
return false
Expand All @@ -79,7 +79,7 @@ struct ModuleBuildRequest {
print("Failed to locate a suitable Package product.")
throw Error.productNotFound
}

// MARK: - Paths

let swiftToolchain = try swiftToolchain()
Expand Down Expand Up @@ -266,43 +266,44 @@ struct ModuleBuildRequest {
for resource in moduleResources {
let relativePrefix = module.directory.string + "/Resources/"
// Only copy resource from the Package's "Resources" directory
guard resource.string.hasPrefix(relativePrefix) else {continue}
guard resource.string.hasPrefix(relativePrefix) else { continue }
let relativePath = resource.string.replacingOccurrences(of: relativePrefix, with: "")
resourcePaths.append((resource.string, relativePath))
}
}

appendResources(for: productModule)
for dependency in productModule.dependencies {
switch dependency {
case .product(let product):
case let .product(product):
for module in product.sourceModules {
appendResources(for: module)
}
case .target(let target):
case let .target(target):
if let module = target.sourceModule {
appendResources(for: module)
}
default: break
}
}

// Copy resources
for resource in resourcePaths {
let dest = sourcePath.appending([resource.relativePath])
let destDirectory = dest.removingLastComponent()

if FileManager.default.fileExists(atPath: destDirectory.string, isDirectory: nil) == false {
let relativeDestDirectory = Path(resource.relativePath).removingLastComponent()
print("creating directory \(relativeDestDirectory.string)/")
try FileManager.default.createDirectory(atPath: destDirectory.string, withIntermediateDirectories: true)
}

// If the resource is pdxinfo, always place it in the pdx root
var destination = dest.string
if resource.path.hasSuffix("/pdxinfo") {
destination = sourcePath.appending(["pdxinfo"]).string
}

print("copying \(resource.relativePath)")
try FileManager.default.copyItem(
atPath: resource.path,
Expand Down
14 changes: 7 additions & 7 deletions Sources/PlaydateKit/Core/System.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ public enum System {
}
}

/// A custom update function.
///
/// The update function should return true to tell the system to update the display, or false if an update isn’t needed.
public nonisolated(unsafe) static var updateCallback: (() -> Bool)? = nil

public private(set) nonisolated(unsafe) static var menuItems: [MenuItem] = []

/// Returns the last-read accelerometer data.
public static var accelerometer: (x: Float, y: Float, z: Float) {
var x: Float = 0, y: Float = 0, z: Float = 0
Expand All @@ -109,13 +116,6 @@ public enum System {
return (current, pushed, released)
}

/// A custom update function.
///
/// The update function should return true to tell the system to update the display, or false if an update isn’t needed.
public nonisolated(unsafe) static var updateCallback: (() -> Bool)? = nil

public private(set) nonisolated(unsafe) static var menuItems: [MenuItem] = []

// MARK: - Time and Date

/// Returns the number of milliseconds since…​some arbitrary point in time.
Expand Down

0 comments on commit d76c975

Please sign in to comment.