1 /*
2 * Copyright (C) 2023 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
<lambda>null17 plugins {
18 alias(libs.plugins.android.library)
19 alias(libs.plugins.kotlin.android)
20 alias(libs.plugins.kotlin.kapt)
21 alias(libs.plugins.dagger.hilt.android)
22 }
23
<lambda>null24 android {
25 namespace = "com.google.jetpackcamera.core.camera"
26 compileSdk = libs.versions.compileSdk.get().toInt()
27 compileSdkPreview = libs.versions.compileSdkPreview.get()
28
29 defaultConfig {
30 minSdk = libs.versions.minSdk.get().toInt()
31 testOptions.targetSdk = libs.versions.targetSdk.get().toInt()
32 lint.targetSdk = libs.versions.targetSdk.get().toInt()
33
34 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
35
36 @Suppress("UnstableApiUsage")
37 externalNativeBuild {
38 val versionScript = file("src/main/cpp/jni.lds").absolutePath
39 cmake {
40 cppFlags += listOf(
41 "-std=c++17",
42 "-O3",
43 "-flto",
44 "-fPIC",
45 "-fno-exceptions",
46 "-fno-rtti",
47 "-fomit-frame-pointer",
48 "-fdata-sections",
49 "-ffunction-sections"
50 )
51 arguments += listOf(
52 "-DCMAKE_VERBOSE_MAKEFILE=ON",
53 "-DCMAKE_SHARED_LINKER_FLAGS=-Wl,--gc-sections " +
54 "-Wl,--version-script=${versionScript}"
55 )
56 }
57 }
58 }
59
60 externalNativeBuild {
61 cmake {
62 version = libs.versions.cmake.get()
63 path = file("src/main/cpp/CMakeLists.txt")
64 }
65 }
66
67 flavorDimensions += "flavor"
68 productFlavors {
69 create("stable") {
70 dimension = "flavor"
71 isDefault = true
72 }
73
74 create("preview") {
75 dimension = "flavor"
76 targetSdkPreview = libs.versions.targetSdkPreview.get()
77 }
78 }
79
80 compileOptions {
81 sourceCompatibility = JavaVersion.VERSION_17
82 targetCompatibility = JavaVersion.VERSION_17
83 }
84 kotlin {
85 jvmToolchain(17)
86 }
87
88 kotlinOptions {
89 freeCompilerArgs += "-Xcontext-receivers"
90 }
91 }
92
<lambda>null93 dependencies {
94 // Testing
95 testImplementation(libs.junit)
96 testImplementation(libs.truth)
97 testImplementation(libs.kotlinx.coroutines.test)
98 testImplementation(libs.mockito.core)
99 androidTestImplementation(libs.androidx.junit)
100 androidTestImplementation(libs.androidx.espresso.core)
101 androidTestImplementation(libs.kotlinx.coroutines.test)
102 androidTestImplementation(libs.rules)
103 androidTestImplementation(libs.truth)
104
105 // Futures
106 implementation(libs.futures.ktx)
107
108 // LiveData
109 implementation(libs.androidx.lifecycle.livedata)
110
111 // CameraX
112 implementation(libs.camera.core)
113 implementation(libs.camera.camera2)
114 implementation(libs.camera.lifecycle)
115 implementation(libs.camera.video)
116
117 // Hilt
118 implementation(libs.dagger.hilt.android)
119 kapt(libs.dagger.hilt.compiler)
120
121 // Tracing
122 implementation(libs.androidx.tracing)
123 implementation(libs.kotlinx.atomicfu)
124
125 // Graphics libraries
126 implementation(libs.androidx.graphics.core)
127
128 // Project dependencies
129 implementation(project(":data:settings"))
130 implementation(project(":core:common"))
131 }
132
133 // Allow references to generated code
<lambda>null134 kapt {
135 correctErrorTypes = true
136 }
137