Jim Blackler | e8f5684 | 2024-02-21 10:39:57 +0000 | [diff] [blame] | 1 | // Copyright 2024 The Dawn & Tint Authors |
| 2 | // |
| 3 | // Redistribution and use in source and binary forms, with or without |
| 4 | // modification, are permitted provided that the following conditions are met: |
| 5 | // |
| 6 | // 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | // list of conditions and the following disclaimer. |
| 8 | // |
| 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, |
| 10 | // this list of conditions and the following disclaimer in the documentation |
| 11 | // and/or other materials provided with the distribution. |
| 12 | // |
| 13 | // 3. Neither the name of the copyright holder nor the names of its |
| 14 | // contributors may be used to endorse or promote products derived from |
| 15 | // this software without specific prior written permission. |
| 16 | // |
| 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 21 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 24 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | plugins { |
| 29 | id 'com.android.library' |
| 30 | id 'maven-publish' |
Jim Blackler | 83bc66f | 2024-04-05 08:44:08 +0000 | [diff] [blame] | 31 | id 'org.jetbrains.kotlin.android' |
Jim Blackler | e8f5684 | 2024-02-21 10:39:57 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | android { |
| 35 | namespace 'net.android.webgpu' |
| 36 | defaultConfig { |
| 37 | minSdkVersion 26 |
Jim Blackler | c25d31a | 2024-06-17 14:57:28 +0000 | [diff] [blame] | 38 | compileSdk 34 |
| 39 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' |
Jim Blackler | e8f5684 | 2024-02-21 10:39:57 +0000 | [diff] [blame] | 40 | externalNativeBuild { |
| 41 | cmake { |
| 42 | arguments '-DANDROID_STL=c++_shared' |
| 43 | version '3.22.1' |
Corentin Wallez | f62ae99 | 2024-07-16 16:59:58 +0000 | [diff] [blame] | 44 | targets 'webgpu_c_bundled' |
Jim Blackler | e8f5684 | 2024-02-21 10:39:57 +0000 | [diff] [blame] | 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | externalNativeBuild { |
| 50 | cmake { |
| 51 | path file('src/main/cpp/CMakeLists.txt') |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | buildFeatures { |
| 56 | prefabPublishing true |
| 57 | } |
| 58 | |
| 59 | prefab { |
| 60 | webgpu_c_bundled { |
| 61 | headers "src/main/cpp/gen/include" |
| 62 | } |
| 63 | } |
Jim Blackler | 83bc66f | 2024-04-05 08:44:08 +0000 | [diff] [blame] | 64 | kotlinOptions { |
| 65 | jvmTarget = '17' |
| 66 | } |
Jim Blackler | f7b617f | 2024-08-27 11:45:51 +0000 | [diff] [blame] | 67 | kotlin { |
| 68 | explicitApi() |
| 69 | } |
Jim Blackler | 83bc66f | 2024-04-05 08:44:08 +0000 | [diff] [blame] | 70 | compileOptions { |
| 71 | targetCompatibility JavaVersion.VERSION_17 |
| 72 | } |
Jim Blackler | dfef975 | 2024-06-15 14:24:47 +0000 | [diff] [blame] | 73 | sourceSets { |
| 74 | main { |
| 75 | java.srcDirs += "$project.projectDir/../../../out/Debug/gen/java" |
| 76 | } |
| 77 | } |
Jim Blackler | 83bc66f | 2024-04-05 08:44:08 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | dependencies { |
Jim Blackler | c25d31a | 2024-06-17 14:57:28 +0000 | [diff] [blame] | 81 | implementation 'androidx.core:core-ktx:1.13.1' |
Alex Benton | af6911c | 2024-07-10 12:43:23 +0000 | [diff] [blame] | 82 | |
Jim Blackler | c25d31a | 2024-06-17 14:57:28 +0000 | [diff] [blame] | 83 | testImplementation 'junit:junit:4.13.2' |
Alex Benton | 334eaa5 | 2024-07-10 13:09:52 +0000 | [diff] [blame] | 84 | testImplementation 'org.reflections:reflections:0.10.2' |
| 85 | testImplementation("org.jetbrains.kotlin:kotlin-reflect") |
Alex Benton | af6911c | 2024-07-10 12:43:23 +0000 | [diff] [blame] | 86 | testImplementation("org.jetbrains.kotlin:kotlin-test") |
| 87 | testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4") |
| 88 | testImplementation("org.mockito:mockito-core:5.12.0") |
| 89 | testImplementation("org.mockito.kotlin:mockito-kotlin:5.3.1") |
| 90 | |
Alex Benton | 334eaa5 | 2024-07-10 13:09:52 +0000 | [diff] [blame] | 91 | androidTestImplementation 'androidx.test.ext:junit-ktx:1.2.1' |
| 92 | androidTestImplementation 'androidx.test:runner:1.6.1' |
| 93 | androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4' |
Jim Blackler | e8f5684 | 2024-02-21 10:39:57 +0000 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | project.afterEvaluate { |
| 97 | publishing { |
| 98 | publications { |
| 99 | libraryProject(MavenPublication) { |
| 100 | setGroupId 'net.android' |
| 101 | setArtifactId 'webgpu' |
| 102 | version '1.1.34' |
| 103 | artifact bundleReleaseAar |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | } |
Jim Blackler | dfef975 | 2024-06-15 14:24:47 +0000 | [diff] [blame] | 108 | |
| 109 | tasks.register('generateBindings', Exec) { |
| 110 | workingDir('../../..') |
| 111 | commandLine 'python3', 'generator/dawn_json_generator.py', |
| 112 | '--template-dir', 'generator/templates', |
| 113 | '--output-dir', "$project.projectDir/../../../out/Debug/gen", |
| 114 | '--dawn-json', 'src/dawn/dawn.json', |
| 115 | '--targets', 'kotlin', |
Sonakshi Saxena | e12c27c | 2024-07-11 16:33:34 +0000 | [diff] [blame] | 116 | '--kotlin-json', 'src/dawn/dawn_kotlin.json', |
| 117 | '--jinja2-path', 'third_party/jinja2' |
Jim Blackler | dfef975 | 2024-06-15 14:24:47 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | preBuild { |
| 121 | dependsOn generateBindings |
| 122 | } |