bp2build: refactor/standardize cc_* bp2build converters
This CL refactors the cc* bp2build converters to use the common
attribute extractors in cc/bp2build.go.
This also adds include_build_directory to be handled by the compiler
attr extractor to generate recursive headers as inputs.
This also turns include_dirs and local_include_dirs into the
execroot-relative -I flags.
e.g. if a module in bionic/libc has "private" in local_include_dirs,
the "-Ibionic/libc/private" copt is generated for it.
Fixes: 185139955
Test: TH
Test: Forrest for mixed_clean-droid
Change-Id: Ib67056482227e62068fbbea0455035bdf5d56319
diff --git a/bp2build/configurability.go b/bp2build/configurability.go
index 97729df..b9ffc04 100644
--- a/bp2build/configurability.go
+++ b/bp2build/configurability.go
@@ -110,7 +110,11 @@
if err != nil {
return "", err
}
- selects += s + ",\n"
+ // s could still be an empty string, e.g. unset slices of structs with
+ // length of 0.
+ if s != "" {
+ selects += s + ",\n"
+ }
}
if len(selects) == 0 {
@@ -137,6 +141,9 @@
if err != nil {
return "", err
}
+ if v == "" {
+ return "", nil
+ }
s += fmt.Sprintf("\"%s\": %s", key, v)
return s, nil
}