Skip to content

Commit

Permalink
Merge branch 'tim/finer_build_archs' into 'master'
Browse files Browse the repository at this point in the history
Gradle cleanups & speedups

See merge request Tanker/sdk-android!46
  • Loading branch information
dmerejkowsky committed Mar 8, 2019
2 parents e378c0c + 8dd07fa commit 1c4afde
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 171 deletions.
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${dokka_version}"
classpath 'javax.inject:javax.inject:1'
classpath 'net.java.dev.jna:jna-platform:4.5.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}


allprojects {
repositories {
google()
Expand Down
49 changes: 27 additions & 22 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -1,51 +1,56 @@
# Generated with dmenv 0.11.1, python 3.7.1, on Linux
-e git+ssh://[email protected]/Tanker/ci@9057d36029825cc05210c1083f26fcaff2a2bf0c#egg=ci
astroid==2.2.4
# Generated with dmenv 0.11.0, python 3.7.2+, on Linux
-e git+ssh://[email protected]/Tanker/ci@d74efd7ac6bf2383788cec6b011dd80bc8fa145c#egg=ci
astroid==2.0.4
attrs==19.1.0
bottle==0.12.16
certifi==2018.11.29
bottle==0.12.13
certifi==2018.10.15
chardet==3.0.4
cli-ui==0.9.1
colorama==0.4.1
colorama==0.3.9
conan==1.12.3
contextlib2==0.5.5
deprecation==2.0.6
distro==1.1.0
docopt==0.6.2
docopt==0.4.0
fasteners==0.14.1
future==0.16.0
idna==2.8
importlib-metadata==0.8
isort==4.3.10
idna==2.7
importlib-metadata==0.6
isort==4.3.4
lazy-object-proxy==1.3.1
mandrill-really-maintained==1.2.4
mandrill==1.0.57
mccabe==0.6.1
monotonic==1.5
mypy-extensions==0.4.1
mypy==0.641
node-semver==0.6.1
packaging==19.0
packaging==18.0
patch==1.16
path.py==11.5.0
pip==19.0.3
pluginbase==0.7
psutil==5.6.0
Pygments==2.3.1
PyJWT==1.7.1
pylint==2.3.1
pyparsing==2.3.1
python-gitlab==1.8.0
Pygments==2.2.0
PyJWT==1.6.4
pylint==2.1.1
pyparsing==2.3.0
python-gitlab==1.6.0
PyYAML==3.13
requests==2.21.0
requests==2.20.0
ruamel.yaml==0.15.89
schema==0.7.0
setuptools==40.8.0
six==1.12.0
tabulate==0.8.3
six==1.11.0
tabulate==0.8.2
tbump==5.0.3
toml==0.10.0
tqdm-conan==4.27.0
tqdm==4.31.1
typed-ast==1.3.1
Unidecode==1.0.23
typed-ast==1.1.0
Unidecode==1.0.22
urllib3==1.24.1
websockets==7.0
wheel==0.33.1
wrapt==1.11.1
wrapt==1.10.11
zipp==0.3.3
2 changes: 1 addition & 1 deletion run-ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def main():
args = parser.parse_args()

if args.command == "update-conan-config":
ci.cpp.update_conan_config(args.platform)
ci.cpp.update_conan_config()
elif args.command == "check":
ci.android.check(native_from_sources=args.native_from_sources)
elif args.command == "deploy":
Expand Down
157 changes: 17 additions & 140 deletions tanker-bindings/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import com.sun.jna.Platform

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply from: 'native.gradle'

group 'io.tanker'
version 'dev'
Expand Down Expand Up @@ -33,11 +32,6 @@ android {
}
}
}
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -76,118 +70,6 @@ android {
}
}

class Helper {
public static def runCmd(cmd, path) {
print("${path}: ${cmd} \n")
def sout = new StringBuilder(), serr = new StringBuilder()
def proc = cmd.execute(null, path)
proc.consumeProcessOutput(sout, serr)
proc.waitFor()
println "$sout $serr"
if (proc.exitValue() != 0) {
throw new Exception("out> $sout err> $serr" + "\nCommand: ${cmd}")
}
}

// This creates a .jar with our .so inside, so we can put it in the classpath for tests
public static def createNativeLibJar(File libPath, String jarName) {
def platformPrefix = Platform.getNativeLibraryResourcePrefix()
def relPrefixedPath = platformPrefix + '/' + libPath.name
def prefixedLibPath = new File(libPath.parent + '/' + relPrefixedPath)
prefixedLibPath.parentFile.mkdirs()
prefixedLibPath.bytes = libPath.bytes // This is just a file copy in Groovy
runCmd("jar cf ${jarName} -C ${libPath.parent} $relPrefixedPath", libPath.parentFile)
}
}

