blob: 6b9cfe3a78d6dd9bc9cea05efbb552431a0f79ca [file] [log] [blame]
Jim Blacklere8f56842024-02-21 10:39:57 +00001// 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
28plugins {
29 id 'com.android.library'
30 id 'maven-publish'
Jim Blackler83bc66f2024-04-05 08:44:08 +000031 id 'org.jetbrains.kotlin.android'
Jim Blacklere8f56842024-02-21 10:39:57 +000032}
33
34android {
35 namespace 'net.android.webgpu'
36 defaultConfig {
37 minSdkVersion 26
Jim Blacklerc25d31a2024-06-17 14:57:28 +000038 compileSdk 34
39 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Jim Blacklere8f56842024-02-21 10:39:57 +000040 externalNativeBuild {
41 cmake {
42 arguments '-DANDROID_STL=c++_shared'
43 version '3.22.1'
Corentin Wallezf62ae992024-07-16 16:59:58 +000044 targets 'webgpu_c_bundled'
Jim Blacklere8f56842024-02-21 10:39:57 +000045 }
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 Blackler83bc66f2024-04-05 08:44:08 +000064 kotlinOptions {
65 jvmTarget = '17'
66 }
Jim Blacklerf7b617f2024-08-27 11:45:51 +000067 kotlin {
68 explicitApi()
69 }
Jim Blackler83bc66f2024-04-05 08:44:08 +000070 compileOptions {
71 targetCompatibility JavaVersion.VERSION_17
72 }
Jim Blacklerdfef9752024-06-15 14:24:47 +000073 sourceSets {
74 main {
75 java.srcDirs += "$project.projectDir/../../../out/Debug/gen/java"
76 }
77 }
Jim Blackler83bc66f2024-04-05 08:44:08 +000078}
79
80dependencies {
Jim Blacklerc25d31a2024-06-17 14:57:28 +000081 implementation 'androidx.core:core-ktx:1.13.1'
Alex Bentonaf6911c2024-07-10 12:43:23 +000082
Jim Blacklerc25d31a2024-06-17 14:57:28 +000083 testImplementation 'junit:junit:4.13.2'
Alex Benton334eaa52024-07-10 13:09:52 +000084 testImplementation 'org.reflections:reflections:0.10.2'
85 testImplementation("org.jetbrains.kotlin:kotlin-reflect")
Alex Bentonaf6911c2024-07-10 12:43:23 +000086 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 Benton334eaa52024-07-10 13:09:52 +000091 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 Blacklere8f56842024-02-21 10:39:57 +000094}
95
96project.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 Blacklerdfef9752024-06-15 14:24:47 +0000108
109tasks.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 Saxenae12c27c2024-07-11 16:33:34 +0000116 '--kotlin-json', 'src/dawn/dawn_kotlin.json',
117 '--jinja2-path', 'third_party/jinja2'
Jim Blacklerdfef9752024-06-15 14:24:47 +0000118}
119
120preBuild {
121 dependsOn generateBindings
122}