summaryrefslogtreecommitdiff
path: root/cc/compdb.go
diff options
context:
space:
mode:
author Changyeon Jo <changyeon@google.com> 2019-12-19 23:26:16 +0000
committer Changyeon Jo <changyeon@google.com> 2019-12-20 00:10:02 +0000
commit96279252d7ace0dc65bb09375515308598ce2ba0 (patch)
treef534c1742267e0daa81f58baa267c76b6c12519d /cc/compdb.go
parent6b295312f6dcca01013ba0909e6e18cbd695a825 (diff)
Generate Compdb file in the output directory
This change modifies the location of generated compdb file from $ANDROID_BUILD_TOP to where compdbOtuputProjectsDirectory points to, under $OUT_DIR. This is especially required for the build environment that maps $ANDROID_BUILD_TOP as read-only, such as Gitc. Test: m SOONG_GEN_COMPDB=1 nothing examine generated compile_commands.json Signed-off-by: Changyeon Jo <changyeon@google.com> Change-Id: I86700f89b613a443a33982ecd5501b0f68a62be7
Diffstat (limited to 'cc/compdb.go')
-rw-r--r--cc/compdb.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/cc/compdb.go b/cc/compdb.go
index 519380fa9..dff14dbeb 100644
--- a/cc/compdb.go
+++ b/cc/compdb.go
@@ -27,7 +27,7 @@ import (
// This singleton generates a compile_commands.json file. It does so for each
// blueprint Android.bp resulting in a cc.Module when either make, mm, mma, mmm
// or mmma is called. It will only create a single compile_commands.json file
-// at out/development/ide/compdb/compile_commands.json. It will also symlink it
+// at ${OUT_DIR}/soong/development/ide/compdb/compile_commands.json. It will also symlink it
// to ${SOONG_LINK_COMPDB_TO} if set. In general this should be created by running
// make SOONG_GEN_COMPDB=1 nothing to get all targets.
@@ -43,7 +43,7 @@ type compdbGeneratorSingleton struct{}
const (
compdbFilename = "compile_commands.json"
- compdbOutputProjectsDirectory = "out/development/ide/compdb"
+ compdbOutputProjectsDirectory = "development/ide/compdb"
// Environment variables used to modify behavior of this singleton.
envVariableGenerateCompdb = "SOONG_GEN_COMPDB"
@@ -78,12 +78,12 @@ func (c *compdbGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCon
})
// Create the output file.
- dir := filepath.Join(getCompdbAndroidSrcRootDirectory(ctx), compdbOutputProjectsDirectory)
- os.MkdirAll(dir, 0777)
- compDBFile := filepath.Join(dir, compdbFilename)
- f, err := os.Create(compdbFilename)
+ dir := android.PathForOutput(ctx, compdbOutputProjectsDirectory)
+ os.MkdirAll(dir.String(), 0777)
+ compDBFile := dir.Join(ctx, compdbFilename)
+ f, err := os.Create(compDBFile.String())
if err != nil {
- log.Fatalf("Could not create file %s: %s", filepath.Join(dir, compdbFilename), err)
+ log.Fatalf("Could not create file %s: %s", compDBFile, err)
}
defer f.Close()
@@ -106,7 +106,7 @@ func (c *compdbGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCon
finalLinkPath := filepath.Join(ctx.Config().Getenv(envVariableCompdbLink), compdbFilename)
if finalLinkPath != "" {
os.Remove(finalLinkPath)
- if err := os.Symlink(compDBFile, finalLinkPath); err != nil {
+ if err := os.Symlink(compDBFile.String(), finalLinkPath); err != nil {
log.Fatalf("Unable to symlink %s to %s: %s", compDBFile, finalLinkPath, err)
}
}