Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
c932de4c
Unverified
Commit
c932de4c
authored
Sep 26, 2023
by
Ilya Ryzhenkov
Committed by
GitHub
Sep 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate compile_commands.json from Gradle C++ compilation tasks (#721)
parent
ea067413
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
.gitignore
.gitignore
+1
-0
CompileSkikoCppTask.kt
skiko/buildSrc/src/main/kotlin/CompileSkikoCppTask.kt
+16
-0
No files found.
.gitignore
View file @
c932de4c
...
...
@@ -9,3 +9,4 @@ deploy.sh
deploy.bat
*.xcodeproj
skiko/src/jvmMain/java
.cache
skiko/buildSrc/src/main/kotlin/CompileSkikoCppTask.kt
View file @
c932de4c
...
...
@@ -11,6 +11,8 @@ import org.gradle.work.InputChanges
import
org.gradle.workers.WorkerExecutionException
import
java.io.File
import
java.nio.file.Files
import
java.nio.file.Path
import
java.util.*
import
java.util.concurrent.Callable
import
kotlin.collections.HashSet
...
...
@@ -145,6 +147,9 @@ abstract class CompileSkikoCppTask() : AbstractSkikoNativeToolTask() {
// Replace slash for Windows paths
arg
(
"-o"
,
outputFile
.
absolutePath
.
replace
(
"\\"
,
"/"
))
arg
(
value
=
sourceFile
.
absolutePath
.
replace
(
"\\"
,
"/"
))
if
(
compiler
.
get
().
startsWith
(
"clang"
))
{
arg
(
"-MJ"
,
outputFile
.
absolutePath
+
".json"
)
}
}
val
argFile
=
run
{
...
...
@@ -178,6 +183,17 @@ abstract class CompileSkikoCppTask() : AbstractSkikoNativeToolTask() {
RunExternalProcessWork
.
workResults
.
remove
(
work
)
}
}
if
(
compiler
.
get
().
startsWith
(
"clang"
))
{
val
compileCommands
=
buildString
{
appendLine
(
"["
)
append
(
sourceOutputPairs
.
joinToString
(
",\n"
)
{
(
_
,
outputFile
)
->
Files
.
readString
(
Path
.
of
(
outputFile
.
absolutePath
+
".json"
)).
trim
().
removeSuffix
(
","
)
})
appendLine
(
"]"
)
}
Files
.
writeString
(
outDir
.
toPath
().
resolve
(
"compile_commands.json"
),
compileCommands
)
}
}
private
fun
findCompilerExecutable
():
File
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment