1
+ import java.nio.file.Paths
1
2
2
3
// General gradle arguments for root project
3
4
buildscript {
@@ -7,24 +8,25 @@ buildscript {
7
8
}
8
9
dependencies {
9
10
//
10
- // https://developer.android.com/studio/releases/gradle-plugin
11
+ // https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
11
12
//
12
- // Notice that 3.3 .0 here is the version of [Android Gradle Plugin]
13
- // Accroding to URL above you will need Gradle 5.0 or higher
13
+ // Notice that 4.0 .0 here is the version of [Android Gradle Plugin]
14
+ // Accroding to URL above you will need Gradle 6.1 or higher
14
15
//
15
- // If you are using Android Studio, and it is using Gradle's lower
16
- // version, Use the plugin version 3.1.3 ~ 3.2.0 for Gradle 4.4 ~ 4.10
17
- classpath ' com.android.tools.build:gradle:3.3.0'
16
+ classpath " com.android.tools.build:gradle:4.1.1"
18
17
}
19
18
}
20
19
repositories {
21
20
google()
22
21
jcenter()
23
22
}
24
-
25
- // Output: Shared library (.so) for Android
26
- apply plugin : ' com.android.library'
27
23
24
+ // Project's root where CMakeLists.txt exists: rootDir/support/.cxx -> rootDir
25
+ def rootDir = Paths . get(project. buildDir. getParent()). getParent()
26
+ println (" rootDir: ${ rootDir} " )
27
+
28
+ // Output: Shared library (.so) for Android
29
+ apply plugin : " com.android.library"
28
30
android {
29
31
compileSdkVersion 25 // Android 7.0
30
32
@@ -41,13 +43,13 @@ android {
41
43
include " arm64-v8a" , " armeabi-v7a" , " x86_64"
42
44
}
43
45
}
46
+ ndkVersion " 21.3.6528147" // ANDROID_NDK_HOME is deprecated. Be explicit
44
47
45
48
defaultConfig {
46
49
minSdkVersion 21 // Android 5.0+
47
50
targetSdkVersion 25 // Follow Compile SDK
48
- versionCode 21 // Follow release count
49
- versionName " 5.3.0" // Follow Official version
50
- testInstrumentationRunner " android.support.test.runner.AndroidJUnitRunner"
51
+ versionCode 34 // Follow release count
52
+ versionName " 7.1.2" // Follow Official version
51
53
52
54
externalNativeBuild {
53
55
cmake {
@@ -56,9 +58,9 @@ android {
56
58
arguments " -DFMT_TEST=false" // Skip test
57
59
arguments " -DFMT_DOC=false" // Skip document
58
60
cppFlags " -std=c++17"
61
+ targets " fmt"
59
62
}
60
63
}
61
- println (" Gradle CMake Plugin: " )
62
64
println (externalNativeBuild. cmake. cppFlags)
63
65
println (externalNativeBuild. cmake. arguments)
64
66
}
@@ -69,16 +71,27 @@ android {
69
71
// neighbor of the top level cmake
70
72
externalNativeBuild {
71
73
cmake {
72
- path " ../CMakeLists.txt"
74
+ version " 3.10.0+"
75
+ path " ${ rootDir} /CMakeLists.txt"
73
76
// buildStagingDirectory "./build" // Custom path for cmake output
74
77
}
75
- // println(cmake.path)
76
78
}
77
79
78
80
sourceSets{
79
81
// Android Manifest for Gradle
80
82
main {
81
- manifest. srcFile ' AndroidManifest.xml'
83
+ manifest. srcFile " AndroidManifest.xml"
84
+ }
85
+ }
86
+
87
+ // https://developer.android.com/studio/build/native-dependencies#build_system_configuration
88
+ buildFeatures {
89
+ prefab true
90
+ prefabPublishing true
91
+ }
92
+ prefab {
93
+ fmt {
94
+ headers " ${ rootDir} /include"
82
95
}
83
96
}
84
97
}
@@ -88,20 +101,32 @@ assemble.doLast
88
101
// Instead of `ninja install`, Gradle will deploy the files.
89
102
// We are doing this since FMT is dependent to the ANDROID_STL after build
90
103
copy {
91
- from ' build/intermediates/cmake'
92
- into ' .. /libs'
104
+ from " build/intermediates/cmake"
105
+ into " ${ rootDir } /libs"
93
106
}
94
107
// Copy debug binaries
95
108
copy {
96
- from ' .. /libs/debug/obj'
97
- into ' .. /libs/debug'
109
+ from " ${ rootDir } /libs/debug/obj"
110
+ into " ${ rootDir } /libs/debug"
98
111
}
99
112
// Copy Release binaries
100
113
copy {
101
- from ' .. /libs/release/obj'
102
- into ' .. /libs/release'
114
+ from " ${ rootDir } /libs/release/obj"
115
+ into " ${ rootDir } /libs/release"
103
116
}
104
117
// Remove empty directory
105
- delete ' ../libs/debug/obj'
106
- delete ' ../libs/release/obj'
118
+ delete " ${ rootDir} /libs/debug/obj"
119
+ delete " ${ rootDir} /libs/release/obj"
120
+
121
+ // Copy AAR files. Notice that the aar is named after the folder of this script.
122
+ copy {
123
+ from " build/outputs/aar/support-release.aar"
124
+ into " ${ rootDir} /libs"
125
+ rename " support-release.aar" , " fmt-release.aar"
126
+ }
127
+ copy {
128
+ from " build/outputs/aar/support-debug.aar"
129
+ into " ${ rootDir} /libs"
130
+ rename " support-debug.aar" , " fmt-debug.aar"
131
+ }
107
132
}
0 commit comments