@@ -25,6 +25,7 @@ import java.io.File
25
25
fun KotlinMultiplatformExtension.configureCLibCInterop (
26
26
project : Project ,
27
27
bazelTask : String ,
28
+ cinteropTaskDependsOn : List <Any > = emptyList(),
28
29
configureCinterop : NamedDomainObjectContainer <DefaultCInteropSettings >.(cLibSource: File , cLibOutDir: File ) -> Unit ,
29
30
) {
30
31
val buildTargetName = bazelTask.split(" :" ).last()
@@ -56,6 +57,7 @@ fun KotlinMultiplatformExtension.configureCLibCInterop(
56
57
val interopTask = " cinterop${interop.name.capitalized()}${this @configureEach.targetName.capitalized()} "
57
58
project.tasks.named(interopTask, CInteropProcess ::class ) {
58
59
dependsOn(buildCinteropCLib)
60
+ cinteropTaskDependsOn.forEach { dependsOn(it) }
59
61
}
60
62
}
61
63
}
@@ -76,12 +78,7 @@ fun KotlinMultiplatformExtension.configureCLibCInterop(
76
78
fun KotlinMultiplatformExtension.configureCLibDependency (
77
79
project : Project ,
78
80
bazelTask : String ,
79
- bazelExtractIncludeTask : String? = null,
80
- bazelExtractIncludeOutputDir : Provider <Directory >? = null,
81
81
) {
82
- require((bazelExtractIncludeTask == null ) == (bazelExtractIncludeOutputDir == null )) {
83
- " Either both bazelExtractIncludeTask and bazelExtractIncludeOutputDir must be specified or neither."
84
- }
85
82
val buildTargetName = bazelTask.split(" :" ).last()
86
83
val prebuiltLibDir = project.cLibPrebuiltDepsDir.resolve(buildTargetName)
87
84
@@ -106,21 +103,6 @@ fun KotlinMultiplatformExtension.configureCLibDependency(
106
103
}
107
104
}
108
105
109
- if (bazelExtractIncludeTask != null ) {
110
- val includeDir = bazelExtractIncludeOutputDir!! .get().asFile
111
- project.tasks.register<Exec >(" buildIncludeDirCLib${buildTargetName.capitalized()} " ) {
112
- dependsOn(" :checkBazel" )
113
- group = " build"
114
- workingDir = project.cinteropLibDir
115
- commandLine(
116
- " bash" ,
117
- " -c" ,
118
- " ./extract_include_dir.sh //prebuilt-deps/grpc_fat:grpc_include_dir $includeDir "
119
- )
120
- outputs.dir(includeDir.resolve(" include" ))
121
- }
122
- }
123
-
124
106
project.tasks.register(" buildDependencyAllTargetsForCLib${buildTargetName.capitalized()} " ) {
125
107
group = " build"
126
108
targets.withType<KotlinNativeTarget >().forEach { target ->
@@ -135,6 +117,26 @@ fun KotlinMultiplatformExtension.configureCLibDependency(
135
117
}
136
118
}
137
119
120
+ fun Project.registerBuildCLibIncludeDirTask (
121
+ bazelTask : String ,
122
+ bazelExtractIncludeOutputDir : Provider <Directory >,
123
+ ): TaskProvider <Exec > {
124
+ val buildTargetName = bazelTask.split(" :" ).last()
125
+ val includeDir = bazelExtractIncludeOutputDir.get().asFile
126
+ return project.tasks.register<Exec >(" buildIncludeDirCLib${buildTargetName.capitalized()} " ) {
127
+ dependsOn(" :checkBazel" )
128
+ group = " build"
129
+ workingDir = project.cinteropLibDir
130
+ commandLine(
131
+ " bash" ,
132
+ " -c" ,
133
+ " ./extract_include_dir.sh //prebuilt-deps/grpc_fat:grpc_include_dir $includeDir "
134
+ )
135
+ outputs.dir(includeDir.resolve(" include" ))
136
+ }
137
+ }
138
+
139
+
138
140
private val Project .cLibPrebuiltDepsDir: File get() = cinteropLibDir.resolve(" prebuilt-deps" )
139
141
140
142
private val Project .bazelBuildDir: Directory
0 commit comments