Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Standardize architectures #249

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ internal abstract class DdNdkSymbolFileUploadTask @Inject constructor(
.toSet()
.forEach { file ->
val arch = file.parentFile.name
require(SUPPORTED_ARCHS.contains(arch))
val archMapping = SUPPORTED_ARCHS.firstOrNull { it.arch == arch }
require(archMapping != null)
files.add(
Uploader.UploadFileInfo(
KEY_NDK_SYMBOL_FILE,
Expand All @@ -51,7 +52,7 @@ internal abstract class DdNdkSymbolFileUploadTask @Inject constructor(
TYPE_NDK_SYMBOL_FILE,
file.name,
mapOf(
"arch" to arch
"arch" to archMapping.uploadArch
)
)
)
Expand All @@ -70,12 +71,23 @@ internal abstract class DdNdkSymbolFileUploadTask @Inject constructor(
}
}

// Map of Android architecture names to the architecture names recognized by the symbolication service
data class SupportedArchitectureMapping(
val arch: String,
val uploadArch: String
)

companion object {
internal const val TASK_NAME = "uploadNdkSymbolFiles"
internal const val KEY_NDK_SYMBOL_FILE = "ndk_symbol_file"
internal const val TYPE_NDK_SYMBOL_FILE = "ndk_symbol_file"
internal const val ENCODING = "application/octet-stream"
internal val SUPPORTED_ARCHS = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
internal val SUPPORTED_ARCHS = setOf(
SupportedArchitectureMapping("armeabi-v7a", "arm"),
SupportedArchitectureMapping("arm64-v8a", "arm64"),
SupportedArchitectureMapping("x86", "x86"),
SupportedArchitectureMapping("x86_64", "x64")
)
Comment on lines +85 to +90
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like could be simply mapOf<String, String>, without introducing data class. But not a big deal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was curious about that. I could go either way but I figured the data class was more descriptive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just lookup is now linear instead of O(1), but it doesn't really matter here


internal val LOGGER = Logging.getLogger("DdSymbolFileUploadTask")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ internal class DdAndroidGradlePluginFunctionalTest {
"`build_id:$buildIdInOriginFile` (site=datadoghq.com):"
)

for (arch in SUPPORTED_ABIS) {
for (arch in SUPPORTED_ABIS.values) {
assertThat(result).containsInOutput("extra attributes: {arch=$arch}")
}
}
Expand Down Expand Up @@ -1054,7 +1054,7 @@ internal class DdAndroidGradlePluginFunctionalTest {
"`build_id:$buildIdInOriginFile` (site=datadoghq.com):"
)

for (arch in SUPPORTED_ABIS) {
for (arch in SUPPORTED_ABIS.values) {
assertThat(result).containsInOutput("extra attributes: {arch=$arch}")
}
}
Expand Down Expand Up @@ -1119,7 +1119,7 @@ internal class DdAndroidGradlePluginFunctionalTest {
"`build_id:$buildIdInOriginFile` (site=datadoghq.com):"
)

for (arch in SUPPORTED_ABIS) {
for (arch in SUPPORTED_ABIS.values) {
assertThat(nativeResult).containsInOutput("extra attributes: {arch=$arch}")
}

Expand Down Expand Up @@ -1228,7 +1228,12 @@ internal class DdAndroidGradlePluginFunctionalTest {
val jvmTarget: String
)

val SUPPORTED_ABIS = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
val SUPPORTED_ABIS = mapOf(
"armeabi-v7a" to "arm",
"arm64-v8a" to "arm64",
"x86" to "x86",
"x86_64" to "x64"
)

val APPLICATION_CLASS_CONTENT = """
package com.datadog.android.sample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ internal class DdNdkSymbolFileUploadTaskTest {
fileType = DdNdkSymbolFileUploadTask.TYPE_NDK_SYMBOL_FILE,
fileName = "libfake.so",
extraAttributes = mapOf(
"arch" to "arm64-v8a"
"arch" to "arm64"
)
),
fakeRepositoryFile,
Expand All @@ -178,7 +178,7 @@ internal class DdNdkSymbolFileUploadTaskTest {
whenever(mockRepositoryDetector.detectRepositories(any(), eq("")))
.doReturn(listOf(fakeRepoInfo))
val fakeSoFiles = mapOf(
"arm64-v8a" to writeFakeSoFile("arm64-v8a"),
"arm64" to writeFakeSoFile("arm64-v8a"),
"x86" to writeFakeSoFile("x86")
)

Expand Down Expand Up @@ -240,7 +240,7 @@ internal class DdNdkSymbolFileUploadTaskTest {
fileType = DdNdkSymbolFileUploadTask.TYPE_NDK_SYMBOL_FILE,
fileName = "libfake.so",
extraAttributes = mapOf(
"arch" to "arm64-v8a"
"arch" to "arm64"
)
),
fakeRepositoryFile,
Expand Down Expand Up @@ -283,7 +283,7 @@ internal class DdNdkSymbolFileUploadTaskTest {
fileType = DdNdkSymbolFileUploadTask.TYPE_NDK_SYMBOL_FILE,
fileName = "libfake.so",
extraAttributes = mapOf(
"arch" to "arm64-v8a"
"arch" to "arm64"
)
),
null,
Expand Down Expand Up @@ -328,7 +328,7 @@ internal class DdNdkSymbolFileUploadTaskTest {
forge.anElementFrom("\"", "'") +
it.substring(splitIndex)
}
writeFakeSoFile("arm64-v8a")
writeFakeSoFile("arm64")

// When
val exception = assertThrows<IllegalStateException> {
Expand Down Expand Up @@ -416,7 +416,7 @@ internal class DdNdkSymbolFileUploadTaskTest {
fileType = DdNdkSymbolFileUploadTask.TYPE_NDK_SYMBOL_FILE,
fileName = "libfake.so",
extraAttributes = mapOf(
"arch" to "arm64-v8a"
"arch" to "arm64"
)
),
fakeRepositoryFile,
Expand Down
Loading