class BuildNativeFromSourcesTask extends DefaultTask {
String projectPath
String buildType

static def runConan(buildPath, installPath, sourcePath, buildType, arch, profile) {
buildPath.mkdirs()
installPath.mkdirs()
Helper.runCmd("conan install $sourcePath --profile $profile --build missing --options shared=True --settings build_type=$buildType --settings arch=$arch --install-folder $buildPath", sourcePath)
Helper.runCmd("conan build --configure --build --install $sourcePath --package-folder $installPath --build-folder $buildPath", sourcePath)
}

@TaskAction
void compile() {
def androidBuildType = buildType.toLowerCase()
def buildPathBase = projectPath+"/../../sdk-native/build/android/$buildType"
def installPathBase = projectPath+"/src/$androidBuildType/jniLibs/"
def sourcePath = new File(projectPath+"/../../sdk-native")

// Run each known android arch (except x86, known bug)
def conanAndroidArchs = ["x86_64": "x86_64", "x86": "x86", "armeabi-v7a":"armv7", "arm64-v8a": "armv8"]
conanAndroidArchs.each{ k, v ->
def buildPath = new File("$buildPathBase/$k")
def installPath = new File("$installPathBase/$k")
runConan(buildPath, installPath, sourcePath, buildType, v, "android")
Helper.runCmd("cp lib/libtanker.so .", installPath)
}

// Last run for host build (used for unit testing)
def buildPath = new File(projectPath+"/../../sdk-native/build/host/$buildType/")
def installPath = new File(projectPath+"/conan/host/")
def profile = System.getenv("CI") ? "gcc8" : "default"
runConan(buildPath, installPath, sourcePath, buildType, "x86_64", profile)
def hostLibDir = new File(installPath, "lib/libtanker.so")
Helper.createNativeLibJar(hostLibDir, 'tanker-native.jar')
}
}

class UseDeployedNative extends DefaultTask {
String projectPath
String buildType

static def runConan(installPath, sourcePath, buildType, arch, profile) {
installPath.mkdirs()
Helper.runCmd("conan install $sourcePath --profile $profile --build missing --settings build_type=$buildType --settings arch=$arch --install-folder $installPath", sourcePath)
}

@TaskAction
void compile() {
def androidBuildType = buildType.toLowerCase()
def installPathBase = projectPath+"/src/$androidBuildType/jniLibs/"
def sourcePath = new File(projectPath+"/conan")

// Run each known android arch (except x86, known bug)
def conanAndroidArchs = ["x86_64": "x86_64", "x86": "x86", "armeabi-v7a":"armv7", "arm64-v8a": "armv8"]
conanAndroidArchs.each{ k, v ->
def installPath = new File("$installPathBase/$k")
runConan(installPath, sourcePath, buildType, v, "android")
}

// Last run for host build (used for unit testing)
def installPath = new File(projectPath+"/conan/host/lib")
def profile = System.getenv("CI") ? "gcc8" : "default"
runConan(installPath, sourcePath, buildType, "x86_64", profile)
def hostLibDir = new File(installPath, "libtanker.so")
Helper.createNativeLibJar(hostLibDir, 'tanker-native.jar')
}
}

task buildNativeFromSourcesDebug(type: BuildNativeFromSourcesTask) {
projectPath = projectDir.absolutePath
buildType = "Debug"
}

task buildNativeFromSourcesRelease(type: BuildNativeFromSourcesTask) {
projectPath = projectDir.absolutePath
buildType = "Release"
}

task useDeployedNativeDebug(type: UseDeployedNative) {
projectPath = projectDir.absolutePath
buildType = "Debug"
}

task useDeployedNativeRelease(type: UseDeployedNative) {
projectPath = projectDir.absolutePath
buildType = "Release"
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
Expand All @@ -198,27 +80,6 @@ task javaDocJar(type: Jar, dependsOn: dokka) {
classifier = 'javadoc'
}

dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
api 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation 'com.android.support:support-compat:28.0.0'
testImplementation 'io.kotlintest:kotlintest-core:3.2.1'
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.2.1'
api 'net.java.dev.jna:jna:4.5.1@aar'
testImplementation 'net.java.dev.jna:jna:4.5.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7'
testImplementation 'org.slf4j:slf4j-nop:1.7.25'
testImplementation files('jna.jar')
testImplementation files('conan/host/lib/tanker-native.jar')
}

clean {
delete "conan/build"
}

dokka {
outputFormat = 'javadoc'

Expand Down Expand Up @@ -260,3 +121,19 @@ uploadArchives {
}
}
}

dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
api 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
api 'net.java.dev.jna:jna:4.5.1@aar'
implementation 'com.android.support:support-compat:28.0.0'
testImplementation 'io.kotlintest:kotlintest-core:3.2.1'
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.2.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7'
testImplementation 'org.slf4j:slf4j-nop:1.7.25'
testImplementation files('jna.jar')
testImplementation files('conan/host/lib/tanker-native.jar')
}
5 changes: 1 addition & 4 deletions tanker-bindings/conan/conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[requires]
tanker/1.10.0@tanker/stable
tanker/1.10.0-r4@tanker/stable

[imports]
lib, *tanker*.* -> .

[options]
tanker:shared=True
Loading

0 comments on commit 1c4afde

Please sign in to comment.