Skip to content

Commit

Permalink
[NDK] Properly apply code formatting (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
markushi authored Nov 19, 2024
1 parent 113d261 commit d8230a8
Show file tree
Hide file tree
Showing 14 changed files with 528 additions and 428 deletions.
21 changes: 21 additions & 0 deletions ndk/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.PHONY: all clean compile format api check

all: clean format compile api check

clean:
./gradlew clean

compile:
./gradlew build

# Format code using the spotless gradle plugin
format:
./gradlew spotlessApply

# Creates the .api dump file
api:
./gradlew :sentry-native-ndk:apiDump

# Run tests and lint
check:
./gradlew check
60 changes: 37 additions & 23 deletions ndk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.diffplug.gradle.spotless.SpotlessPlugin
import com.diffplug.spotless.LineEnding
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishPlugin
Expand All @@ -9,11 +10,10 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
`java-library`
id("com.diffplug.spotless") version "6.11.0" apply true
id("com.diffplug.spotless") version "6.25.0" apply true
id("io.gitlab.arturbosch.detekt") version "1.19.0"
`maven-publish`
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.0"

}

buildscript {
Expand Down Expand Up @@ -46,11 +46,12 @@ allprojects {
withType<Test> {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = TestExceptionFormat.FULL
testLogging.events = setOf(
TestLogEvent.SKIPPED,
TestLogEvent.PASSED,
TestLogEvent.FAILED
)
testLogging.events =
setOf(
TestLogEvent.SKIPPED,
TestLogEvent.PASSED,
TestLogEvent.FAILED,
)
maxParallelForks = Runtime.getRuntime().availableProcessors() / 2

// Cap JVM args per test
Expand All @@ -59,7 +60,7 @@ allprojects {
dependsOn("cleanTest")
}
withType<JavaCompile> {
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing"))
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing", "-Xlint:-options"))
}
}
}
Expand Down Expand Up @@ -127,6 +128,8 @@ subprojects {
}
}
}

apply<SpotlessPlugin>()
}

spotless {
Expand All @@ -139,21 +142,25 @@ spotless {
}
kotlin {
target("**/*.kt")
targetExclude("**/generated/**")
ktlint()
}
kotlinGradle {
target("**/*.kts")
targetExclude("**/generated/**")
ktlint()
}
}

private val androidLibs = setOf(
"lib"
)
private val androidLibs =
setOf(
"lib",
)

private val androidXLibs = listOf(
"androidx.core:core"
)
private val androidXLibs =
listOf(
"androidx.core:core",
)

/*
* Adapted from https://github.com/androidx/androidx/blob/c799cba927a71f01ea6b421a8f83c181682633fb/buildSrc/private/src/main/kotlin/androidx/build/MavenUploadHelper.kt#L524-L549
Expand All @@ -178,22 +185,25 @@ private val androidXLibs = listOf(
fun MavenPublishBaseExtension.assignAarTypes() {
pom {
withXml {
val dependencies = asNode().children().find {
it is Node && it.name().toString().endsWith("dependencies")
} as Node?
val dependencies =
asNode().children().find {
it is Node && it.name().toString().endsWith("dependencies")
} as Node?

dependencies?.children()?.forEach { dep ->
if (dep !is Node) {
return@forEach
}
val group = dep.children().firstOrNull {
it is Node && it.name().toString().endsWith("groupId")
} as? Node
val group =
dep.children().firstOrNull {
it is Node && it.name().toString().endsWith("groupId")
} as? Node
val groupValue = group?.children()?.firstOrNull() as? String

val artifactId = dep.children().firstOrNull {
it is Node && it.name().toString().endsWith("artifactId")
} as? Node
val artifactId =
dep.children().firstOrNull {
it is Node && it.name().toString().endsWith("artifactId")
} as? Node
val artifactIdValue = artifactId?.children()?.firstOrNull() as? String

if (artifactIdValue in androidLibs) {
Expand All @@ -205,3 +215,7 @@ fun MavenPublishBaseExtension.assignAarTypes() {
}
}
}

apiValidation {
ignoredProjects.addAll(listOf("sample"))
}
2 changes: 2 additions & 0 deletions ndk/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ POM_ARTIFACT_ID=sentry-native-ndk
systemProp.org.gradle.internal.http.socketTimeout=120000

android.nonTransitiveRClass=true

android.suppressUnsupportedCompileSdk=34
29 changes: 0 additions & 29 deletions ndk/lib/api/sentry-android-ndk.api

This file was deleted.

83 changes: 83 additions & 0 deletions ndk/lib/api/sentry-native-ndk.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
public final class io/sentry/ndk/BuildConfig {
public static final field BUILD_TYPE Ljava/lang/String;
public static final field DEBUG Z
public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String;
public fun <init> ()V
}

public final class io/sentry/ndk/DebugImage {
public fun <init> ()V
public fun getArch ()Ljava/lang/String;
public fun getCodeFile ()Ljava/lang/String;
public fun getCodeId ()Ljava/lang/String;
public fun getDebugFile ()Ljava/lang/String;
public fun getDebugId ()Ljava/lang/String;
public fun getImageAddr ()Ljava/lang/String;
public fun getImageSize ()Ljava/lang/Long;
public fun getType ()Ljava/lang/String;
public fun getUuid ()Ljava/lang/String;
public fun setArch (Ljava/lang/String;)V
public fun setCodeFile (Ljava/lang/String;)V
public fun setCodeId (Ljava/lang/String;)V
public fun setDebugFile (Ljava/lang/String;)V
public fun setDebugId (Ljava/lang/String;)V
public fun setImageAddr (Ljava/lang/String;)V
public fun setImageSize (J)V
public fun setImageSize (Ljava/lang/Long;)V
public fun setType (Ljava/lang/String;)V
public fun setUuid (Ljava/lang/String;)V
}

public abstract interface class io/sentry/ndk/INativeScope {
public abstract fun addBreadcrumb (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public abstract fun removeExtra (Ljava/lang/String;)V
public abstract fun removeTag (Ljava/lang/String;)V
public abstract fun removeUser ()V
public abstract fun setExtra (Ljava/lang/String;Ljava/lang/String;)V
public abstract fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public abstract fun setUser (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
}

public final class io/sentry/ndk/NativeModuleListLoader {
public fun <init> ()V
public fun clearModuleList ()V
public fun loadModuleList ()[Lio/sentry/ndk/DebugImage;
public static fun nativeClearModuleList ()V
public static fun nativeLoadModuleList ()[Lio/sentry/ndk/DebugImage;
}

public final class io/sentry/ndk/NativeScope : io/sentry/ndk/INativeScope {
public fun <init> ()V
public fun addBreadcrumb (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public static fun nativeAddBreadcrumb (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public static fun nativeRemoveExtra (Ljava/lang/String;)V
public static fun nativeRemoveTag (Ljava/lang/String;)V
public static fun nativeRemoveUser ()V
public static fun nativeSetExtra (Ljava/lang/String;Ljava/lang/String;)V
public static fun nativeSetTag (Ljava/lang/String;Ljava/lang/String;)V
public static fun nativeSetUser (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public fun removeExtra (Ljava/lang/String;)V
public fun removeTag (Ljava/lang/String;)V
public fun removeUser ()V
public fun setExtra (Ljava/lang/String;Ljava/lang/String;)V
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setUser (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
}

public final class io/sentry/ndk/NdkOptions {
public fun <init> (Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V
public fun getDist ()Ljava/lang/String;
public fun getDsn ()Ljava/lang/String;
public fun getEnvironment ()Ljava/lang/String;
public fun getMaxBreadcrumbs ()I
public fun getOutboxPath ()Ljava/lang/String;
public fun getRelease ()Ljava/lang/String;
public fun getSdkName ()Ljava/lang/String;
public fun isDebug ()Z
}

public final class io/sentry/ndk/SentryNdk {
public static fun close ()V
public static fun init (Lio/sentry/ndk/NdkOptions;)V
}

Loading

0 comments on commit d8230a8

Please sign in to comment.