Loading android/bazel.go +9 −0 Original line number Diff line number Diff line Loading @@ -174,6 +174,15 @@ var ( "liblinker_debuggerd_stub", // ruperts@, cc_library_static, depends on //system/libbase "libbionic_tests_headers_posix", // ruperts@, cc_library_static "libc_dns", // ruperts@, cc_library_static // List of all full_cc_libraries in //bionic, with their immediate failures "libc", // jingwen@, cc_library, depends on //external/gwp_asan "libc_malloc_debug", // jingwen@, cc_library, fatal error: 'assert.h' file not found "libc_malloc_hooks", // jingwen@, cc_library, fatal error: 'errno.h' file not found "libdl", // jingwen@, cc_library, ld.lld: error: no input files "libm", // jingwen@, cc_library, fatal error: 'freebsd-compat.h' file not found "libseccomp_policy", // jingwen@, cc_library, fatal error: 'seccomp_policy.h' file not found "libstdc++", // jingwen@, cc_library, depends on //external/gwp_asan } // Used for quicker lookups Loading android/bazel_handler.go +8 −3 Original line number Diff line number Diff line Loading @@ -352,15 +352,20 @@ func (context *bazelContext) workspaceFileContents() []byte { # This file is generated by soong_build. Do not edit. local_repository( name = "sourceroot", path = "%s", path = "%[1]s", ) local_repository( name = "rules_cc", path = "%s/build/bazel/rules_cc", path = "%[1]s/build/bazel/rules_cc", ) local_repository( name = "bazel_skylib", path = "%[1]s/build/bazel/bazel_skylib", ) ` return []byte(fmt.Sprintf(formatString, context.workspaceDir, context.workspaceDir)) return []byte(fmt.Sprintf(formatString, context.workspaceDir)) } func (context *bazelContext) mainBzlFileContents() []byte { Loading android/paths.go +6 −0 Original line number Diff line number Diff line Loading @@ -421,6 +421,9 @@ func BazelLabelForModuleDeps(ctx BazelConversionPathContext, modules []string) b // bazel-compatible labels. Properties passed as the paths or excludes argument must have been // annotated with struct tag `android:"path"` so that dependencies on other modules will have // already been handled by the path_properties mutator. // // With expanded globs, we can catch package boundaries problem instead of // silently failing to potentially missing files from Bazel's globs. func BazelLabelForModuleSrc(ctx BazelConversionPathContext, paths []string) bazel.LabelList { return BazelLabelForModuleSrcExcludes(ctx, paths, []string(nil)) } Loading @@ -431,6 +434,9 @@ func BazelLabelForModuleSrc(ctx BazelConversionPathContext, paths []string) baze // passed as the paths or excludes argument must have been annotated with struct tag // `android:"path"` so that dependencies on other modules will have already been handled by the // path_properties mutator. // // With expanded globs, we can catch package boundaries problem instead of // silently failing to potentially missing files from Bazel's globs. func BazelLabelForModuleSrcExcludes(ctx BazelConversionPathContext, paths, excludes []string) bazel.LabelList { excludeLabels := expandSrcsForBazel(ctx, excludes, []string(nil)) excluded := make([]string, 0, len(excludeLabels.Includes)) Loading bazel/properties.go +72 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package bazel import ( "fmt" "path/filepath" "regexp" "sort" ) Loading Loading @@ -47,6 +48,57 @@ type LabelList struct { Excludes []Label } // GlobsInDir returns a list of glob expressions for a list of extensions // (optionally recursive) within a directory. func GlobsInDir(dir string, recursive bool, extensions []string) []string { globs := []string{} globInfix := "" if dir == "." { if recursive { // e.g "**/*.h" globInfix = "**/" } // else e.g. "*.h" for _, ext := range extensions { globs = append(globs, globInfix+"*"+ext) } } else { if recursive { // e.g. "foo/bar/**/*.h" dir += "/**" } // else e.g. "foo/bar/*.h" for _, ext := range extensions { globs = append(globs, dir+"/*"+ext) } } return globs } // LooseHdrsGlobs returns the list of non-recursive header globs for each parent directory of // each source file in this LabelList's Includes. func (ll *LabelList) LooseHdrsGlobs(exts []string) []string { var globs []string for _, parentDir := range ll.uniqueParentDirectories() { globs = append(globs, GlobsInDir(parentDir, false, exts)...) } return globs } // uniqueParentDirectories returns a list of the unique parent directories for // all files in ll.Includes. func (ll *LabelList) uniqueParentDirectories() []string { dirMap := map[string]bool{} for _, label := range ll.Includes { dirMap[filepath.Dir(label.Label)] = true } dirs := []string{} for dir := range dirMap { dirs = append(dirs, dir) } return dirs } // Append appends the fields of other labelList to the corresponding fields of ll. func (ll *LabelList) Append(other LabelList) { if len(ll.Includes) > 0 || len(other.Includes) > 0 { Loading Loading @@ -224,6 +276,26 @@ func MakeLabelListAttribute(value LabelList) LabelListAttribute { return LabelListAttribute{Value: UniqueBazelLabelList(value)} } // Append appends all values, including os and arch specific ones, from another // LabelListAttribute to this LabelListAttribute. func (attrs *LabelListAttribute) Append(other LabelListAttribute) { for arch := range PlatformArchMap { this := attrs.GetValueForArch(arch) that := other.GetValueForArch(arch) this.Append(that) attrs.SetValueForArch(arch, this) } for os := range PlatformOsMap { this := attrs.GetValueForOS(os) that := other.GetValueForOS(os) this.Append(that) attrs.SetValueForOS(os, this) } attrs.Value.Append(other.Value) } // HasArchSpecificValues returns true if the attribute contains // architecture-specific label_list values. func (attrs LabelListAttribute) HasConfigurableValues() bool { Loading bp2build/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ bootstrap_go_package { testSrcs: [ "build_conversion_test.go", "bzl_conversion_test.go", "cc_library_conversion_test.go", "cc_library_headers_conversion_test.go", "cc_library_static_conversion_test.go", "cc_object_conversion_test.go", Loading Loading
android/bazel.go +9 −0 Original line number Diff line number Diff line Loading @@ -174,6 +174,15 @@ var ( "liblinker_debuggerd_stub", // ruperts@, cc_library_static, depends on //system/libbase "libbionic_tests_headers_posix", // ruperts@, cc_library_static "libc_dns", // ruperts@, cc_library_static // List of all full_cc_libraries in //bionic, with their immediate failures "libc", // jingwen@, cc_library, depends on //external/gwp_asan "libc_malloc_debug", // jingwen@, cc_library, fatal error: 'assert.h' file not found "libc_malloc_hooks", // jingwen@, cc_library, fatal error: 'errno.h' file not found "libdl", // jingwen@, cc_library, ld.lld: error: no input files "libm", // jingwen@, cc_library, fatal error: 'freebsd-compat.h' file not found "libseccomp_policy", // jingwen@, cc_library, fatal error: 'seccomp_policy.h' file not found "libstdc++", // jingwen@, cc_library, depends on //external/gwp_asan } // Used for quicker lookups Loading
android/bazel_handler.go +8 −3 Original line number Diff line number Diff line Loading @@ -352,15 +352,20 @@ func (context *bazelContext) workspaceFileContents() []byte { # This file is generated by soong_build. Do not edit. local_repository( name = "sourceroot", path = "%s", path = "%[1]s", ) local_repository( name = "rules_cc", path = "%s/build/bazel/rules_cc", path = "%[1]s/build/bazel/rules_cc", ) local_repository( name = "bazel_skylib", path = "%[1]s/build/bazel/bazel_skylib", ) ` return []byte(fmt.Sprintf(formatString, context.workspaceDir, context.workspaceDir)) return []byte(fmt.Sprintf(formatString, context.workspaceDir)) } func (context *bazelContext) mainBzlFileContents() []byte { Loading
android/paths.go +6 −0 Original line number Diff line number Diff line Loading @@ -421,6 +421,9 @@ func BazelLabelForModuleDeps(ctx BazelConversionPathContext, modules []string) b // bazel-compatible labels. Properties passed as the paths or excludes argument must have been // annotated with struct tag `android:"path"` so that dependencies on other modules will have // already been handled by the path_properties mutator. // // With expanded globs, we can catch package boundaries problem instead of // silently failing to potentially missing files from Bazel's globs. func BazelLabelForModuleSrc(ctx BazelConversionPathContext, paths []string) bazel.LabelList { return BazelLabelForModuleSrcExcludes(ctx, paths, []string(nil)) } Loading @@ -431,6 +434,9 @@ func BazelLabelForModuleSrc(ctx BazelConversionPathContext, paths []string) baze // passed as the paths or excludes argument must have been annotated with struct tag // `android:"path"` so that dependencies on other modules will have already been handled by the // path_properties mutator. // // With expanded globs, we can catch package boundaries problem instead of // silently failing to potentially missing files from Bazel's globs. func BazelLabelForModuleSrcExcludes(ctx BazelConversionPathContext, paths, excludes []string) bazel.LabelList { excludeLabels := expandSrcsForBazel(ctx, excludes, []string(nil)) excluded := make([]string, 0, len(excludeLabels.Includes)) Loading
bazel/properties.go +72 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package bazel import ( "fmt" "path/filepath" "regexp" "sort" ) Loading Loading @@ -47,6 +48,57 @@ type LabelList struct { Excludes []Label } // GlobsInDir returns a list of glob expressions for a list of extensions // (optionally recursive) within a directory. func GlobsInDir(dir string, recursive bool, extensions []string) []string { globs := []string{} globInfix := "" if dir == "." { if recursive { // e.g "**/*.h" globInfix = "**/" } // else e.g. "*.h" for _, ext := range extensions { globs = append(globs, globInfix+"*"+ext) } } else { if recursive { // e.g. "foo/bar/**/*.h" dir += "/**" } // else e.g. "foo/bar/*.h" for _, ext := range extensions { globs = append(globs, dir+"/*"+ext) } } return globs } // LooseHdrsGlobs returns the list of non-recursive header globs for each parent directory of // each source file in this LabelList's Includes. func (ll *LabelList) LooseHdrsGlobs(exts []string) []string { var globs []string for _, parentDir := range ll.uniqueParentDirectories() { globs = append(globs, GlobsInDir(parentDir, false, exts)...) } return globs } // uniqueParentDirectories returns a list of the unique parent directories for // all files in ll.Includes. func (ll *LabelList) uniqueParentDirectories() []string { dirMap := map[string]bool{} for _, label := range ll.Includes { dirMap[filepath.Dir(label.Label)] = true } dirs := []string{} for dir := range dirMap { dirs = append(dirs, dir) } return dirs } // Append appends the fields of other labelList to the corresponding fields of ll. func (ll *LabelList) Append(other LabelList) { if len(ll.Includes) > 0 || len(other.Includes) > 0 { Loading Loading @@ -224,6 +276,26 @@ func MakeLabelListAttribute(value LabelList) LabelListAttribute { return LabelListAttribute{Value: UniqueBazelLabelList(value)} } // Append appends all values, including os and arch specific ones, from another // LabelListAttribute to this LabelListAttribute. func (attrs *LabelListAttribute) Append(other LabelListAttribute) { for arch := range PlatformArchMap { this := attrs.GetValueForArch(arch) that := other.GetValueForArch(arch) this.Append(that) attrs.SetValueForArch(arch, this) } for os := range PlatformOsMap { this := attrs.GetValueForOS(os) that := other.GetValueForOS(os) this.Append(that) attrs.SetValueForOS(os, this) } attrs.Value.Append(other.Value) } // HasArchSpecificValues returns true if the attribute contains // architecture-specific label_list values. func (attrs LabelListAttribute) HasConfigurableValues() bool { Loading
bp2build/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ bootstrap_go_package { testSrcs: [ "build_conversion_test.go", "bzl_conversion_test.go", "cc_library_conversion_test.go", "cc_library_headers_conversion_test.go", "cc_library_static_conversion_test.go", "cc_object_conversion_test.go", Loading