1
<lambda>null2 plugins {
3 `c`
4 }
5
6 description = "JNI bindings for the AWS Common Runtime"
7
8 buildDir = File("../../build")
9
10 var buildType = "RelWithDebInfo"
11 if (project.hasProperty("buildType")) {
12 buildType = project.property("buildType").toString()
13 logger.info("Using custom build type: ${buildType}")
14 }
15
<lambda>null16 val cmakeConfigure = tasks.register("cmakeConfigure") {
17 var cmakeArgs = listOf(
18 "-B${buildDir}/cmake-build",
19 "-H${projectDir}/../../",
20 "-DCMAKE_BUILD_TYPE=${buildType}",
21 "-DCMAKE_INSTALL_PREFIX=${buildDir}/cmake-build",
22 "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
23 "-DBUILD_DEPS=ON",
24 "-DBUILD_TESTING=OFF"
25 )
26
27 inputs.file("../../CMakeLists.txt")
28 outputs.file("${buildDir}/cmake-build/CMakeCache.txt")
29
30 doLast {
31 val argsStr = cmakeArgs.joinToString(separator=" ")
32 logger.info("cmake ${argsStr}")
33 exec {
34 executable("cmake")
35 args(cmakeArgs)
36 environment(mapOf<String, String>("JAVA_HOME" to System.getProperty("java.home")))
37 }
38 }
39 }
40
<lambda>null41 val cmakeBuild = tasks.register("cmakeBuild") {
42 dependsOn(cmakeConfigure)
43 inputs.file("../../CMakeLists.txt")
44 inputs.file("${buildDir}/cmake-build/CMakeCache.txt")
45 inputs.files(fileTree(".").matching {
46 include(listOf("**/*.c", "**/*.h"))
47 })
48 inputs.files(fileTree("../../crt").matching {
49 include(listOf("**/CMakeLists.txt", "**/*.c", "**/*.h"))
50 })
51 outputs.file("${buildDir}/cmake-build/lib/libaws-crt-jni.so")
52 outputs.upToDateWhen { false } //shared lib doesn't seem to get placed in jar without this
53
54 var cmakeArgs = listOf(
55 "--build", "${buildDir}/cmake-build",
56 "--target", "all"
57 )
58
59 doLast {
60 val argsStr = cmakeArgs.joinToString(separator=" ")
61 logger.info("cmake ${argsStr}")
62 exec {
63 executable("cmake")
64 args(cmakeArgs)
65 }
66 }
67 }
68
<lambda>null69 tasks.assemble {
70 dependsOn(cmakeBuild)
71 }
72