Don't include empty-string arguments in compile_commands.json
compdb.go was incorrectly splitting compiler arguments. This could
cause empty strings to be included in compile_commands.json,
potentially confusing tools.
Bug: 117124308
Test: m checkbuild
Test: m SOONG_GEN_COMPDB=1 \
SOONG_GEN_COMPDB_DEBUG=1 \
SOONG_LINK_COMPDB_TO=$ANDROID_BUILD_TOP nothing
Examine $ANDROID_BUILD_TOP/compile_commands.json
Change-Id: I375baf255c50a1329cd644ac584d200aba9daa69
diff --git a/cc/compdb.go b/cc/compdb.go
index a9c5b5e..acfc924 100644
--- a/cc/compdb.go
+++ b/cc/compdb.go
@@ -181,7 +181,7 @@
func evalAndSplitVariable(ctx android.SingletonContext, str string) ([]string, error) {
evaluated, err := ctx.Eval(pctx, str)
if err == nil {
- return strings.Split(evaluated, " "), nil
+ return strings.Fields(evaluated), nil
}
return []string{""}, err
}