From 9b7f943969e17273ac9bd78bb238ffbea3865993 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Tue, 20 Aug 2024 23:21:06 +0200 Subject: Support building libsamba.so for unittests Unittests still fail as there is no samba server to talk to (step 2). --- libs/samba/build.gradle.kts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'libs/samba/build.gradle.kts') diff --git a/libs/samba/build.gradle.kts b/libs/samba/build.gradle.kts index 79827ee..2fc5007 100644 --- a/libs/samba/build.gradle.kts +++ b/libs/samba/build.gradle.kts @@ -24,3 +24,42 @@ android { dependencies { implementation(project(":libs:io")) } + +listOf("Debug", "Release").forEach { buildType -> + val buildDir = project.layout.buildDirectory.dir("test/debug/build") + + val configure by tasks.register( + "configureLibsFor${buildType}UnitTest", + Exec::class + ) { + args( + "-S", + project.layout.projectDirectory.dir("."), + "-B", + buildDir.get() + ) + executable = "cmake" + } + + val compile by tasks.register( + "compileLibsFor${buildType}UnitTest", + Exec::class + ) { + dependsOn(configure) + args("--build", buildDir.get()) + executable = "cmake" + } + + val copy by tasks.register( + "copyLibsFor${buildType}UnitTest", + Copy::class + ) { + dependsOn(compile) + from(buildDir.map { it.file("libsamba.so") }) + into(project.layout.projectDirectory.dir("src/test${buildType}/jniLibs")) + } + + tasks.matching { it.name == "test${buildType}UnitTest" }.all { + dependsOn(copy) + } +} -- cgit v1.2.3-70-g09d2