Skip to content

Commit

Permalink
feat: expose platform matching APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrMilchmann committed Dec 30, 2024
1 parent 1917d9d commit 5e97178
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/changelog/0.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ _Not Released Yet_
- The purpose of this platform is to provide more convenient development
experience. The implicit platform should be filtered when creating
distributions.
- Experimentally exposed the match functions for `Architecture` and
`OperatingSystem` as public API.

#### Fixes

Expand Down
13 changes: 12 additions & 1 deletion src/main/kotlin/com/osmerion/gradle/lwjgl3/Architecture.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public fun Architecture(matches: Predicate<String>): Architecture =
*
* @since 0.1.0
*/
@OptIn(ExperimentalPlatformApi::class)
public sealed class Architecture {

internal abstract val artifactClassifierComponent: String?
Expand All @@ -59,7 +60,17 @@ public sealed class Architecture {

}

internal abstract fun matches(arch: String): Boolean
/**
* Checks if the given `arch` matches this architecture.
*
* @param arch the architecture to match
*
* @return `true` if the given `arch` matches this architecture, or `false` otherwise
*
* @since 0.5.0
*/
@ExperimentalPlatformApi
public abstract fun matches(arch: String): Boolean

/**
* The ARM32 architecture.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2023-2024 Leon Linhart
* All rights reserved.
*/
package com.osmerion.gradle.lwjgl3

/**
* Marks APIs that are experimental parts of the platform (i.e. OS and
* architecture) matching APIs.
*
* @since 0.5.0
*/
@RequiresOptIn
public annotation class ExperimentalPlatformApi
13 changes: 12 additions & 1 deletion src/main/kotlin/com/osmerion/gradle/lwjgl3/OperatingSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public fun OperatingSystem(matches: Predicate<String>): OperatingSystem =
*
* @since 0.1.0
*/
@OptIn(ExperimentalPlatformApi::class)
public sealed class OperatingSystem {

internal abstract val artifactClassifierComponent: String
Expand All @@ -59,7 +60,17 @@ public sealed class OperatingSystem {

}

internal abstract fun matches(osName: String): Boolean
/**
* Checks if the given operating system name matches this operating system.
*
* @param osName the name of the operating system to match
*
* @return `true` if the given operating system name matches this operating system,
*
* @since 0.5.0
*/
@ExperimentalPlatformApi
public abstract fun matches(osName: String): Boolean

/**
* The FreeBSD operating system family.
Expand Down

0 comments on commit 5e97178

Please sign in to comment.