forked from google/filament
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
195 lines (170 loc) · 5.52 KB
/
build.gradle
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// This script accepts the following parameters:
//
// filament_dist_dir
// Path to the Filament distribution/install directory for Android
// (produced by make/ninja install). This directory must contain lib/arm64-v8a/ etc.
//
// filament_tools_dir
// Path to the Filament distribution/install directory for desktop.
// This directory must contain bin/matc.
//
// filament_exclude_vulkan
// When set, support for Vulkan will be excluded.
//
// filament_skip_samples
// Exclude samples from the project. Useful to speed up compilation.
//
// filament_abis
// List of supported ABIs to build as a comma separated list. Available options are:
// arm64-v8a, armeabi-v7a, x86_64, x86, all
// Defaults to all.
//
// Example:
// ./gradlew -Pfilament_dist_dir=../dist-android-release assembleRelease -Pfilament_abis=x86
// Publishing to Maven Central:
// - Build and upload artifacts with ./gradlew publish
// - Close and release staging repo on Nexus with ./gradlew closeAndReleaseRepository
//
// The following is needed in ~/gradle/gradle.properties:
//
// SONATYPE_NEXUS_USERNAME=nexus_user
// SONATYPE_NEXUS_PASSWORD=nexus_password
//
// nexusUsername=nexus_user
// nexusPassword=nexus_password
//
// signing.keyId=pgp_key_id
// signing.password=pgp_key_password
// signing.secretKeyRingFile=/Users/user/.gnupg/maven_signing.key
//
buildscript {
def filamentPath = file("../out/android-release/filament").absolutePath
if (project.hasProperty("filament_dist_dir")) {
filamentPath = file(project.property("filament_dist_dir")).absolutePath
}
// Our CMake scripts require a forward-slash path for the FILAMENT_DIST_DIR
// variable, so here we convert the native path to a forward-slash path.
filamentPath = filamentPath.replace(File.separator, '/')
// Warning: changing this property does not work well with incremental builds.
def excludeVulkan = project.hasProperty("filament_exclude_vulkan")
def abis = ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
if (project.hasProperty("filament_abis")) {
def newAbis = project.property("filament_abis").split(',')
if (!newAbis.contains("all")) {
abis = newAbis
}
}
// Our minSdkVersion is 19.
ext.versions = [
'minSdk': 19,
'targetSdk': 30,
'compileSdk': 30,
'kotlin': '1.4.10',
'buildTools': '30.0.2',
'ndk': '21.3.6528147'
]
ext.deps = [
'androidx': [
'annotations': "androidx.annotation:annotation:1.1.0",
'core': "androidx.core:core:1.3.0",
],
'kotlin': "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}"
]
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
}
ext.cmakeArgs = [
"-DANDROID_PIE=ON",
"-DANDROID_PLATFORM=21",
"-DANDROID_STL=c++_static",
"-DFILAMENT_DIST_DIR=${filamentPath}".toString(),
"-DFILAMENT_SUPPORTS_VULKAN=${excludeVulkan ? 'OFF' : 'ON'}".toString()
]
ext.cppFlags = [
"-std=c++17",
"-Wno-unused-command-line-argument",
// Required to support API levels below 23
"-Wl,--hash-style=both",
"-fno-stack-protector",
"-fno-exceptions",
"-fno-unwind-tables",
"-fno-asynchronous-unwind-tables",
"-fno-rtti",
"-ffast-math",
"-ffp-contract=fast",
"-fvisibility-inlines-hidden",
"-fvisibility=hidden",
"-fomit-frame-pointer",
"-ffunction-sections",
"-fdata-sections",
"-Wl,--gc-sections",
"-Wl,-Bsymbolic-functions",
]
ext.abis = abis
repositories {
mavenCentral()
google()
jcenter()
}
}
plugins {
id 'io.codearte.nexus-staging' version '0.22.0'
}
// Nexus Staging configuration
// See https://github.com/Codearte/gradle-nexus-staging-plugin/
nexusStaging {
packageGroup = 'com.google.android'
stagingProfileId = '9a75a224a4f17b'
}
subprojects {
group = GROUP
version = VERSION_NAME
repositories {
mavenCentral()
google()
jcenter()
}
if (!name.startsWith("sample")) {
apply plugin: 'com.android.library'
android {
buildToolsVersion versions.buildTools
compileSdkVersion versions.compileSdk
ndkVersion versions.ndk
defaultConfig {
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
externalNativeBuild {
cmake {
arguments.addAll(rootProject.ext.cmakeArgs)
cppFlags.addAll(rootProject.ext.cppFlags)
}
}
ndk {
abiFilters(*rootProject.ext.abis)
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
sourceSets {
main {
jni.srcDirs "src/main/cpp"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
}
gradle.taskGraph.whenReady {
gradle.taskGraph.allTasks.each {
it.onlyIf {
!it.project.ext.has('isSample') || !project.hasProperty('filament_skip_samples')
}
}
}