Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "ferricia"]
path = ferricia
url = https://github.com/bitsusei/TerraModulus-Ferricia-Engine
[submodule "vector-math"]
path = vector-math
url = https://github.com/bitsusei/kotlin-vector-math
3 changes: 2 additions & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 68 additions & 36 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,63 @@ plugins {
kotlin("jvm") version "2.3.21"
kotlin("plugin.serialization") version "2.1.20"
id("org.jetbrains.kotlinx.atomicfu") version "0.27.0"
id("net.terramodulus.plugins.cargo") apply false
// id("fr.stardustenterprises.rust.wrapper") version "3.2.4" apply false
application
}

allprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
version = "0.0.1"

version = "0.0.1"
repositories {
mavenCentral()
}

project(":ferricia") {
// Candidates: fr.stardustenterprises.rust.wrapper
apply(plugin = "net.terramodulus.plugins.cargo")

repositories {
mavenCentral()
if (providers.gradleProperty("release").isPresent) configure<CargoExtension> {
release = true // use `-Prelease=true`
}
configure<CargoExtension> {
outputFile = release.map {
projectDir.resolve("target/${if (it) "release" else "debug"}/${System.mapLibraryName("ferricia")}")
}
}
// somehow, .cargo extension is unusable
tasks.register<CargoTask>("buildClient") {
args = listOf("-F", "client")
println(outputFile.get())
}
tasks.register<CargoTask>("buildServer") {
args = listOf("-F", "server")
}
configurations {
create("client") {
isCanBeConsumed = true
isCanBeResolved = false
}
create("server") {
isCanBeConsumed = true
isCanBeResolved = false
}
}
artifacts {
add("client", tasks.named("buildClient"))
add("server", tasks.named("buildServer"))
}
}

configure(listOf(project(":kernel"), project(":internal"))) {
configure(listOf(project("common"), project("client"), project("server"))) {
apply(plugin = "org.jetbrains.kotlin.jvm")

version = rootProject.version

repositories {
mavenCentral()
}

sourceSets.main {
kotlin.srcDir("kotlin")
resources.srcDir("resources")
Expand Down Expand Up @@ -61,6 +103,23 @@ project(":kernel") {
}
}

project(":kernel:client") {
dependencies {
implementation(project(":ferricia", "client"))
}
}
project(":kernel:server") {
dependencies {
implementation(project(":ferricia", "server"))
}
}

configure(listOf(project(":internal:common"), project(":kernel:common"))) {
dependencies {
api("com.cout970:kotlin-vector-math:0.1.0")
}
}

project(":kernel:common") {
dependencies {
api("org.jetbrains:annotations:26.1.0")
Expand All @@ -86,10 +145,12 @@ project(":kernel:common") {

project(":kernel:client").dependencies {
implementation("net.sf.jopt-simple:jopt-simple:5.0.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0")
}

project(":kernel:server").dependencies {
implementation("net.sf.jopt-simple:jopt-simple:5.0.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0")
}

project(":internal:common").dependencies {
Expand All @@ -112,28 +173,6 @@ configure(listOf(project(":kernel:server"), project(":kernel:client"))) {
}
}

/** Build Ferricia Engine with Cargo */
tasks.register<Exec>("cargoBuildClient") {
onlyIf {
!gradle.taskGraph.hasTask(":kernel:server:jar")
}
workingDir = rootProject.file("ferricia")
commandLine("cargo", "build")
if (project.hasProperty("release")) args("--release") // use `-Prelease=true`
args("-F", "client")
}
tasks.register<Exec>("cargoBuildServer") {
onlyIf {
!gradle.taskGraph.hasTask(":kernel:client:jar")
}
workingDir = rootProject.file("ferricia")
commandLine("cargo", "build")
if (project.hasProperty("release")) args("--release") // use `-Prelease=true`
args("-F", "server")
}
project(":kernel:client").tasks.named("jar") { dependsOn(tasks.named("cargoBuildClient")) }
project(":kernel:server").tasks.named("jar") { dependsOn(tasks.named("cargoBuildServer")) }

tasks.register("buildClient") {
group = "build"
description = "Build client"
Expand All @@ -151,17 +190,13 @@ tasks.named("run") {
tasks.register("runClient") {
group = "application"
description = "Run client"
dependsOn("cargoBuildClient")
dependsOn(":kernel:client:run")
}
project(":kernel:client").tasks.named("run").get().mustRunAfter(tasks.named("cargoBuildClient"))
tasks.register("runServer") {
group = "application"
description = "Run server"
dependsOn("cargoBuildServer")
dependsOn(":kernel:server:run")
}
project(":kernel:server").tasks.named("run").get().mustRunAfter(tasks.named("cargoBuildServer"))

configure(listOf(project(":kernel:server"), project(":kernel:client"))) {
distributions {
Expand All @@ -170,15 +205,12 @@ configure(listOf(project(":kernel:server"), project(":kernel:client"))) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
into("lib") {
val dir = if (project.hasProperty("release")) "release" else "debug"
from("$rootDir/ferricia/target/$dir/${System.mapLibraryName("ferricia")}")
if (OperatingSystem.current().isWindows) from(
"$rootDir/ferricia/target/$dir/ferricia.dll",
"$rootDir/ferricia/target/$dir/oded.dll",
"$rootDir/ferricia/target/$dir/OpenAL32.dll",
"$rootDir/ferricia/target/$dir/SDL3.dll",
) else { // suppose UNIX
// other libs should be installed on user's end directly
from("$rootDir/ferricia/target/$dir/libferricia.so")
}
) // for UNIX, other libs should have been installed on user's end directly
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* SPDX-FileCopyrightText: 2026 TerraModulus Team and Contributors
* SPDX-License-Identifier: LGPL-3.0-only
*/

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

gradlePlugin {
plugins {
register("cargoPlugin") {
id = "net.terramodulus.plugins.cargo"
implementationClass = "CargoPlugin"
}
}
}
12 changes: 12 additions & 0 deletions buildSrc/src/main/kotlin/CargoExtension.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-FileCopyrightText: 2026 TerraModulus Team and Contributors
* SPDX-License-Identifier: LGPL-3.0-only
*/

import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property

interface CargoExtension {
val release: Property<Boolean>
val outputFile: RegularFileProperty
}
21 changes: 21 additions & 0 deletions buildSrc/src/main/kotlin/CargoPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* SPDX-FileCopyrightText: 2026 TerraModulus Team and Contributors
* SPDX-License-Identifier: LGPL-3.0-only
*/

import org.gradle.api.Plugin
import org.gradle.api.Project

class CargoPlugin : Plugin<Project> {
override fun apply(target: Project) {
val extension = target.extensions.create("cargoConfig", CargoExtension::class.java)

extension.release.convention(false)

target.tasks.withType(CargoTask::class.java).configureEach {
release.convention(extension.release)
outputFile.convention(extension.outputFile)
inputs.dir(project.projectDir)
}
}
}
47 changes: 47 additions & 0 deletions buildSrc/src/main/kotlin/CargoTask.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* SPDX-FileCopyrightText: 2026 TerraModulus Team and Contributors
* SPDX-License-Identifier: LGPL-3.0-only
*/

import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.gradle.process.ExecOperations
import javax.inject.Inject

abstract class CargoTask @Inject constructor(private val execOperations: ExecOperations, objectFactory: ObjectFactory) : DefaultTask() {
// @get:Input
// abstract val environment: Property<Map<String, String>>

@get:Input
@get:Optional
abstract val release: Property<Boolean>

@get:Input
@get:Optional
val args: ListProperty<String> = objectFactory.listProperty(String::class.java)

@get:OutputFile
abstract val outputFile: RegularFileProperty

init {
release.convention(false)
args.convention(args.empty())
}

@TaskAction
fun build() {
execOperations.exec {
executable = "cargo"
args = listOf("build") + this@CargoTask.args.get()
if (release.get()) args = args + "--release"
workingDir = project.projectDir
}
}
}
2 changes: 1 addition & 1 deletion ferricia
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 3 additions & 3 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ rootProject.children.forEach {
it.projectDir = File(settingsDir, "src/${it.name}")
include("${it.name}:common", "${it.name}:client", "${it.name}:server")
}

include("ferricia") // this is Rust

includeBuild("vector-math") {
dependencySubstitution {
substitute(module("com.cout970:kotlin-vector-math")).using(project(":"))
}
}
12 changes: 12 additions & 0 deletions src/internal/client/kotlin/net/terramodulus/engine/AsdIntData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-FileCopyrightText: 2026 TerraModulus Team and Contributors
* SPDX-License-Identifier: LGPL-3.0-only
*/

package net.terramodulus.engine

/**
* ASD Intermediate Data
*/
class AsdIntData {
}
Loading
Loading