Skip to content

Commit 70e0566

Browse files
committed
grpc-native: Cleanup
Signed-off-by: Johannes Zottele <[email protected]>
1 parent 6da5041 commit 70e0566

File tree

8 files changed

+24
-557
lines changed

8 files changed

+24
-557
lines changed

cinterop-c/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,3 @@
1212
/.aswb/
1313
/.clwb/
1414
.idea/
15-
16-
out/
17-
tmp/

cinterop-c/MODULE.bazel

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ module(
33
version = "0.1",
44
)
55

6-
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
7-
86
# rules_cc for cc_library support
97
bazel_dep(
108
name = "rules_cc",
@@ -37,36 +35,3 @@ bazel_dep(
3735
version = GRPC_VERSION,
3836
repo_name = "com_github_grpc_grpc",
3937
)
40-
41-
## gRPC pre-built
42-
43-
local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
44-
45-
local_repository(
46-
name = "prebuilt_deps",
47-
path = "prebuilt-deps",
48-
)
49-
50-
http_file(
51-
name = "grpc_ios_arm64",
52-
sha256 = "7bc13a15c59850048e77b5719ea262a6fcc22884ab42c9f14f38859200faac9b",
53-
urls = [GRPC_BASE + "ios_arm64.a"],
54-
)
55-
56-
http_file(
57-
name = "grpc_ios_sim_arm64",
58-
sha256 = "55fde875508372860125ee8505ef4e84b95c9620744378a99f8f4095292dcae5",
59-
urls = [GRPC_BASE + "ios_simulator_arm64.a"],
60-
)
61-
62-
http_file(
63-
name = "grpc_ios_x64",
64-
sha256 = "7544113fe9b6c9d0a57c8b8864b5272e01e3a64ea36cd0802d4a76e98ad5e232",
65-
urls = [GRPC_BASE + "ios_x64.a"],
66-
)
67-
68-
http_file(
69-
name = "grpc_macos_arm64",
70-
sha256 = "6cf466a285832ecd0f41041164c412e9b541388210058310d7bb59f6a27d09de",
71-
urls = [GRPC_BASE + "macos_arm64.a"],
72-
)

cinterop-c/extract_include_dir.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
set -Eeuo pipefail
77
trap 'echo "ERROR: Build failed at ${BASH_SOURCE}:${LINENO}" >&2' ERR
88

9-
# Builds a static library for a specific platform (os/arch).
9+
# Extract all headers in the /include directory of the given target.
1010
#
1111
# Usage:
12-
# ./build_target.sh //path:libtarget out_dir <platform> <short> <os>
12+
# ./extract_include_dir.sh <target> <output-directory>
1313
# Example:
14-
# ./build_target.sh :protowire_static out @build_bazel_apple_support//platforms:ios_arm64 ios_arm64 ios
14+
# ./extract_include_dir.sh //prebuilt-deps/grpc_fat:grpc_fat prebuilt-deps/grpc_fat
1515
#
16-
# The example will produce ./out/libprotowire_static.ios_arm64.a
16+
# The example will produce the prebuilt-deps/grpc_fat/include directory with all headers.
1717

1818
LABEL="${1:?need bazel target label}"
1919
DST="${2:?need output destination}"

gradle-conventions/src/main/kotlin/conventions-root.gradle.kts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,12 @@
22
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import util.other.capitalized
65
import util.other.isPublicModule
76
import util.other.libs
8-
import util.other.maybeNamed
97
import util.setupPage
10-
import util.tasks.ValidatePublishedArtifactsTask
11-
import util.tasks.configureNpm
12-
import util.tasks.registerChangelogTask
13-
import util.tasks.registerDumpPlatformTableTask
14-
import util.tasks.registerVerifyPlatformTableTask
15-
import kotlin.io.path.exists
16-
import kotlin.io.path.isDirectory
17-
import kotlin.io.path.listDirectoryEntries
18-
import kotlin.io.path.name
19-
import kotlin.io.path.readText
8+
import util.tasks.*
209
import java.nio.file.Path
21-
import kotlin.io.path.createFile
10+
import kotlin.io.path.*
2211

2312
plugins {
2413
id("org.jetbrains.dokka")
@@ -121,3 +110,17 @@ gradle.afterProject {
121110
}
122111
}
123112
}
113+
114+
115+
tasks.register<Exec>("checkBazel") {
116+
commandLine("which", "bazel")
117+
isIgnoreExitValue = true
118+
doLast {
119+
if (executionResult.get().exitValue == 0) {
120+
val path = standardOutput.toString().trim()
121+
logger.debug("bazel: {}", path)
122+
} else {
123+
throw GradleException("'bazel' not found on PATH. Please install Bazel (https://bazel.build/).")
124+
}
125+
}
126+
}

