Improving build script
This commit is contained in:
parent
27e893632d
commit
d6a63509cb
@ -1,21 +1,9 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") version "2.1.0"
|
||||
kotlin("multiplatform") apply false
|
||||
id("buildSrc")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
mingwX64()
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation("io.ktor:ktor-client-core:3.1.1")
|
||||
implementation("io.ktor:ktor-network:3.1.1")
|
||||
}
|
||||
}
|
||||
}
|
||||
maven("https://maven.landgrafhomyak.ru/")
|
||||
}
|
2
gradle.properties
Normal file
2
gradle.properties
Normal file
@ -0,0 +1,2 @@
|
||||
kotlin.mpp.applyDefaultHierarchyTemplate=false
|
||||
kotlin.native.enableKlibsCrossCompilation=true
|
20
modules/build-script/build.gradle.kts
Normal file
20
modules/build-script/build.gradle.kts
Normal file
@ -0,0 +1,20 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://maven.landgrafhomyak.ru/")
|
||||
}
|
||||
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
main {
|
||||
dependencies {
|
||||
api("ru.landgrafhomyak.kotlin:kotlin-mpp-gradle-build-helper:v0.2k2.0.20")
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1
modules/build-script/settings.gradle.kts
Normal file
1
modules/build-script/settings.gradle.kts
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = "build-script"
|
@ -0,0 +1,10 @@
|
||||
package ru.landgrafhomyak.bgtu.networks0.build_script
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
class BuildSrcPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
// project.extensions.add("utility", DslExtension)
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package ru.landgrafhomyak.bgtu.networks0.build_script
|
||||
|
||||
object Dependencies {
|
||||
val kotlin_atomicfu = "org.jetbrains.kotlinx:atomicfu:${Versions.kotlin_atomicfu}"
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package ru.landgrafhomyak.bgtu.networks0.build_script
|
||||
|
||||
@Suppress( "MayBeConstant")
|
||||
object Versions {
|
||||
val kotlin_atomicfu = "0.27.0"
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
package ru.landgrafhomyak.bgtu.networks0.build_script
|
||||
|
||||
import java.util.function.BiFunction
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
import kotlin.reflect.KProperty
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.api.NamedDomainObjectProvider
|
||||
import org.gradle.api.Transformer
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.specs.Spec
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
|
||||
@Suppress("FunctionName")
|
||||
private fun NamedDomainObjectContainer<KotlinSourceSet>._createConditional(
|
||||
name: String,
|
||||
vararg children: KotlinSourceSet?
|
||||
): KotlinSourceSet? {
|
||||
val existingChildren = children.filterNotNull()
|
||||
|
||||
if (existingChildren.isEmpty())
|
||||
return null
|
||||
|
||||
val ss = this.create(name)
|
||||
existingChildren
|
||||
.forEach { child -> child.dependsOn(ss) }
|
||||
|
||||
return ss
|
||||
}
|
||||
|
||||
fun NamedDomainObjectContainer<KotlinSourceSet>.setupHierarchy() {
|
||||
val linuxX64Main = this.findByName("linuxX64Main")
|
||||
val linuxX64Test = this.findByName("linuxX64Test")
|
||||
val linuxArm64Main = this.findByName("linuxArm64Main")
|
||||
val linuxArm64Test = this.findByName("linuxArm64Test")
|
||||
|
||||
val linuxMain = this._createConditional("linuxMain", linuxX64Main, linuxArm64Main)
|
||||
val linuxTest = this._createConditional("linuxTest", linuxX64Test, linuxArm64Test)
|
||||
|
||||
val macosX64Main = this.findByName("macosX64Main")
|
||||
val macosX64Test = this.findByName("macosX64Test")
|
||||
val macosArm64Main = this.findByName("macosArm64Main")
|
||||
val macosArm64Test = this.findByName("macosArm64Test")
|
||||
|
||||
val macosMain = this._createConditional("macosMain", macosX64Main, macosArm64Main)
|
||||
val macosTest = this._createConditional("macosTest", macosX64Test, macosArm64Test)
|
||||
|
||||
val posixMain = this._createConditional("posixMain", linuxMain, macosMain)
|
||||
val posixTest = this._createConditional("posixTest", linuxTest, macosTest)
|
||||
|
||||
val mingwX64Main = this.findByName("mingwX64Main")
|
||||
val mingwX64Test = this.findByName("mingwX64Test")
|
||||
|
||||
val windowsMain = this._createConditional("windowsMain", mingwX64Main)
|
||||
val windowsTest = this._createConditional("windowsTest", mingwX64Test)
|
||||
|
||||
val nativeMain = this._createConditional("nativeMain", posixMain, windowsMain)
|
||||
val nativeTest = this._createConditional("nativeTest", posixTest, windowsTest)
|
||||
|
||||
nativeMain?.dependsOn(this.getByName("commonMain"))
|
||||
nativeTest?.dependsOn(this.getByName("commonTest"))
|
||||
}
|
||||
|
||||
|
||||
val NamedDomainObjectContainer<KotlinSourceSet>.posixMain by SourceSetDelegate
|
||||
val NamedDomainObjectContainer<KotlinSourceSet>.posixTest by SourceSetDelegate
|
||||
val NamedDomainObjectContainer<KotlinSourceSet>.windowsMain by SourceSetDelegate
|
||||
val NamedDomainObjectContainer<KotlinSourceSet>.windowsTest by SourceSetDelegate
|
||||
|
||||
|
||||
private object SourceSetDelegate : ReadOnlyProperty<NamedDomainObjectContainer<KotlinSourceSet>, NamedDomainObjectProvider<KotlinSourceSet>> {
|
||||
private class BoundProvider(
|
||||
private val _collection: NamedDomainObjectContainer<KotlinSourceSet>,
|
||||
private val _name: String
|
||||
) : NamedDomainObjectProvider<KotlinSourceSet> {
|
||||
override fun get(): KotlinSourceSet = this._collection.getByName(this._name)
|
||||
|
||||
override fun getOrNull(): KotlinSourceSet? = this._collection.findByName(this._name)
|
||||
|
||||
override fun isPresent(): Boolean = this.getOrNull() != null
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun forUseAtConfigurationTime(): Provider<KotlinSourceSet> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getName(): String = this._name
|
||||
|
||||
override fun configure(action: Action<in KotlinSourceSet>) {
|
||||
action.execute(this.get())
|
||||
}
|
||||
|
||||
override fun <U : Any?, R : Any?> zip(right: Provider<U>, combiner: BiFunction<in KotlinSourceSet, in U, out R?>): Provider<R> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun orElse(provider: Provider<out KotlinSourceSet>): Provider<KotlinSourceSet> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun orElse(value: KotlinSourceSet): Provider<KotlinSourceSet> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun <S : Any?> flatMap(transformer: Transformer<out Provider<out S>?, in KotlinSourceSet>): Provider<S> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun filter(spec: Spec<in KotlinSourceSet>): Provider<KotlinSourceSet> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun <S : Any?> map(transformer: Transformer<out S?, in KotlinSourceSet>): Provider<S> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getOrElse(defaultValue: KotlinSourceSet): KotlinSourceSet = this.getOrNull() ?: defaultValue
|
||||
}
|
||||
|
||||
override fun getValue(thisRef: NamedDomainObjectContainer<KotlinSourceSet>, property: KProperty<*>): NamedDomainObjectProvider<KotlinSourceSet> {
|
||||
return BoundProvider(thisRef, property.name)
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
implementation-class=ru.landgrafhomyak.bgtu.networks0.build_script.BuildSrcPlugin
|
@ -1,5 +1,7 @@
|
||||
import ru.landgrafhomyak.bgtu.networks0.build_script.setupHierarchy
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform") version "2.1.0"
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
@ -14,67 +16,6 @@ kotlin {
|
||||
macosX64()
|
||||
macosArm64()
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
val nativeMain by creating {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
val nativeTest by creating {
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
|
||||
val posixMain by creating {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
val posixTest by creating {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
|
||||
val linuxMain by creating {
|
||||
dependsOn(posixMain)
|
||||
}
|
||||
val linuxTest by creating {
|
||||
dependsOn(posixTest)
|
||||
}
|
||||
|
||||
val linuxX64Main by getting {
|
||||
dependsOn(linuxMain)
|
||||
}
|
||||
val linuxX64Test by getting {
|
||||
dependsOn(linuxTest)
|
||||
}
|
||||
val linuxArm64Main by getting {
|
||||
dependsOn(linuxMain)
|
||||
}
|
||||
val linuxArm64Test by getting {
|
||||
dependsOn(linuxTest)
|
||||
}
|
||||
|
||||
val macosMain by creating {
|
||||
dependsOn(posixMain)
|
||||
}
|
||||
val macosTest by creating {
|
||||
dependsOn(posixTest)
|
||||
}
|
||||
val macosX64Main by getting {
|
||||
dependsOn(macosMain)
|
||||
}
|
||||
val macosX64Test by getting {
|
||||
dependsOn(macosTest)
|
||||
}
|
||||
val macosArm64Main by getting {
|
||||
dependsOn(macosMain)
|
||||
}
|
||||
val macosArm64Test by getting {
|
||||
dependsOn(macosTest)
|
||||
}
|
||||
setupHierarchy()
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import ru.landgrafhomyak.bgtu.networks0.build_script.setupHierarchy
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform") version "2.1.0"
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
@ -14,71 +16,12 @@ kotlin {
|
||||
macosX64()
|
||||
macosArm64()
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
val nativeMain by creating {
|
||||
dependsOn(commonMain)
|
||||
setupHierarchy()
|
||||
|
||||
nativeMain {
|
||||
dependencies {
|
||||
implementation(project(":modules:low-level:c-interop-utilities"))
|
||||
}
|
||||
}
|
||||
val nativeTest by creating {
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
|
||||
val posixMain by creating {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
val posixTest by creating {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
|
||||
val linuxMain by creating {
|
||||
dependsOn(posixMain)
|
||||
}
|
||||
val linuxTest by creating {
|
||||
dependsOn(posixTest)
|
||||
}
|
||||
|
||||
val linuxX64Main by getting {
|
||||
dependsOn(linuxMain)
|
||||
}
|
||||
val linuxX64Test by getting {
|
||||
dependsOn(linuxTest)
|
||||
}
|
||||
val linuxArm64Main by getting {
|
||||
dependsOn(linuxMain)
|
||||
}
|
||||
val linuxArm64Test by getting {
|
||||
dependsOn(linuxTest)
|
||||
}
|
||||
|
||||
val macosMain by creating {
|
||||
dependsOn(posixMain)
|
||||
}
|
||||
val macosTest by creating {
|
||||
dependsOn(posixTest)
|
||||
}
|
||||
val macosX64Main by getting {
|
||||
dependsOn(macosMain)
|
||||
}
|
||||
val macosX64Test by getting {
|
||||
dependsOn(macosTest)
|
||||
}
|
||||
val macosArm64Main by getting {
|
||||
dependsOn(macosMain)
|
||||
}
|
||||
val macosArm64Test by getting {
|
||||
dependsOn(macosTest)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
import ru.landgrafhomyak.bgtu.networks0.build_script.Dependencies
|
||||
import ru.landgrafhomyak.bgtu.networks0.build_script.setupHierarchy
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform") version "2.1.0"
|
||||
}
|
||||
@ -14,72 +17,19 @@ kotlin {
|
||||
macosX64()
|
||||
macosArm64()
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
setupHierarchy()
|
||||
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:atomicfu:0.27.0")
|
||||
implementation(Dependencies.kotlin_atomicfu)
|
||||
}
|
||||
}
|
||||
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
val nativeMain by creating {
|
||||
dependsOn(commonMain)
|
||||
nativeMain {
|
||||
dependencies {
|
||||
implementation(project(":modules:low-level:c-interop-utilities"))
|
||||
implementation(project(":modules:low-level:multithreading"))
|
||||
}
|
||||
}
|
||||
val nativeTest by creating {
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
|
||||
val posixMain by creating {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
val posixTest by creating {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
|
||||
val linuxMain by creating {
|
||||
dependsOn(posixMain)
|
||||
}
|
||||
val linuxTest by creating {
|
||||
dependsOn(posixTest)
|
||||
}
|
||||
|
||||
val linuxX64Main by getting {
|
||||
dependsOn(linuxMain)
|
||||
}
|
||||
val linuxX64Test by getting {
|
||||
dependsOn(linuxTest)
|
||||
}
|
||||
val linuxArm64Main by getting {
|
||||
dependsOn(linuxMain)
|
||||
}
|
||||
val linuxArm64Test by getting {
|
||||
dependsOn(linuxTest)
|
||||
}
|
||||
|
||||
val macosMain by creating {
|
||||
dependsOn(posixMain)
|
||||
}
|
||||
val macosTest by creating {
|
||||
dependsOn(posixTest)
|
||||
}
|
||||
val macosX64Main by getting {
|
||||
dependsOn(macosMain)
|
||||
}
|
||||
val macosX64Test by getting {
|
||||
dependsOn(macosTest)
|
||||
}
|
||||
val macosArm64Main by getting {
|
||||
dependsOn(macosMain)
|
||||
}
|
||||
val macosArm64Test by getting {
|
||||
dependsOn(macosTest)
|
||||
}
|
||||
}
|
||||
}
|
@ -150,5 +150,9 @@ actual class SocketBlockingEventLoop : SocketEventLoop {
|
||||
override suspend fun _waitForRead() =
|
||||
this@SocketBlockingEventLoop._waitForRead(this._socketFd)
|
||||
|
||||
override fun close() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package ru.landgrafhomyak.bgtu.networks0.low_level.sockets
|
||||
|
||||
actual class SocketBlockingEventLoop : ru.landgrafhomyak.bgtu.networks0.low_level.sockets.SocketEventLoop {
|
||||
actual constructor() {
|
||||
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun icmp_IPv4(addr: String): ru.landgrafhomyak.bgtu.networks0.low_level.sockets.IcmpSocket {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun icmp_IPv6(addr: String): ru.landgrafhomyak.bgtu.networks0.low_level.sockets.IcmpSocket {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
|
||||
private fun _mainloop() {
|
||||
|
||||
}
|
||||
|
||||
actual companion object {
|
||||
actual fun runForever(el: ru.landgrafhomyak.bgtu.networks0.low_level.sockets.SocketBlockingEventLoop) {
|
||||
el._mainloop()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package ru.landgrafhomyak.bgtu.networks0.low_level.sockets
|
||||
|
||||
interface IcmpSocket {
|
||||
suspend fun send(data: UByteArray)
|
||||
suspend fun recv(): UByteArray
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package ru.landgrafhomyak.bgtu.networks0.low_level.sockets
|
||||
|
||||
@Suppress("FunctionName")
|
||||
interface SocketEventLoop {
|
||||
fun icmp_IPv4(addr: String): IcmpSocket
|
||||
fun icmp_IPv6(addr: String): IcmpSocket
|
||||
}
|
@ -1,3 +1,26 @@
|
||||
includeBuild("./modules/build-script") {
|
||||
dependencySubstitution {
|
||||
substitute(module("buildSrc:buildSrc:buildSrc")).using(project(":"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://maven.landgrafhomyak.ru/")
|
||||
}
|
||||
plugins {
|
||||
kotlin("multiplatform") version "2.1.0"
|
||||
id("buildSrc")
|
||||
}
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == "buildSrc")
|
||||
useModule("buildSrc:buildSrc:buildSrc")
|
||||
}
|
||||
}
|
||||
}
|
||||
include(":modules:low-level:c-interop-utilities")
|
||||
include(":modules:low-level:multithreading")
|
||||
include(":modules:low-level:sockets")
|
Loading…
Reference in New Issue
Block a user