Skip to content

Commit

Permalink
Merge branch 'feature/dev-publish-static' into 'feature/dev' (merge r…
Browse files Browse the repository at this point in the history
…equest !152)


feature/dev-publish-static
增加静态链接 libc++ 版本,通过版本号后缀 -STATIC 区分,默认关闭,通过 gradle 参数控制开启,publish 到 maven central 时开启
  • Loading branch information
gryamy committed Jan 21, 2022
2 parents 1704122 + 60c1466 commit 972c692
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 34 deletions.
4 changes: 4 additions & 0 deletions matrix/matrix-android/gradle/Arguments.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ gradle.ext.gonnaPublish = {
}

return false
}

gradle.ext.staticLinkCXX = {
return gradle.startParameter.projectProperties.containsKey("publishStaticLinkCXXFlavor" as String)
}
11 changes: 1 addition & 10 deletions matrix/matrix-android/matrix-backtrace/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,7 @@ android {

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.annotation:annotation:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
// implementation "com.tencent.stubs:logger:${rootProject.LOGGER_VERSION}"
implementation project(':matrix-android-lib')
}
apply from: project.file('dependencies.gradle')

group = rootProject.GROUP
version = rootProject.VERSION_NAME
Expand Down
85 changes: 85 additions & 0 deletions matrix/matrix-android/matrix-backtrace/cxx-static/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
apply plugin: 'com.android.library'

apply from: rootProject.file('gradle/WeChatNativeDepend.gradle')

android {
compileSdkVersion rootProject.compileSdkVersion

defaultConfig {
minSdkVersion rootProject.MIN_SDK_VERSION_FOR_HOOK
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.VERSION_CODE
versionName rootProject.VERSION_NAME

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

ndk {
abiFilters rootProject.ABI_FILTERS as String[]
}

externalNativeBuild {
cmake {
targets = ['wechatbacktrace', 'unwindstack']
arguments = ['-DANDROID_STL=c++_static',
"-DEnableLOG=${gradle.enableLog() ? "ON" : "OFF"}" as String,
"-DQUT_STATISTIC_ENABLE=${gradle.enableLog() ? "ON" : "OFF"}" as String]
}

exportHeaders {
from('../src/main/cpp') {
include 'common/*.h'
moveToDir 'backtrace'
}
from('../src/main/cpp/libwechatbacktrace/include') {
include '**/*.h'
moveToDir 'backtrace'
}
from('../src/main/cpp/external/libunwindstack/include') {
include '**/*.h'
moveToDir 'backtrace'
}
from('../src/main/cpp/dexfile/include') {
include '**/*.h'
moveToDir 'backtrace'
}
}
}
}

buildTypes {

release {
minifyEnabled false
}
}

externalNativeBuild {
cmake {
path "../CMakeLists.txt"
}
}

sourceSets {
main {
java.srcDirs = ['../src/main/java']
res.srcDirs = ['../src/main/res']
manifest.srcFile '../src/main/AndroidManifest.xml'
}
}

}

apply from: project.file('../dependencies.gradle')

group = rootProject.GROUP
version = "${rootProject.VERSION_NAME}-STATIC"

if("External" == rootProject.ext.PUBLISH_CHANNEL) {
apply from: rootProject.file('gradle/android-publish.gradle')
}
else {
apply from: rootProject.file('gradle/WeChatPublish.gradle')
wechatPublish {
artifactId = POM_ARTIFACT_ID
}
}
10 changes: 10 additions & 0 deletions matrix/matrix-android/matrix-backtrace/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.annotation:annotation:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
// implementation "com.tencent.stubs:logger:${rootProject.LOGGER_VERSION}"
implementation project(':matrix-android-lib')
}
13 changes: 1 addition & 12 deletions matrix/matrix-android/matrix-hooks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,7 @@ android {

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

testImplementation 'junit:junit:4.12'
implementation 'androidx.annotation:annotation:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
// implementation "com.tencent.stubs:logger:${rootProject.LOGGER_VERSION}"
implementation project(':matrix-android-lib')
implementation project(':matrix-backtrace')
implementation project(':matrix-android-commons')
}
apply from: project.file('dependencies.gradle')

group = rootProject.GROUP
version = rootProject.VERSION_NAME
Expand Down
71 changes: 71 additions & 0 deletions matrix/matrix-android/matrix-hooks/cxx-static/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
apply plugin: 'com.android.library'

apply from: rootProject.file('gradle/WeChatNativeDepend.gradle')

