summaryrefslogtreecommitdiff
path: root/plugins/hello_gdextension/build.gradle
blob: 11896d54657d622eb0e8e0a98f019ebdca7cb88d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
}

android {
    compileSdk versions.compileSdk

    defaultConfig {
        minSdk versions.minSdk
        targetSdk versions.targetSdk
        versionCode 1
        versionName "1.0"
        externalNativeBuild {
            cmake {
                cppFlags ''
            }
        }
        ndk {
            //noinspection ChromeOsAbiSupport
            abiFilters 'arm64-v8a'
        }
    }
    externalNativeBuild {
        cmake {
            path file('CMakeLists.txt')
            version '3.22.1'
        }
    }

    namespace = "fhuyakou.godot.plugin.android.hellogdextension"

    // Used to customize the name of generated AAR file.
    libraryVariants.configureEach { variant ->
        variant.outputs.configureEach { output ->
            output.outputFileName = "HelloGDExtension.${variant.name}.aar"
        }
    }

}

dependencies {
    compileOnly libraries.godotAndroidLib
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlinVersion"
}

tasks.register('copyDebugAARToAddons', Copy) {
    from 'build/outputs/aar'
    include 'HelloGDExtension.debug.aar'
    into 'src/main/assets/addons/hello_gdextension_plugin/.bin/debug'
}

tasks.register('copyReleaseAARToAddons', Copy) {
    from 'build/outputs/aar'
    include 'HelloGDExtension.release.aar'
    into 'src/main/assets/addons/hello_gdextension_plugin/.bin/release'
}

tasks.register('copyDebugSharedLibs', Copy) {
    dependsOn(":plugins:hello_gdextension:externalNativeBuildDebug")

    from 'build/intermediates/cmake/debug/obj/arm64-v8a'
    include 'libhello_gdextension.so'
    into 'src/main/assets/addons/hello_gdextension_plugin/.bin/debug'
}

tasks.register('copyReleaseSharedLibs', Copy) {
    dependsOn(":plugins:hello_gdextension:externalNativeBuildRelease")

    from 'build/intermediates/cmake/release/obj/arm64-v8a'
    include 'libhello_gdextension.so'
    into 'src/main/assets/addons/hello_gdextension_plugin/.bin/release'
}

tasks.register('copyAddonsToDemo', Copy) {
    dependsOn(copyDebugAARToAddons)
    dependsOn(copyReleaseAARToAddons)
    dependsOn(copyDebugSharedLibs)
    dependsOn(copyReleaseSharedLibs)

    doFirst {
        delete('demo/addons/hello_gdextension_plugin')
    }
    from 'src/main/assets/addons/hello_gdextension_plugin'
    into 'demo/addons/hello_gdextension_plugin'

}

assemble.finalizedBy(copyDebugAARToAddons)
assemble.finalizedBy(copyReleaseAARToAddons)
assemble.finalizedBy(copyDebugSharedLibs)
assemble.finalizedBy(copyReleaseSharedLibs)
assemble.finalizedBy(copyAddonsToDemo)