gradle-conventions/src/main/kotlin/util/cinterop.kt

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
package util
66

7-
import org.gradle.api.GradleException
87
import org.gradle.api.NamedDomainObjectContainer
98
import org.gradle.api.Project
109
import org.gradle.api.file.Directory
@@ -31,20 +30,6 @@ fun KotlinMultiplatformExtension.configureCLibCInterop(
3130
val cLibSource = project.cinteropLibDir
3231
val cLibOutDir = project.bazelBuildDir.dir(buildTargetName).asFile
3332

34-
35-
// TODO: Replace function implementation, so it does not use an internal API
36-
fun findProgram(name: String) = org.gradle.internal.os.OperatingSystem.current().findInPath(name)
37-
val checkBazel = project.tasks.register("checkBazel") {
38-
doLast {
39-
val bazelPath = findProgram("bazel")
40-
if (bazelPath != null) {
41-
logger.debug("bazel: {}", bazelPath)
42-
} else {
43-
throw GradleException("'bazel' not found on PATH. Please install Bazel (https://bazel.build/).")
44-
}
45-
}
46-
}
47-
4833
targets.withType<KotlinNativeTarget>().configureEach {
4934
// the name used for the static library files (e.g. iosSimulatorArm64 -> ios_simulator_arm64)
5035
val platformShortName = konanTarget.visibleName
@@ -118,6 +103,7 @@ fun KotlinMultiplatformExtension.configureCLibDependency(
118103

119104
if (bazelExtractIncludeTask != null) {
120105
project.tasks.register<Exec>("buildIncludeDirCLib${buildTargetName.capitalized()}") {
106+
dependsOn("checkBazel")
121107
group = "build"
122108
workingDir = project.cinteropLibDir
123109
commandLine(
@@ -169,8 +155,7 @@ private fun TaskContainer.registerBuildClibTask(
169155
inputs.files(project.fileTree(project.cinteropLibDir) { exclude("bazel-*/**", "prebuilt-deps/**") })
170156
outputs.files(outFile)
171157

172-
// TODO: how to register the task idempotently?
173-
// dependsOn(checkBazel)
158+
dependsOn("checkBazel")
174159
}
175160
}
176161

gradle-conventions/src/main/kotlin/util/tasks/bazel.kt

Lines changed: 0 additions & 139 deletions
This file was deleted.

grpc/grpc-core/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ kotlin {
7979
includeDirs(
8080
cLibSource.resolve("include"),
8181
cLibSource.resolve("$grpcPrebuiltDir/include"),
82-
cLibSource.resolve("bazel-cinterop-c/external/grpc+/include"),
8382
)
8483
extraOpts("-libraryPath", "$grpcPrebuiltDir")
8584
extraOpts("-libraryPath", "$cLibOutDir")
@@ -88,7 +87,8 @@ kotlin {
8887

8988
configureCLibDependency(
9089
project,
91-
bazelTask = "//prebuilt-deps/grpc_fat:grpc_fat"
90+
bazelTask = "//prebuilt-deps/grpc_fat:grpc_fat",
91+
bazelExtractIncludeTask = "//prebuilt-deps/grpc_fat:grpc_include_dir"
9292
)
9393

9494
}

0 commit comments

Comments
 (0)