Skip to content

Commit eee55b5

Browse files
authored
Gradle fixes from libprocessing refactor. (#1346)
1 parent 2b9f115 commit eee55b5

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

core/build.gradle.kts

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,44 @@ dependencies {
6565
if (enableWebGPU) {
6666
val currentPlatform = PlatformUtils.detect()
6767
val libprocessingDir = file("${project.rootDir}/libprocessing")
68+
69+
if (!libprocessingDir.exists()) {
70+
throw GradleException(
71+
"libprocessing submodule directory not found at: ${libprocessingDir.absolutePath}\n" +
72+
"Please initialize the submodule with: git submodule update --init --recursive"
73+
)
74+
}
75+
6876
val rustTargetDir = file("$libprocessingDir/target")
6977
val nativeOutputDir = file("${layout.buildDirectory.get()}/native/${currentPlatform.target}")
7078

79+
val ffiManifestPath = fileTree(libprocessingDir) {
80+
include("**/processing_ffi/Cargo.toml")
81+
}.files.firstOrNull()?.let { it.relativeTo(libprocessingDir).path }
82+
?: throw GradleException(
83+
"Could not find processing_ffi Cargo.toml in libprocessing.\n" +
84+
"Searched in: ${libprocessingDir.absolutePath}\n" +
85+
"The libprocessing structure may have changed."
86+
)
87+
7188
val buildRustRelease by tasks.registering(CargoBuildTask::class) {
7289
cargoWorkspaceDir.set(libprocessingDir)
73-
manifestPath.set("ffi/Cargo.toml")
90+
manifestPath.set(ffiManifestPath)
7491
release.set(true)
7592
cargoPath.set(PlatformUtils.getCargoPath())
7693
outputLibrary.set(file("$rustTargetDir/release/${currentPlatform.libName}"))
7794

78-
inputs.files(fileTree("$libprocessingDir/ffi/src"))
79-
inputs.file("$libprocessingDir/ffi/Cargo.toml")
80-
inputs.file("$libprocessingDir/ffi/build.rs")
81-
inputs.file("$libprocessingDir/ffi/cbindgen.toml")
82-
inputs.files(fileTree("$libprocessingDir/renderer/src"))
83-
inputs.file("$libprocessingDir/renderer/Cargo.toml")
95+
inputs.files(fileTree("$libprocessingDir/crates") {
96+
include("**/src/**/*.rs")
97+
include("**/Cargo.toml")
98+
include("**/build.rs")
99+
include("**/cbindgen.toml")
100+
})
84101
inputs.file("$libprocessingDir/Cargo.toml")
85-
outputs.file("$libprocessingDir/ffi/include/processing.h")
102+
inputs.file("$libprocessingDir/Cargo.lock")
103+
104+
val headerDir = file("$libprocessingDir/${ffiManifestPath}").parentFile.resolve("include")
105+
outputs.file("$headerDir/processing.h")
86106
}
87107

88108
val copyNativeLibs by tasks.registering(Copy::class) {
@@ -110,7 +130,7 @@ if (enableWebGPU) {
110130

111131
val cleanRust by tasks.registering(CargoCleanTask::class) {
112132
cargoWorkspaceDir.set(libprocessingDir)
113-
manifestPath.set("ffi/Cargo.toml")
133+
manifestPath.set(ffiManifestPath)
114134
cargoPath.set(PlatformUtils.getCargoPath())
115135

116136
mustRunAfter(buildRustRelease)
@@ -158,7 +178,9 @@ if (enableWebGPU) {
158178
dependsOn(downloadJextract, makeJextractExecutable)
159179
}
160180

161-
headerFile.set(file("$libprocessingDir/ffi/include/processing.h"))
181+
// Find header file dynamically based on FFI manifest location
182+
val headerDir = file("$libprocessingDir/${ffiManifestPath}").parentFile.resolve("include")
183+
headerFile.set(file("$headerDir/processing.h"))
162184
outputDirectory.set(generatedJavaDir)
163185
targetPackage.set("processing.ffi")
164186

0 commit comments

Comments
 (0)