Skip to content

Commit cf66975

Browse files
More fixes for dev deps (#296)
* More fixes for dev deps This should fix some BCR issues * bump
1 parent e1ec09a commit cf66975

File tree

12 files changed

+118
-105
lines changed

12 files changed

+118
-105
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module(
22
name = "bazel-diff",
3-
version = "12.1.0",
3+
version = "12.1.1",
44
compatibility_level = 0,
55
)
66

MODULE.bazel.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ release_deploy_jar:
1313
build \
1414
//cli:bazel-diff_deploy.jar \
1515
-c opt
16+
17+
.PHONY: format
18+
format:
19+
bazelisk run //cli/format

cli/BUILD

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
21
load("@rules_java//java:defs.bzl", "java_binary")
32
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library", "kt_jvm_test")
43

@@ -143,10 +142,5 @@ java_binary(
143142
name = "ktfmt",
144143
main_class = "com.facebook.ktfmt.cli.Main",
145144
runtime_deps = ["@ktfmt//jar"],
146-
)
147-
148-
format_multirun(
149-
name = "format",
150-
kotlin = ":ktfmt",
151-
visibility = ["//visibility:public"],
145+
visibility = ["//cli/format:__pkg__"],
152146
)

cli/format/BUILD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
2+
3+
format_multirun(
4+
name = "format",
5+
kotlin = "//cli:ktfmt",
6+
visibility = ["//visibility:public"],
7+
)

cli/src/main/kotlin/com/bazel_diff/bazel/BazelClient.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ class BazelClient(
3636
// show up in
3737
// `configuredRuleInput`. Hence, one must not filter them out with `kind(rule, deps(..))`.
3838
val mainTargets = queryService.query("deps(//...:all-targets)", useCquery = true)
39-
val repoTargets = if (repoTargetsQuery.isNotEmpty()) {
40-
queryService.query(repoTargetsQuery.joinToString(" + ") { "'$it'" })
41-
} else {
42-
emptyList()
43-
}
39+
val repoTargets =
40+
if (repoTargetsQuery.isNotEmpty()) {
41+
queryService.query(repoTargetsQuery.joinToString(" + ") { "'$it'" })
42+
} else {
43+
emptyList()
44+
}
4445
(mainTargets + repoTargets).distinctBy { it.name }
4546
} else {
4647
val buildTargetsQuery =

cli/src/main/kotlin/com/bazel_diff/bazel/BazelQueryService.kt

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import kotlinx.coroutines.runBlocking
1313
import org.koin.core.component.KoinComponent
1414
import org.koin.core.component.inject
1515

16-
private val versionComparator = compareBy<Triple<Int, Int, Int>> { it.first }
17-
.thenBy { it.second }
18-
.thenBy { it.third }
16+
private val versionComparator =
17+
compareBy<Triple<Int, Int, Int>> { it.first }.thenBy { it.second }.thenBy { it.third }
1918

2019
class BazelQueryService(
2120
private val workingDirectory: Path,
@@ -27,27 +26,26 @@ class BazelQueryService(
2726
private val noBazelrc: Boolean,
2827
) : KoinComponent {
2928
private val logger: Logger by inject()
30-
private val version: Triple<Int, Int, Int> by lazy {
31-
runBlocking { determineBazelVersion() }
32-
}
29+
private val version: Triple<Int, Int, Int> by lazy { runBlocking { determineBazelVersion() } }
3330

3431
@OptIn(ExperimentalCoroutinesApi::class)
3532
private suspend fun determineBazelVersion(): Triple<Int, Int, Int> {
3633
val cmd = arrayOf(bazelPath.toString(), "--version")
3734
logger.i { "Executing Bazel version command: ${cmd.joinToString()}" }
38-
val result = process(
39-
*cmd,
40-
stdout = Redirect.CAPTURE,
41-
workingDirectory = workingDirectory.toFile(),
42-
stderr = Redirect.PRINT,
43-
destroyForcibly = true,
44-
)
35+
val result =
36+
process(
37+
*cmd,
38+
stdout = Redirect.CAPTURE,
39+
workingDirectory = workingDirectory.toFile(),
40+
stderr = Redirect.PRINT,
41+
destroyForcibly = true,
42+
)
4543

4644
if (result.resultCode != 0) {
4745
throw RuntimeException("Bazel version command failed, exit code ${result.resultCode}")
4846
}
4947

50-
if (result.output.size != 1 || !result.output.first().startsWith("bazel ")) {
48+
if (result.output.size != 1 || !result.output.first().startsWith("bazel ")) {
5149
throw RuntimeException("Bazel version command returned unexpected output: ${result.output}")
5250
}
5351
// Trim off any prerelease suffixes.
@@ -56,12 +54,14 @@ class BazelQueryService(
5654
return Triple(version[0], version[1], version[2])
5755
}
5856

59-
// Use streamed_proto output for cquery if available. This is more efficient than the proto output.
57+
// Use streamed_proto output for cquery if available. This is more efficient than the proto
58+
// output.
6059
// https://github.com/bazelbuild/bazel/commit/607d0f7335f95aa0ee236ba3c18ce2a232370cdb
6160
private val canUseStreamedProtoWithCquery
6261
get() = versionComparator.compare(version, Triple(7, 0, 0)) >= 0
6362

64-
// Use an output file for (c)query if supported. This avoids excessively large stdout, which is sent out on the BES.
63+
// Use an output file for (c)query if supported. This avoids excessively large stdout, which is
64+
// sent out on the BES.
6565
// https://github.com/bazelbuild/bazel/commit/514e9052f2c603c53126fbd9436bdd3ad3a1b0c7
6666
private val canUseOutputFile
6767
get() = versionComparator.compare(version, Triple(8, 2, 0)) >= 0
@@ -87,20 +87,21 @@ class BazelQueryService(
8787
outputFile.inputStream().buffered().use { proto ->
8888
if (useCquery) {
8989
if (canUseStreamedProtoWithCquery) {
90-
mutableListOf<AnalysisProtosV2.CqueryResult>()
91-
.apply {
92-
while (true) {
93-
val result = AnalysisProtosV2.CqueryResult.parseDelimitedFrom(proto) ?: break
94-
// EOF
95-
add(result)
96-
}
90+
mutableListOf<AnalysisProtosV2.CqueryResult>()
91+
.apply {
92+
while (true) {
93+
val result =
94+
AnalysisProtosV2.CqueryResult.parseDelimitedFrom(proto) ?: break
95+
// EOF
96+
add(result)
97+
}
98+
}
99+
.flatMap { it.resultsList }
100+
} else {
101+
AnalysisProtosV2.CqueryResult.parseFrom(proto).resultsList
97102
}
98-
.flatMap { it.resultsList }
99-
} else {
100-
AnalysisProtosV2.CqueryResult.parseFrom(proto).resultsList
101-
}
102-
.mapNotNull { toBazelTarget(it.target) }
103-
.filter { it.name in compatibleTargetSet }
103+
.mapNotNull { toBazelTarget(it.target) }
104+
.filter { it.name in compatibleTargetSet }
104105
} else {
105106
mutableListOf<Build.Target>()
106107
.apply {
@@ -167,8 +168,7 @@ class BazelQueryService(
167168
return str(target.label)
168169
return ""
169170
"""
170-
.trimIndent()
171-
)
171+
.trimIndent())
172172
add(cqueryStarlarkFile.toString())
173173
} else {
174174
add(if (canUseStreamedProtoWithCquery) "streamed_proto" else "proto")
@@ -199,17 +199,19 @@ class BazelQueryService(
199199

200200
logger.i { "Executing Query: $query" }
201201
logger.i { "Command: ${cmd.toTypedArray().joinToString()}" }
202-
val result = process(
203-
*cmd.toTypedArray(),
204-
stdout = if (canUseOutputFile) Redirect.SILENT else Redirect.ToFile(outputFile),
205-
workingDirectory = workingDirectory.toFile(),
206-
stderr = Redirect.PRINT,
207-
destroyForcibly = true,
208-
)
202+
val result =
203+
process(
204+
*cmd.toTypedArray(),
205+
stdout = if (canUseOutputFile) Redirect.SILENT else Redirect.ToFile(outputFile),
206+
workingDirectory = workingDirectory.toFile(),
207+
stderr = Redirect.PRINT,
208+
destroyForcibly = true,
209+
)
209210

210211
if (!allowedExitCodes.contains(result.resultCode)) {
211-
logger.w { "Bazel query failed, output: ${result.output.joinToString("\n")}" }
212-
throw RuntimeException("Bazel query failed, exit code ${result.resultCode}, allowed exit codes: ${allowedExitCodes.joinToString()}")
212+
logger.w { "Bazel query failed, output: ${result.output.joinToString("\n")}" }
213+
throw RuntimeException(
214+
"Bazel query failed, exit code ${result.resultCode}, allowed exit codes: ${allowedExitCodes.joinToString()}")
213215
}
214216
return outputFile
215217
}

cli/src/main/kotlin/com/bazel_diff/cli/GenerateHashesCommand.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ class GenerateHashesCommand : Callable<Int> {
7979
var fineGrainedHashExternalRepos: Set<String> = emptySet()
8080

8181
@CommandLine.Option(
82-
names = ["--fineGrainedHashExternalReposFile"],
83-
description =
84-
[
85-
"A text file containing a newline separated list of external repos. Similar to --fineGrainedHashExternalRepos but helps you avoid exceeding max arg length. Mutually exclusive with --fineGrainedHashExternalRepos."])
82+
names = ["--fineGrainedHashExternalReposFile"],
83+
description =
84+
[
85+
"A text file containing a newline separated list of external repos. Similar to --fineGrainedHashExternalRepos but helps you avoid exceeding max arg length. Mutually exclusive with --fineGrainedHashExternalRepos."])
8686
var fineGrainedHashExternalReposFile: File? = null
8787

8888
@CommandLine.Option(

cli/src/main/kotlin/com/bazel_diff/cli/VersionProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class VersionProvider : IVersionProvider {
1010
val inputStream =
1111
classLoader.getResourceAsStream("cli/version")
1212
?: classLoader.getResourceAsStream("version")
13-
?: throw IllegalArgumentException(
13+
?: throw IllegalArgumentException(
1414
"unknown version as version file not found in resources")
1515

1616
val version = BufferedReader(InputStreamReader(inputStream)).use { it.readText().trim() }

cli/src/main/kotlin/com/bazel_diff/di/Modules.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ fun hasherModule(
3434
excludeExternalTargets: Boolean,
3535
): Module = module {
3636
if (fineGrainedHashExternalReposFile != null && fineGrainedHashExternalRepos.isNotEmpty()) {
37-
System.err.println("Error: fineGrainedHashExternalReposFile and fineGrainedHashExternalRepos are mutually exclusive - please provide only one of them")
37+
System.err.println(
38+
"Error: fineGrainedHashExternalReposFile and fineGrainedHashExternalRepos are mutually exclusive - please provide only one of them")
3839
System.exit(1)
3940
}
40-
val updatedFineGrainedHashExternalRepos = fineGrainedHashExternalReposFile?.let { file ->
41-
file.readLines()
42-
.filter { it.isNotBlank() }
43-
.toSet()
44-
} ?: fineGrainedHashExternalRepos
41+
val updatedFineGrainedHashExternalRepos =
42+
fineGrainedHashExternalReposFile?.let { file ->
43+
file.readLines().filter { it.isNotBlank() }.toSet()
44+
} ?: fineGrainedHashExternalRepos
4545

4646
val cmd: MutableList<String> =
4747
ArrayList<String>().apply {

0 commit comments

Comments
 (0)