-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
112 changed files
with
8,499 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
**.iml | ||
.gradle | ||
.idea | ||
.DS_Store | ||
build | ||
captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
|
||
xcuserdata | ||
**.xcodeproj | ||
**.podspec | ||
Podfile.lock | ||
Pods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "mars"] | ||
path = mars | ||
url = [email protected]:HackWebRTC/mars.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,56 @@ | ||
# kmp-xlog | ||
KMP wrapper for tencent mars xlog | ||
|
||
KMP wrapper for [tencent mars xlog](https://github.com/Tencent/mars). | ||
|
||
## Dependency | ||
|
||
```kotlin | ||
// add common source set dependency | ||
kotlin { | ||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
implementation("com.piasy:kmp-xlog:$releaseVersion") | ||
} | ||
} | ||
} | ||
} | ||
|
||
// add iOS cocoapods dependency | ||
// TODO | ||
``` | ||
|
||
## Usage | ||
|
||
```kotlin | ||
object Logging { | ||
const val LEVEL_DEBUG = 1 | ||
const val LEVEL_INFO = 2 | ||
const val LEVEL_ERROR = 4 | ||
} | ||
|
||
// Android initialize | ||
fun initializeMarsXLog( | ||
context: Context, | ||
logDir: String, | ||
level: Int, | ||
namePrefix: String, | ||
logToConsole: Boolean | ||
) | ||
|
||
// iOS initialize | ||
fun initializeMarsXLog( | ||
level: Int, | ||
namePrefix: String, | ||
logToConsole: Boolean | ||
) | ||
|
||
// logging | ||
object Logging { | ||
fun debug(tag: String, content: String) | ||
|
||
fun info(tag: String, content: String) | ||
|
||
fun error(tag: String, content: String) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
buildscript { | ||
repositories { | ||
gradlePluginPortal() | ||
google() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
plugins { | ||
//trick: for the same plugin versions in all sub-modules | ||
id("com.android.library").version(Consts.agp).apply(false) | ||
id("com.android.application").version(Consts.agp).apply(false) | ||
|
||
kotlin("android").version(Consts.kotlin).apply(false) | ||
kotlin("multiplatform").version(Consts.kotlin).apply(false) | ||
} | ||
|
||
tasks.register("clean", Delete::class) { | ||
delete(rootProject.buildDir) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
object Consts { | ||
const val agp = "7.3.0" | ||
|
||
const val kotlin = "1.7.10" | ||
|
||
const val mockk = "1.12.4" | ||
const val androidXTestVersion = "1.5.0" | ||
|
||
const val androidCompileSdk = 33 | ||
const val androidMinSdk = 21 | ||
const val androidTargetSdk = 33 | ||
const val androidNdk = "21.3.6528147" | ||
|
||
const val iosDeploymentTarget = "14.0" | ||
|
||
const val releaseGroup = "com.piasy" | ||
const val releaseName = "kmp-xlog" | ||
const val releaseVersion = "1.0.0" | ||
|
||
val androidNS = "$releaseGroup.${releaseName.replace('-', '_')}" | ||
} |
101 changes: 101 additions & 0 deletions
101
buildSrc/src/main/kotlin/convention.publication.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// credit: https://dev.to/kotlin/how-to-build-and-publish-a-kotlin-multiplatform-library-going-public-4a8k | ||
import java.util.Properties | ||
|
||
plugins { | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
// Stub secrets to let the project sync and build without the publication values set up | ||
ext["signing.keyId"] = null | ||
ext["signing.password"] = null | ||
ext["signing.secretKeyRingFile"] = null | ||
ext["ossrhUsername"] = null | ||
ext["ossrhPassword"] = null | ||
|
||
// Grabbing secrets from local.properties file or from environment variables, which could be used on CI | ||
val secretPropsFile = project.rootProject.file("local.properties") | ||
if (secretPropsFile.exists()) { | ||
secretPropsFile.reader().use { | ||
Properties().apply { | ||
load(it) | ||
} | ||
}.onEach { (name, value) -> | ||
ext[name.toString()] = value | ||
} | ||
} else { | ||
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID") | ||
ext["signing.password"] = System.getenv("SIGNING_PASSWORD") | ||
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE") | ||
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME") | ||
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD") | ||
} | ||
|
||
ext["artifact.name"] = null | ||
ext["artifact.desc"] = null | ||
ext["artifact.url"] = null | ||
val propsFile = project.rootProject.file("gradle.properties") | ||
if (propsFile.exists()) { | ||
propsFile.reader().use { | ||
Properties().apply { | ||
load(it) | ||
} | ||
}.onEach { (name, value) -> | ||
ext[name.toString()] = value | ||
} | ||
} | ||
|
||
val javadocJar by tasks.registering(Jar::class) { | ||
archiveClassifier.set("javadoc") | ||
} | ||
|
||
fun getExtraString(name: String) = ext[name]?.toString() | ||
|
||
publishing { | ||
// Configure maven central repository | ||
repositories { | ||
maven { | ||
name = "sonatype" | ||
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
credentials { | ||
username = getExtraString("ossrhUsername") | ||
password = getExtraString("ossrhPassword") | ||
} | ||
} | ||
} | ||
|
||
// Configure all publications | ||
publications.withType<MavenPublication> { | ||
// Stub javadoc.jar artifact | ||
artifact(javadocJar.get()) | ||
|
||
// Provide artifacts information requited by Maven Central | ||
pom { | ||
name.set(getExtraString("artifact.name")) | ||
description.set(getExtraString("artifact.desc")) | ||
url.set(getExtraString("artifact.url")) | ||
|
||
licenses { | ||
license { | ||
name.set("MIT") | ||
url.set("https://opensource.org/licenses/MIT") | ||
} | ||
} | ||
developers { | ||
developer { | ||
id.set("Piasy") | ||
name.set("Piasy Xu") | ||
email.set("[email protected]") | ||
} | ||
} | ||
scm { | ||
url.set(getExtraString("artifact.url")) | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Signing artifacts. Signing.* extra properties values will be used | ||
signing { | ||
sign(publishing.publications) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
pushd kmp-xlog/src/iosMain | ||
rm -rf build xlog.xcodeproj | ||
|
||
xcodegen | ||
|
||
xcodebuild clean | ||
xcodebuild -quiet -arch arm64 | ||
mv build/libxlog.a libs/os-arm64/libxlog.a | ||
|
||
xcodebuild clean | ||
xcodebuild -quiet -arch x86_64 -sdk iphonesimulator | ||
mv build/libxlog.a libs/sim-x64/libxlog.a | ||
|
||
xcodebuild clean | ||
xcodebuild -quiet -arch arm64 -sdk iphonesimulator | ||
mv build/libxlog.a libs/sim-arm64/libxlog.a | ||
|
||
rm -rf build | ||
|
||
popd | ||
|
||
./gradlew clean :kmp-xlog:podPublishReleaseXCFramework | ||
|
||
pushd kmp-xlog | ||
|
||
libtool -static -no_warning_for_no_symbols \ | ||
-o build/kmp_xlog-os-arm64 \ | ||
src/iosMain/frameworks/mars.xcframework/ios-arm64/mars.framework/mars \ | ||
src/iosMain/libs/os-arm64/libxlog.a \ | ||
build/cocoapods/publish/release/kmp_xlog.xcframework/ios-arm64/kmp_xlog.framework/kmp_xlog | ||
|
||
lipo -create src/iosMain/libs/sim-arm64/libxlog.a \ | ||
src/iosMain/libs/sim-x64/libxlog.a \ | ||
-output build/libxlog-sim-arm64-x64.a | ||
|
||
libtool -static -no_warning_for_no_symbols \ | ||
-o build/kmp_xlog-sim-arm64-x64 \ | ||
src/iosMain/frameworks/mars.xcframework/ios-arm64_x86_64-simulator/mars.framework/mars \ | ||
build/libxlog-sim-arm64-x64.a \ | ||
build/cocoapods/publish/release/kmp_xlog.xcframework/ios-arm64_x86_64-simulator/kmp_xlog.framework/kmp_xlog | ||
|
||
cp build/kmp_xlog-os-arm64 \ | ||
build/cocoapods/publish/release/kmp_xlog.xcframework/ios-arm64/kmp_xlog.framework/kmp_xlog | ||
|
||
cp build/kmp_xlog-sim-arm64-x64 \ | ||
build/cocoapods/publish/release/kmp_xlog.xcframework/ios-arm64_x86_64-simulator/kmp_xlog.framework/kmp_xlog | ||
|
||
popd | ||
|
||
cp LICENSE kmp-xlog/build/cocoapods/publish/release/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
py=$(python -c 'import sys; print(".".join(map(str, sys.version_info[0:1])))') | ||
if [[ "$py" != "2" ]]; then | ||
echo "Please use py2 env" | ||
exit | ||
fi | ||
|
||
# build mars xlog at first, with py2 env | ||
pushd mars | ||
printf '3\n' | env NDK_ROOT=/Users/piasy/tools/android-sdk/ndk/21.3.6528147 python mars/build_android.py | ||
popd | ||
|
||
cp mars/mars/libraries/mars_xlog_sdk/libs/armeabi-v7a/libc++_shared.so \ | ||
kmp-xlog/src/androidMain/jniLibs/armeabi-v7a/ | ||
cp mars/mars/libraries/mars_xlog_sdk/libs/arm64-v8a/libc++_shared.so \ | ||
kmp-xlog/src/androidMain/jniLibs/arm64-v8a/ | ||
cp mars/mars/libraries/mars_xlog_sdk/libs/x86/libc++_shared.so \ | ||
kmp-xlog/src/androidMain/jniLibs/x86/ | ||
cp mars/mars/libraries/mars_xlog_sdk/libs/x86_64/libc++_shared.so \ | ||
kmp-xlog/src/androidMain/jniLibs/x86_64/ | ||
|
||
cp mars/mars/libraries/mars_xlog_sdk/libs/armeabi-v7a/libmarsxlog.so \ | ||
kmp-xlog/src/androidMain/jniLibs/armeabi-v7a/ | ||
cp mars/mars/libraries/mars_xlog_sdk/libs/arm64-v8a/libmarsxlog.so \ | ||
kmp-xlog/src/androidMain/jniLibs/arm64-v8a/ | ||
cp mars/mars/libraries/mars_xlog_sdk/libs/x86/libmarsxlog.so \ | ||
kmp-xlog/src/androidMain/jniLibs/x86/ | ||
cp mars/mars/libraries/mars_xlog_sdk/libs/x86_64/libmarsxlog.so \ | ||
kmp-xlog/src/androidMain/jniLibs/x86_64/ | ||
|
||
cp mars/mars/libraries/mars_xlog_sdk/obj/local/armeabi-v7a/libc++_shared.so \ | ||
symbols/android/armeabi-v7a/ | ||
cp mars/mars/libraries/mars_xlog_sdk/obj/local/arm64-v8a/libc++_shared.so \ | ||
symbols/android/arm64-v8a/ | ||
cp mars/mars/libraries/mars_xlog_sdk/obj/local/x86/libc++_shared.so \ | ||
symbols/android/x86/ | ||
cp mars/mars/libraries/mars_xlog_sdk/obj/local/x86_64/libc++_shared.so \ | ||
symbols/android/x86_64/ | ||
|
||
cp mars/mars/libraries/mars_xlog_sdk/obj/local/armeabi-v7a/libmarsxlog.so \ | ||
symbols/android/armeabi-v7a/ | ||
cp mars/mars/libraries/mars_xlog_sdk/obj/local/arm64-v8a/libmarsxlog.so \ | ||
symbols/android/arm64-v8a/ | ||
cp mars/mars/libraries/mars_xlog_sdk/obj/local/x86/libmarsxlog.so \ | ||
symbols/android/x86/ | ||
cp mars/mars/libraries/mars_xlog_sdk/obj/local/x86_64/libmarsxlog.so \ | ||
symbols/android/x86_64/ | ||
|
||
cp mars/mars/libraries/mars_xlog_sdk/src/main/java/com/tencent/mars/xlog/Log.java \ | ||
mars/mars/libraries/mars_xlog_sdk/src/main/java/com/tencent/mars/xlog/Xlog.java \ | ||
kmp-xlog/src/androidMain/java/com/tencent/mars/xlog/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
py=$(python -c 'import sys; print(".".join(map(str, sys.version_info[0:1])))') | ||
if [[ "$py" != "2" ]]; then | ||
echo "Please use py2 env" | ||
exit | ||
fi | ||
|
||
# build mars xlog at first, with py2 env | ||
pushd mars/mars | ||
printf '2\n' | python build_ios.py | ||
popd | ||
|
||
rm -rf kmp-xlog/src/iosMain/frameworks/mars.xcframework | ||
cp -r mars/mars/cmake_build/iOS/Darwin.out/mars.xcframework kmp-xlog/src/iosMain/frameworks/ |
Oops, something went wrong.