Skip to content

Commit

Permalink
Add compose support for android_instrumentation_binary (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
minkuan88 authored Mar 29, 2024
1 parent a84d8b5 commit 90ef85b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "grab_bazel_common",
commit = "092435fb286705c4dcd845c93c9d84e94a4088d9",
commit = "7ce14f2063b19b1e700bb9fa51cc944626545450",
remote = "https://github.com/grab/grab-bazel-common.git",
)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ grazel {
rules {
bazelCommon {
gitRepository {
commit = "092435fb286705c4dcd845c93c9d84e94a4088d9"
commit = "7ce14f2063b19b1e700bb9fa51cc944626545450"
remote = "https://github.com/grab/grab-bazel-common.git"
}
toolchains {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ fun StatementsBuilder.androidInstrumentationBinary(
resourceStripPrefix: String? = null,
resourceFiles: List<Assignee> = emptyList(),
testInstrumentationRunner: String? = null,
enableCompose: Boolean = false,
) {
load(
"@$GRAB_BAZEL_COMMON//rules:defs.bzl",
Expand Down Expand Up @@ -377,5 +378,9 @@ fun StatementsBuilder.androidInstrumentationBinary(
testInstrumentationRunner?.let {
"test_instrumentation_runner" `=` it.quote
}

if (enableCompose) {
"enable_compose" `=` enableCompose.toString().capitalize()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ internal data class AndroidInstrumentationBinaryData(
val resourceStripPrefix: String? = null,
val srcs: List<String>,
val testInstrumentationRunner: String? = null,
val compose: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.grab.grazel.gradle.dependencies.BuildGraphType
import com.grab.grazel.gradle.dependencies.DependenciesDataSource
import com.grab.grazel.gradle.dependencies.DependencyGraphs
import com.grab.grazel.gradle.dependencies.GradleDependencyToBazelDependency
import com.grab.grazel.gradle.hasCompose
import com.grab.grazel.gradle.variant.AndroidVariantDataSource
import com.grab.grazel.gradle.variant.MatchedVariant
import com.grab.grazel.gradle.variant.getMigratableBuildVariants
Expand Down Expand Up @@ -144,6 +145,7 @@ internal class DefaultAndroidInstrumentationBinaryDataExtractor
srcs = srcs,
testInstrumentationRunner = testInstrumentationRunner,
manifestValues = manifestValues,
compose = hasCompose,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal data class AndroidInstrumentationBinaryTarget(
val resourceStripPrefix: String? = null,
val resourceFiles: List<String>,
val testInstrumentationRunner: String? = null,
val compose: Boolean,
) : BazelBuildTarget {

override fun statements(builder: StatementsBuilder) = builder {
Expand All @@ -56,6 +57,7 @@ internal data class AndroidInstrumentationBinaryTarget(
resourceStripPrefix = resourceStripPrefix,
resourceFiles = buildResFiles(resourceFiles),
testInstrumentationRunner = testInstrumentationRunner,
enableCompose = compose,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ internal class AndroidInstrumentationBinaryTargetBuilder
resourceFiles = resourceFiles,
srcs = srcs,
testInstrumentationRunner = testInstrumentationRunner,
compose = compose,
)
}

Expand Down
4 changes: 4 additions & 0 deletions sample-android/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ android_instrumentation_binary(
],
custom_package = "com.grab.grazel.android.sample",
debug_key = "//buildsystem:debug-keystore",
enable_compose = True,
instruments = ":sample-android-flavor1-free-debug",
manifest_values = {
"versionCode": "1",
Expand Down Expand Up @@ -472,6 +473,7 @@ android_instrumentation_binary(
],
custom_package = "com.grab.grazel.android.sample",
debug_key = "//buildsystem:debug-keystore",
enable_compose = True,
instruments = ":sample-android-flavor1-paid-debug",
manifest_values = {
"versionCode": "1",
Expand Down Expand Up @@ -527,6 +529,7 @@ android_instrumentation_binary(
],
custom_package = "com.grab.grazel.android.sample",
debug_key = "//buildsystem:debug-keystore",
enable_compose = True,
instruments = ":sample-android-flavor2-free-debug",
manifest_values = {
"versionCode": "1",
Expand Down Expand Up @@ -582,6 +585,7 @@ android_instrumentation_binary(
],
custom_package = "com.grab.grazel.android.sample",
debug_key = "//buildsystem:debug-keystore",
enable_compose = True,
instruments = ":sample-android-flavor2-paid-debug",
manifest_values = {
"versionCode": "1",
Expand Down

0 comments on commit 90ef85b

Please sign in to comment.