android {
compileSdkVersion rootProject.compileSdkVersion

defaultConfig {
minSdkVersion MIN_SDK_VERSION_FOR_HOOK
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.VERSION_CODE
versionName rootProject.VERSION_NAME

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

ndk {
abiFilters rootProject.ABI_FILTERS as String[]
}

externalNativeBuild {
cmake {
arguments = ['-DANDROID_STL=c++_static', "-DEnableLOG=${gradle.enableLog() ? "ON" : "OFF"}" as String]
}

exportHeaders {
from('../src/main/cpp/common') {
include '**/*.h'
include '*.h'
}
}
}
}

buildTypes {

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

externalNativeBuild {
cmake {
path "../CMakeLists.txt"
}
}

sourceSets {
main {
java.srcDirs = ['../src/main/java']
res.srcDirs = ['../src/main/res']
manifest.srcFile '../src/main/AndroidManifest.xml'
}
}

}

apply from: project.file('../dependencies.gradle')

group = rootProject.GROUP
version = "${rootProject.VERSION_NAME}-STATIC"

if("External" == rootProject.ext.PUBLISH_CHANNEL) {
apply from: rootProject.file('gradle/android-publish.gradle')
}
else {
apply from: rootProject.file('gradle/WeChatPublish.gradle')
wechatPublish {
artifactId = POM_ARTIFACT_ID
}
}
12 changes: 12 additions & 0 deletions matrix/matrix-android/matrix-hooks/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

testImplementation 'junit:junit:4.12'
implementation 'androidx.annotation:annotation:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
// implementation "com.tencent.stubs:logger:${rootProject.LOGGER_VERSION}"
implementation project(':matrix-android-lib')
implementation project(':matrix-backtrace')
implementation project(':matrix-android-commons')
}
12 changes: 1 addition & 11 deletions matrix/matrix-android/matrix-opengl-leak/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,7 @@ android {
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation project(':matrix-android-lib')
implementation project(':matrix-android-commons')
implementation project(':matrix-backtrace')

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.annotation:annotation:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
}
apply from: project.file('dependencies.gradle')

group = rootProject.GROUP
version = rootProject.VERSION_NAME
Expand Down
72 changes: 72 additions & 0 deletions matrix/matrix-android/matrix-opengl-leak/cxx-static/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apply plugin: 'com.android.library'

apply from: rootProject.file('gradle/WeChatNativeDepend.gradle')

android {
compileSdkVersion rootProject.compileSdkVersion

defaultConfig {
minSdkVersion MIN_SDK_VERSION_FOR_HOOK
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.VERSION_CODE
versionName rootProject.VERSION_NAME

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

ndk {
abiFilters rootProject.ABI_FILTERS as String[]
}

externalNativeBuild {
cmake {
arguments = ['-DANDROID_STL=c++_static', "-DEnableLOG=${gradle.enableLog() ? "ON" : "OFF"}" as String]
}

exportHeaders {
from('../src/main/cpp/common') {
include '**/*.h'
include '*.h'
}
}
}
}

buildTypes {

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

externalNativeBuild {
cmake {
path "../CMakeLists.txt"
}
}

sourceSets {
main {
java.srcDirs = ['../src/main/java']
res.srcDirs = ['../src/main/res']
aidl.srcDirs = ['../src/main/aidl']
manifest.srcFile '../src/main/AndroidManifest.xml'
}
}

}

apply from: project.file('../dependencies.gradle')

group = rootProject.GROUP
version = "${rootProject.VERSION_NAME}-STATIC"

if("External" == rootProject.ext.PUBLISH_CHANNEL) {
apply from: rootProject.file('gradle/android-publish.gradle')
}
else {
apply from: rootProject.file('gradle/WeChatPublish.gradle')
wechatPublish {
artifactId = POM_ARTIFACT_ID
}
}
11 changes: 11 additions & 0 deletions matrix/matrix-android/matrix-opengl-leak/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation project(':matrix-android-lib')
implementation project(':matrix-android-commons')
implementation project(':matrix-backtrace')

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.annotation:annotation:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
}
8 changes: 7 additions & 1 deletion matrix/matrix-android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply from:"$rootDir/gradle/Arguments.gradle"
apply from: "$rootDir/gradle/Arguments.gradle"

// Gradle plugin
include ':matrix-gradle-plugin'
Expand Down Expand Up @@ -33,3 +33,9 @@ include ':test:matrix-backtrace-benchmark'
// TEST
include ':test:test-backtrace'
include ':test:test-memoryhook'

if (gradle.staticLinkCXX()) {
include ':matrix-hooks:cxx-static'
include ':matrix-opengl-leak:cxx-static'
include ':matrix-backtrace:cxx-static'
}

0 comments on commit 972c692

Please sign in to comment.