Skip to content

Commit 5b88b07

Browse files
committed
Bring back clangd
1 parent 5117352 commit 5b88b07

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

packages/react-native-gesture-handler/android/build.gradle.kts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,31 @@ android {
130130

131131
sourceSets["main"].java.srcDirs(buildListOfJavaSrcDirs())
132132

133-
// TODO: Bring back clangd
133+
if (isGHExampleApp()) {
134+
tasks.withType<com.android.build.gradle.tasks.ExternalNativeBuildJsonTask>().configureEach {
135+
doLast {
136+
val hashRegex = """/Debug/([^/]+)/logs""".toRegex()
137+
val archRegex = """/logs/([^/]+)$""".toRegex()
138+
139+
val path = outputs.files.singleFile.path
140+
141+
val hashResults = hashRegex.find(path)
142+
val hash = hashResults?.groups?.get(1)?.value
143+
144+
val archResults = archRegex.find(path)
145+
val arch = archResults?.groups?.get(1)?.value
146+
147+
val rootDir = File(project.projectDir, "../../..")
148+
val generated = File(project.projectDir, ".cxx/Debug/$hash/$arch/compile_commands.json")
149+
150+
if (generated != null) {
151+
val output = File(rootDir, "compile_commands.json")
152+
output.writeText(generated.readText())
153+
println("Generated clangd metadata.")
154+
}
155+
}
156+
}
157+
}
134158
}
135159

136160
dependencies {

0 commit comments

Comments
 (0)