Skip to content

Commit

Permalink
Use composite builds for gl-native and common (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
jush authored Oct 25, 2024
1 parent 2700dca commit eea9dff
Show file tree
Hide file tree
Showing 206 changed files with 38 additions and 96 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ commands:
store-results:
steps:
- store_artifacts:
path: sdk/build
path: maps-sdk/build
- store_artifacts:
path: LICENSE.md

Expand All @@ -142,7 +142,7 @@ commands:
name: Initialize developer access token for sdk tests
command: |
if [ -n "${MAPBOX_DEVELOPER_CONFIG_XML}" ]; then
echo "${MAPBOX_DEVELOPER_CONFIG_XML}" > sdk/src/androidTest/res/values/developer-config.xml
echo "${MAPBOX_DEVELOPER_CONFIG_XML}" > maps-sdk/src/androidTest/res/values/developer-config.xml
fi
- run:
name: Build << parameters.module_target >> instrumentation test apk
Expand Down Expand Up @@ -385,7 +385,7 @@ jobs:
name: check release runtime Mapbox dependencies to fail fast
command: |
echo "PR Target branch: $PR_TARGET_BRANCH"
./gradlew sdk:dependencyInsight --configuration releaseRuntimeClasspath --dependency com.mapbox.maps | grep -vzq 'FAILED'
./gradlew maps-sdk:dependencyInsight --configuration releaseRuntimeClasspath --dependency com.mapbox.maps | grep -vzq 'FAILED'
- run:
name: check changelog
command: |
Expand Down Expand Up @@ -620,7 +620,7 @@ jobs:
- mapbox-gl-native-begin
- login-google-cloud-platform
- run-firebase-instrumentation:
module_target: "sdk"
module_target: "maps-sdk"
multiple_devices: false
- mapbox-gl-native-end
- run: exit 0
Expand All @@ -633,7 +633,7 @@ jobs:
- read-from-workspace
- login-google-cloud-platform
- run-firebase-instrumentation:
module_target: "sdk"
module_target: "maps-sdk"
multiple_devices: true
- slack/notify:
event: fail
Expand Down Expand Up @@ -737,13 +737,13 @@ jobs:
- save-to-workspace:
path: "app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk"
- build-instrumentation-test:
module_target: "sdk"
module_target: "maps-sdk"
- save-to-workspace:
path: "sdk/build/outputs/apk/androidTest/debug/sdk-debug-androidTest.apk"
path: "maps-sdk/build/outputs/apk/androidTest/debug/maps-sdk-debug-androidTest.apk"
- build-instrumentation-test:
module_target: "module-telemetry"
- save-to-workspace:
path: "module-telemetry/build/outputs/apk/androidTest/debug/sdk-debug-androidTest.apk"
path: "module-telemetry/build/outputs/apk/androidTest/debug/module-telemetry-debug-androidTest.apk"
- store_artifacts:
path: app/build/outputs/apk
destination: .
Expand Down
6 changes: 3 additions & 3 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ This module enables us to independently develop other modules against interfaces
on any concrete implementation. By having this strict decoupling, we makes sure we think well about
the contracts a module has with other and what public API it exposes to consumers.

#### sdk
The sdk module is the main module developers integrate in their project. It contains the most
#### maps-sdk
The maps-sdk module is the main module developers integrate in their project. It contains the most
important building blocks of the product that couldn't have been decoupled from the underlying
c++ implementation at this time.

Expand Down Expand Up @@ -247,7 +247,7 @@ The CircleCI bot will wait for the Firebase test to finish, collect the results,
publish them as build artifact and fail/succeed accordingly.

Instrumentation tests are divided across 3 modules:
- sdk: contains instrumentation tests that validate C++ integration of the SDK
- maps-sdk: contains instrumentation tests that validate C++ integration of the SDK
- app: contains instrumentation tests that validate specific feature integrations
- extension-style-app: contains instrumentation tests for validating the style integration

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ License: [The Apache Software License, Version 2.0](http://www.apache.org/licens

===========================================================================

### MapboxCoreMaps,11.8.0-rc.1,Mapbox ToS,Mapbox,https://www.mapbox.com/
### MapboxCoreMaps,11.9.0-beta.1,Mapbox ToS,Mapbox,https://www.mapbox.com/

```
Mapbox Core Maps version 11.0
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ clean:

.PHONY: codecoverage
codecoverage:
./gradlew sdk:jacocoTestDebugUnitTestReport && google-chrome sdk/build/jacoco/jacocoHtml/index.html
./gradlew maps-sdk:jacocoTestDebugUnitTestReport && google-chrome maps-sdk/build/jacoco/jacocoHtml/index.html

.PHONY: unit-tests
unit-tests:
./gradlew test -i

.PHONY: instrumentation-tests
instrumentation-tests:
./gradlew sdk:connectedDebugAndroidTest && ./gradlew app:connectedDebugAndroidTest
./gradlew maps-sdk:connectedDebugAndroidTest && ./gradlew app:connectedDebugAndroidTest

.PHONY: instrumentation-clean
instrumentation-clean:
Expand Down
9 changes: 1 addition & 8 deletions android-auto-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id("com.mapbox.gradle.application")
}

val buildFromSource: String by project

android {
compileSdk = libs.versions.autoCompileSdkVersion.get().toInt()
Expand All @@ -27,12 +26,6 @@ android {
execution = "ANDROIDX_TEST_ORCHESTRATOR"
}
}

packagingOptions {
if (buildFromSource.toBoolean()) {
jniLibs.pickFirsts.add("**/libc++_shared.so")
}
}
}

dependencies {
Expand All @@ -41,7 +34,7 @@ dependencies {

// Please review the compatibility guide. This app is showcasing the latest features with latest Maps SDK main branch.
// https://github.com/mapbox/mapbox-maps-android/tree/main/extension-androidauto#compatibility-with-maps-sdk-v11
implementation(project(":sdk"))
implementation(project(":maps-sdk"))

implementation(libs.kotlin)
implementation(libs.androidx.appCompat)
Expand Down
9 changes: 1 addition & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ apply {
from("$rootDir/gradle/script-git-version.gradle")
from("$rootDir/gradle/play-publisher.gradle")
}
val buildFromSource: String by project

android {
compileSdk = libs.versions.exampleCompileSdkVersion.get().toInt()
Expand Down Expand Up @@ -84,16 +83,10 @@ android {
path = file("src/main/cpp/CMakeLists.txt")
}
}

packagingOptions {
if (buildFromSource.toBoolean()) {
jniLibs.pickFirsts.add("**/libc++_shared.so")
}
}
}

dependencies {
implementation(project(":sdk"))
implementation(project(":maps-sdk"))
implementation(libs.kotlin)
implementation(libs.mapbox.javaTurf)
implementation(libs.mapbox.javaGeoJSON)
Expand Down
9 changes: 1 addition & 8 deletions compose-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
id("org.jetbrains.kotlin.plugin.parcelize")
}

val buildFromSource: String by project

android {
compileSdk = libs.versions.androidCompileSdkVersion.get().toInt()
Expand Down Expand Up @@ -54,19 +53,13 @@ android {
}
}

packagingOptions {
if (buildFromSource.toBoolean()) {
jniLibs.pickFirsts.add("**/libc++_shared.so")
}
}

buildFeatures {
compose = true
}
}

dependencies {
implementation(project(":sdk"))
implementation(project(":maps-sdk"))
implementation(project(":extension-compose"))
implementation(platform(libs.compose.bom))
implementation(libs.compose.ui)
Expand Down
2 changes: 1 addition & 1 deletion extension-androidauto/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mapboxLibrary {
}

dependencies {
api(project(":sdk"))
api(project(":maps-sdk"))
api(libs.googleCarAppLibrary)
implementation(libs.kotlin)
implementation(libs.androidx.coreKtx)
Expand Down
6 changes: 3 additions & 3 deletions extension-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mapboxLibrary {

dependencies {
dependencies {
compileOnly(project(":sdk"))
compileOnly(project(":maps-sdk"))
implementation(platform(libs.compose.bom))
implementation(libs.mapbox.javaGeoJSON)
implementation(libs.compose.ui)
Expand All @@ -67,11 +67,11 @@ dependencies {
androidTestImplementation(libs.androidx.testJUnit)
androidTestImplementation(libs.androidx.espresso)
androidTestImplementation(libs.androidx.uiAutomator)
androidTestImplementation(project(":sdk"))
androidTestImplementation(project(":maps-sdk"))
androidTestImplementation(libs.compose.uiTest)

testImplementation(libs.bundles.base.dependenciesTests)
testImplementation(project(":sdk"))
testImplementation(project(":maps-sdk"))
testImplementation(libs.junit)

detektPlugins(libs.detektFormatting)
Expand Down
8 changes: 1 addition & 7 deletions extension-style-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
id("com.mapbox.maps.token")
}

val buildFromSource: String by project

android {
compileSdk = libs.versions.androidCompileSdkVersion.get().toInt()
Expand All @@ -29,15 +28,10 @@ android {
}
}

packagingOptions {
if (buildFromSource.toBoolean()) {
jniLibs.pickFirsts.add("**/libc++_shared.so")
}
}
}

dependencies {
implementation(project(":sdk"))
implementation(project(":maps-sdk"))
implementation(libs.kotlin)
implementation(libs.androidx.appCompat)
androidTestUtil(libs.androidx.orchestrator)
Expand Down
4 changes: 1 addition & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ kotlin.code.style=official
# https://issuetracker.google.com/issues/172784894
# android.jetifier.blacklist=bcprov-jdk15on
android.jetifier.ignorelist=bcprov-jdk15on
# Internal build flag to build the full mapbox stack from source versus using binaries
# Internal build flag to build from source.
buildFromSource=false
# Internal build flag to build build maps-core based on source of common-sdk.
buildCommonFromSource=false
# Disable ksp incremental feature due to ksp bug in https://github.com/google/ksp/issues/1280
ksp.incremental=false
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ internal constructor(
private val enabledProperty: Property<Boolean> = objects.property<Boolean>().convention(false)
private val configurationProperty: ListProperty<String> =
objects.listProperty<String>().convention(listOf("implementation"))
private val buildFromSourceProperty: Property<Boolean> =
objects.property<Boolean>().convention(false)

/**
* True if this dependency should be added.
Expand Down Expand Up @@ -54,20 +52,10 @@ internal constructor(
configurationProperty.setDisallowChanges(value)
}

/**
* True if this dependency should instead be built from source.
*/
@Suppress("MemberVisibilityCanBePrivate")
public var buildFromSource: Boolean
get() = buildFromSourceProperty.get()
set(value) {
buildFromSourceProperty.setDisallowChanges(value)
}

internal fun applyTo(project: Project) = project.afterEvaluate {
if (enabled) {
this@MapboxDependencyExtension.configurations.forEach { configuration ->
dependency.add(this, configuration, buildFromSource)
dependency.add(this, configuration)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,39 @@ import org.gradle.api.Project
* @param group The dependency group ID
* @param artifact The dependency artifact ID
* @param snapshotArtifact The dependency artifact ID to use if the version contains `-SNAPSHOT`
* @param sourceProject The Gradle project module name if this [Dependency] can also be built from
* source within this Gradle project.
* @param supportsNdkVariant True if this dependency also publishes variants for different NDKs.
* The NDK will be suffixed to the artifact ID.
*/
internal abstract class BaseDependency(
open val group: String,
open val artifact: String,
open val snapshotArtifact: String = artifact,
open val sourceProject: String? = null,
open val supportsNdkVariant: Boolean = false,
) {
abstract fun resolveVersion(project: Project): String

fun add(project: Project, configuration: String, buildFromSource: Boolean) {
if (buildFromSource) {
project.dependencies.add(configuration, project.project(sourceProject!!))
fun add(project: Project, configuration: String) {
val version = resolveVersion(project)
var artifactId = if (version.contains("-SNAPSHOT")) {
snapshotArtifact
} else {
val version = resolveVersion(project)
var artifactId = if (version.contains("-SNAPSHOT")) {
snapshotArtifact
} else {
artifact
}
if (supportsNdkVariant) {
artifactId = project.appendNdkIfNeeded(artifactId)
}
val coordinates = "${group}:$artifactId:$version"
project.dependencies.add(configuration, coordinates)
artifact
}
if (supportsNdkVariant) {
artifactId = project.appendNdkIfNeeded(artifactId)
}
val coordinates = "${group}:$artifactId:$version"
project.dependencies.add(configuration, coordinates)
}
}

internal data class Dependency(
override val group: String,
override val artifact: String,
private val version: String,
override val sourceProject: String? = null,
override val snapshotArtifact: String = artifact,
override val supportsNdkVariant: Boolean = false,
) : BaseDependency(group, artifact, snapshotArtifact, sourceProject, supportsNdkVariant) {
) : BaseDependency(group, artifact, snapshotArtifact, supportsNdkVariant) {
override fun resolveVersion(project: Project): String = version
}

Expand All @@ -59,10 +51,9 @@ internal data class VersionCatalogDependency(
override val artifact: String,
private val versionRef: String,
private val catalogName: String = "libs",
override val sourceProject: String? = null,
override val snapshotArtifact: String = artifact,
override val supportsNdkVariant: Boolean = false,
) : BaseDependency(group, artifact, snapshotArtifact, sourceProject, supportsNdkVariant) {
) : BaseDependency(group, artifact, snapshotArtifact, supportsNdkVariant) {

override fun resolveVersion(project: Project): String =
project.getVersionCatalog(catalogName).findVersion(versionRef).get().toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ internal object MapboxDependencies {
group = "com.mapbox.common",
artifact = "common",
versionRef = "mapboxCommon",
sourceProject = ":common",
supportsNdkVariant = true
)

internal val GlNative = VersionCatalogDependency(
group = "com.mapbox.maps",
artifact = "android-core",
versionRef = "mapboxGlNative",
sourceProject = ":maps-core",
snapshotArtifact = "android-core-internal",
supportsNdkVariant = true
)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sdk/api/sdk.api → maps-sdk/api/maps-sdk.api
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ public class com/mapbox/maps/renderer/widget/BitmapWidget : com/mapbox/maps/rend
public synthetic fun <init> (Landroid/graphics/Bitmap;Lcom/mapbox/maps/renderer/widget/WidgetPosition;FILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Landroid/graphics/Bitmap;Lcom/mapbox/maps/renderer/widget/WidgetPosition;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getPosition ()Lcom/mapbox/maps/renderer/widget/WidgetPosition;
public synthetic fun getRenderer$sdk_release ()Lcom/mapbox/maps/renderer/widget/WidgetRenderer;
public synthetic fun getRenderer$maps_sdk_release ()Lcom/mapbox/maps/renderer/widget/WidgetRenderer;
public fun getRotation ()F
public fun setPosition (Lcom/mapbox/maps/renderer/widget/WidgetPosition;)V
public fun setRotation (F)V
Expand Down
2 changes: 0 additions & 2 deletions sdk/build.gradle.kts → maps-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ plugins {
//id("com.mapbox.android.sdk.versions")
}

val buildFromSource: String by project

mapboxLibrary {
dokka {
// Include extra list of files to generate documentation if available
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit eea9dff

Please sign in to comment.