-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathbuild.gradle
More file actions
132 lines (108 loc) · 3.78 KB
/
build.gradle
File metadata and controls
132 lines (108 loc) · 3.78 KB
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
group 'com.flet.serious_python_android'
version '0.9.10'
def python_version = '3.12'
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'de.undercouch:gradle-download-task:4.1.2'
}
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}
apply plugin: 'com.android.library'
apply plugin: 'de.undercouch.download'
android {
namespace "com.flet.serious_python_android"
// Bumping the plugin compileSdkVersion requires all clients of this plugin
// to bump the version in their app.
compileSdkVersion 31
// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
path "../src/CMakeLists.txt"
// The default CMake version for the Android Gradle Plugin is 3.10.2.
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
//
// The Flutter tooling requires that developers have CMake 3.10 or later
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 21
ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64'
}
}
packagingOptions {
doNotStrip "*/arm64-v8a/libpython*.so"
doNotStrip "*/armeabi-v7a/libpython*.so"
doNotStrip "*/x86/libpython*.so"
doNotStrip "*/x86_64/libpython*.so"
}
}
import de.undercouch.gradle.tasks.download.Download
task copyBuildDist(type: Copy) {
def srcDir = System.getenv('SERIOUS_PYTHON_BUILD_DIST')
if (srcDir != null) {
from srcDir
into 'src/main/jniLibs'
}
}
// Loop through abiFilters
def packageTasks = []
android.defaultConfig.ndk.abiFilters.each { abi ->
def srcDir = System.getenv('SERIOUS_PYTHON_SITE_PACKAGES')
if (srcDir == null || srcDir.allWhitespace) {
throw new InvalidUserDataException("SERIOUS_PYTHON_SITE_PACKAGES environment variable is not set.")
}
packageTasks.add("zipSitePackages_$abi")
packageTasks.add("copyOpt_$abi")
tasks.register("jniCleanUp_$abi", Delete) {
delete "src/main/jniLibs/$abi"
}
tasks.register("downloadDistArchive_$abi", Download) {
src "https://github.com/flet-dev/python-build/releases/download/v${python_version}/python-android-dart-${python_version}-${abi}.tar.gz"
dest new File(buildDir, "python-android-${abi}.tar.gz")
}
tasks.register("untarFile_$abi", Copy) {
from tarTree(tasks.named("downloadDistArchive_$abi").get().dest)
into "src/main/jniLibs/$abi"
dependsOn "jniCleanUp_$abi", "downloadDistArchive_$abi"
}
tasks.register("copyOpt_$abi", Copy) {
from fileTree(dir: "$srcDir/$abi/opt", include: ["**/*.so"])
into "src/main/jniLibs/$abi"
eachFile {
path = name
}
includeEmptyDirs = false
dependsOn "jniCleanUp_$abi"
}
tasks.register("zipSitePackages_$abi", Zip) {
from fileTree(dir: "$srcDir/$abi")
archiveFileName = "libpythonsitepackages.so"
destinationDirectory = file("src/main/jniLibs/$abi")
dependsOn "jniCleanUp_$abi", "untarFile_$abi"
}
}
if (System.getenv('SERIOUS_PYTHON_BUILD_DIST')) {
task copyOrUntar(dependsOn: 'copyBuildDist')
} else {
task copyOrUntar(dependsOn: packageTasks)
}
preBuild.dependsOn copyOrUntar