Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module types, along with the related code. Bug: 315353489 Test: m blueprint_tests Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
This commit is contained in:
@@ -15,10 +15,7 @@
|
||||
package rust
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -63,8 +60,6 @@ func RustBinaryHostFactory() android.Module {
|
||||
func NewRustBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
|
||||
module := newModule(hod, android.MultilibFirst)
|
||||
|
||||
android.InitBazelModule(module)
|
||||
|
||||
binary := &binaryDecorator{
|
||||
baseCompiler: NewBaseCompiler("bin", "", InstallInSystem),
|
||||
}
|
||||
@@ -185,88 +180,3 @@ func (binary *binaryDecorator) staticallyLinked() bool {
|
||||
func (binary *binaryDecorator) testBinary() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type rustBinaryLibraryAttributes struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
Compile_data bazel.LabelListAttribute
|
||||
Crate_name bazel.StringAttribute
|
||||
Edition bazel.StringAttribute
|
||||
Crate_features bazel.StringListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Proc_macro_deps bazel.LabelListAttribute
|
||||
Rustc_flags bazel.StringListAttribute
|
||||
}
|
||||
|
||||
func binaryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
|
||||
binary := m.compiler.(*binaryDecorator)
|
||||
|
||||
var srcs bazel.LabelList
|
||||
var compileData bazel.LabelList
|
||||
|
||||
if binary.baseCompiler.Properties.Srcs[0] == "src/main.rs" {
|
||||
srcs = android.BazelLabelForModuleSrc(ctx, []string{"src/**/*.rs"})
|
||||
compileData = android.BazelLabelForModuleSrc(
|
||||
ctx,
|
||||
[]string{
|
||||
"src/**/*.proto",
|
||||
"examples/**/*.rs",
|
||||
"**/*.md",
|
||||
"templates/**/*.template",
|
||||
},
|
||||
)
|
||||
} else {
|
||||
srcs = android.BazelLabelForModuleSrc(ctx, binary.baseCompiler.Properties.Srcs)
|
||||
}
|
||||
|
||||
deps := android.BazelLabelForModuleDeps(ctx, append(
|
||||
binary.baseCompiler.Properties.Rustlibs,
|
||||
))
|
||||
|
||||
procMacroDeps := android.BazelLabelForModuleDeps(ctx, binary.baseCompiler.Properties.Proc_macros)
|
||||
|
||||
var rustcFLags []string
|
||||
for _, cfg := range binary.baseCompiler.Properties.Cfgs {
|
||||
rustcFLags = append(rustcFLags, fmt.Sprintf("--cfg=%s", cfg))
|
||||
}
|
||||
|
||||
attrs := &rustBinaryLibraryAttributes{
|
||||
Srcs: bazel.MakeLabelListAttribute(
|
||||
srcs,
|
||||
),
|
||||
Compile_data: bazel.MakeLabelListAttribute(
|
||||
compileData,
|
||||
),
|
||||
Crate_name: bazel.StringAttribute{
|
||||
Value: &binary.baseCompiler.Properties.Crate_name,
|
||||
},
|
||||
Edition: bazel.StringAttribute{
|
||||
Value: binary.baseCompiler.Properties.Edition,
|
||||
},
|
||||
Crate_features: bazel.StringListAttribute{
|
||||
Value: binary.baseCompiler.Properties.Features,
|
||||
},
|
||||
Deps: bazel.MakeLabelListAttribute(
|
||||
deps,
|
||||
),
|
||||
Proc_macro_deps: bazel.MakeLabelListAttribute(
|
||||
procMacroDeps,
|
||||
),
|
||||
Rustc_flags: bazel.StringListAttribute{
|
||||
Value: append(
|
||||
rustcFLags,
|
||||
binary.baseCompiler.Properties.Flags...,
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
ctx.CreateBazelTargetModule(
|
||||
bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "rust_binary",
|
||||
Bzl_load_location: "@rules_rust//rust:defs.bzl",
|
||||
},
|
||||
android.CommonAttributes{
|
||||
Name: m.Name(),
|
||||
},
|
||||
attrs,
|
||||
)
|
||||
}
|
||||
|
@@ -51,8 +51,6 @@ var (
|
||||
"-C force-unwind-tables=yes",
|
||||
// Use v0 mangling to distinguish from C++ symbols
|
||||
"-C symbol-mangling-version=v0",
|
||||
// This flag requires to have no space so that when it's exported to bazel
|
||||
// it can be removed. See aosp/2768339
|
||||
"--color=always",
|
||||
"-Z dylib-lto",
|
||||
"-Z link-native-libraries=no",
|
||||
@@ -145,8 +143,3 @@ func GetRustVersion(ctx android.PathContext) string {
|
||||
}
|
||||
return RustDefaultVersion
|
||||
}
|
||||
|
||||
// BazelRustToolchainVars returns a string with
|
||||
func BazelRustToolchainVars(config android.Config) string {
|
||||
return android.BazelToolchainVars(config, ExportedVars)
|
||||
}
|
||||
|
186
rust/library.go
186
rust/library.go
@@ -21,10 +21,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel"
|
||||
"android/soong/cc"
|
||||
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -402,8 +399,6 @@ func (library *libraryDecorator) BuildOnlyShared() {
|
||||
func NewRustLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
||||
module := newModule(hod, android.MultilibBoth)
|
||||
|
||||
android.InitBazelModule(module)
|
||||
|
||||
library := &libraryDecorator{
|
||||
MutatedProperties: LibraryMutatedProperties{
|
||||
BuildDylib: false,
|
||||
@@ -801,184 +796,3 @@ func (l *libraryDecorator) collectHeadersForSnapshot(ctx android.ModuleContext,
|
||||
// TODO(185577950): If support for generated headers is added, they need to be collected here as well.
|
||||
l.collectedSnapshotHeaders = ret
|
||||
}
|
||||
|
||||
type rustLibraryAttributes struct {
|
||||
commonLibraryAttrs
|
||||
}
|
||||
|
||||
type commonLibraryAttrs struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
Compile_data bazel.LabelListAttribute
|
||||
Crate_name bazel.StringAttribute
|
||||
Edition bazel.StringAttribute
|
||||
Crate_features bazel.StringListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Rustc_flags bazel.StringListAttribute
|
||||
Proc_macro_deps bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
func commonLibraryAttrsBp2build(ctx android.Bp2buildMutatorContext, m *Module) *commonLibraryAttrs {
|
||||
lib := m.compiler.(*libraryDecorator)
|
||||
|
||||
srcs, compileData := srcsAndCompileDataAttrs(ctx, *lib.baseCompiler)
|
||||
|
||||
deps := android.BazelLabelForModuleDeps(ctx, append(
|
||||
lib.baseCompiler.Properties.Rustlibs,
|
||||
lib.baseCompiler.Properties.Rlibs...,
|
||||
))
|
||||
|
||||
cargoBuildScript := cargoBuildScriptBp2build(ctx, m)
|
||||
if cargoBuildScript != nil {
|
||||
deps.Add(&bazel.Label{
|
||||
Label: ":" + *cargoBuildScript,
|
||||
})
|
||||
}
|
||||
|
||||
procMacroDeps := android.BazelLabelForModuleDeps(ctx, lib.baseCompiler.Properties.Proc_macros)
|
||||
|
||||
var rustcFLags []string
|
||||
for _, cfg := range lib.baseCompiler.Properties.Cfgs {
|
||||
rustcFLags = append(rustcFLags, fmt.Sprintf("--cfg=%s", cfg))
|
||||
}
|
||||
|
||||
return &commonLibraryAttrs{
|
||||
Srcs: bazel.MakeLabelListAttribute(
|
||||
srcs,
|
||||
),
|
||||
Compile_data: bazel.MakeLabelListAttribute(
|
||||
compileData,
|
||||
),
|
||||
Crate_name: bazel.StringAttribute{
|
||||
Value: &lib.baseCompiler.Properties.Crate_name,
|
||||
},
|
||||
Edition: bazel.StringAttribute{
|
||||
Value: lib.baseCompiler.Properties.Edition,
|
||||
},
|
||||
Crate_features: bazel.StringListAttribute{
|
||||
Value: lib.baseCompiler.Properties.Features,
|
||||
},
|
||||
Deps: bazel.MakeLabelListAttribute(
|
||||
deps,
|
||||
),
|
||||
Proc_macro_deps: bazel.MakeLabelListAttribute(
|
||||
procMacroDeps,
|
||||
),
|
||||
Rustc_flags: bazel.StringListAttribute{
|
||||
Value: append(
|
||||
rustcFLags,
|
||||
lib.baseCompiler.Properties.Flags...,
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func libraryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
|
||||
ctx.CreateBazelTargetModule(
|
||||
bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "rust_library",
|
||||
Bzl_load_location: "@rules_rust//rust:defs.bzl",
|
||||
},
|
||||
android.CommonAttributes{
|
||||
Name: m.Name(),
|
||||
},
|
||||
commonLibraryAttrsBp2build(ctx, m),
|
||||
)
|
||||
}
|
||||
|
||||
type cargoBuildScriptAttributes struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
Edition bazel.StringAttribute
|
||||
Version bazel.StringAttribute
|
||||
}
|
||||
|
||||
func cargoBuildScriptBp2build(ctx android.Bp2buildMutatorContext, m *Module) *string {
|
||||
// Soong treats some crates like libprotobuf as special in that they have
|
||||
// cargo build script ran to produce an out folder and check it into AOSP
|
||||
// For example, https://cs.android.com/android/platform/superproject/main/+/main:external/rust/crates/protobuf/out/
|
||||
// is produced by cargo build script https://cs.android.com/android/platform/superproject/main/+/main:external/rust/crates/protobuf/build.rs
|
||||
// The out folder is then fed into `rust_library` by a genrule
|
||||
// https://cs.android.com/android/platform/superproject/main/+/main:external/rust/crates/protobuf/Android.bp;l=22
|
||||
// This allows Soong to decouple from cargo completely.
|
||||
|
||||
// Soong decouples from cargo so that it has control over cc compilation.
|
||||
// https://cs.android.com/android/platform/superproject/main/+/main:development/scripts/cargo2android.py;l=1033-1041;drc=8449944a50a0445a5ecaf9b7aed12608c81bf3f1
|
||||
// generates a `cc_library_static` module to have custom cc flags.
|
||||
// Since bp2build will convert the cc modules to cc targets which include the cflags,
|
||||
// Bazel does not need to have this optimization.
|
||||
|
||||
// Performance-wise: rust_library -> cargo_build_script vs rust_library -> genrule (like Soong)
|
||||
// don't have any major difference in build time in Bazel. So using cargo_build_script does not slow
|
||||
// down the build.
|
||||
|
||||
// The benefit of using `cargo_build_script` here is that it would take care of setting correct
|
||||
// `OUT_DIR` for us - similar to what Soong does here
|
||||
// https://cs.android.com/android/platform/superproject/main/+/main:build/soong/rust/builder.go;l=202-218;drc=f29ca58e88c5846bbe8955e5192135e5ab4f14a1
|
||||
|
||||
// TODO(b/297364081): cargo2android.py has logic for when generate/not cc_library_static and out directory
|
||||
// bp2build might be able use the same logic for when to use `cargo_build_script`.
|
||||
// For now, we're building libprotobuf_build_script as a one-off until we have a more principled solution
|
||||
if m.Name() != "libprotobuf" {
|
||||
return nil
|
||||
}
|
||||
|
||||
lib := m.compiler.(*libraryDecorator)
|
||||
|
||||
name := m.Name() + "_build_script"
|
||||
attrs := &cargoBuildScriptAttributes{
|
||||
Srcs: bazel.MakeLabelListAttribute(
|
||||
android.BazelLabelForModuleSrc(ctx, []string{"build.rs"}),
|
||||
),
|
||||
Edition: bazel.StringAttribute{
|
||||
Value: lib.baseCompiler.Properties.Edition,
|
||||
},
|
||||
Version: bazel.StringAttribute{
|
||||
Value: lib.baseCompiler.Properties.Cargo_pkg_version,
|
||||
},
|
||||
}
|
||||
|
||||
// TODO(b/290790800): Remove the restriction when rust toolchain for android is implemented
|
||||
var restriction bazel.BoolAttribute
|
||||
restriction.SetSelectValue(bazel.OsConfigurationAxis, "android", proptools.BoolPtr(false))
|
||||
|
||||
ctx.CreateBazelTargetModuleWithRestrictions(
|
||||
bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "cargo_build_script",
|
||||
Bzl_load_location: "@rules_rust//cargo:cargo_build_script.bzl",
|
||||
},
|
||||
android.CommonAttributes{
|
||||
Name: name,
|
||||
},
|
||||
attrs,
|
||||
restriction,
|
||||
)
|
||||
|
||||
return &name
|
||||
}
|
||||
|
||||
type ffiStaticAttributes struct {
|
||||
commonLibraryAttrs
|
||||
Export_includes bazel.StringListAttribute
|
||||
}
|
||||
|
||||
func ffiStaticBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
|
||||
lib := m.compiler.(*libraryDecorator)
|
||||
|
||||
attrs := &ffiStaticAttributes{
|
||||
Export_includes: bazel.StringListAttribute{
|
||||
Value: lib.Properties.Include_dirs,
|
||||
},
|
||||
commonLibraryAttrs: *commonLibraryAttrsBp2build(ctx, m),
|
||||
}
|
||||
|
||||
ctx.CreateBazelTargetModule(
|
||||
bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "rust_ffi_static",
|
||||
Bzl_load_location: "//build/bazel/rules/rust:rust_ffi_static.bzl",
|
||||
},
|
||||
android.CommonAttributes{
|
||||
Name: m.Name(),
|
||||
},
|
||||
attrs,
|
||||
)
|
||||
}
|
||||
|
@@ -15,10 +15,7 @@
|
||||
package rust
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -50,8 +47,6 @@ func ProcMacroFactory() android.Module {
|
||||
func NewProcMacro(hod android.HostOrDeviceSupported) (*Module, *procMacroDecorator) {
|
||||
module := newModule(hod, android.MultilibFirst)
|
||||
|
||||
android.InitBazelModule(module)
|
||||
|
||||
procMacro := &procMacroDecorator{
|
||||
baseCompiler: NewBaseCompiler("lib", "lib64", InstallInSystem),
|
||||
flagExporter: NewFlagExporter(),
|
||||
@@ -103,65 +98,3 @@ func (procMacro *procMacroDecorator) everInstallable() bool {
|
||||
// Proc_macros are never installed
|
||||
return false
|
||||
}
|
||||
|
||||
type procMacroAttributes struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
Compile_data bazel.LabelListAttribute
|
||||
Crate_name bazel.StringAttribute
|
||||
Edition bazel.StringAttribute
|
||||
Crate_features bazel.StringListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Rustc_flags bazel.StringListAttribute
|
||||
}
|
||||
|
||||
func procMacroBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
|
||||
procMacro := m.compiler.(*procMacroDecorator)
|
||||
srcs, compileData := srcsAndCompileDataAttrs(ctx, *procMacro.baseCompiler)
|
||||
deps := android.BazelLabelForModuleDeps(ctx, append(
|
||||
procMacro.baseCompiler.Properties.Rustlibs,
|
||||
procMacro.baseCompiler.Properties.Rlibs...,
|
||||
))
|
||||
|
||||
var rustcFLags []string
|
||||
for _, cfg := range procMacro.baseCompiler.Properties.Cfgs {
|
||||
rustcFLags = append(rustcFLags, fmt.Sprintf("--cfg=%s", cfg))
|
||||
}
|
||||
|
||||
attrs := &procMacroAttributes{
|
||||
Srcs: bazel.MakeLabelListAttribute(
|
||||
srcs,
|
||||
),
|
||||
Compile_data: bazel.MakeLabelListAttribute(
|
||||
compileData,
|
||||
),
|
||||
Crate_name: bazel.StringAttribute{
|
||||
Value: &procMacro.baseCompiler.Properties.Crate_name,
|
||||
},
|
||||
Edition: bazel.StringAttribute{
|
||||
Value: procMacro.baseCompiler.Properties.Edition,
|
||||
},
|
||||
Crate_features: bazel.StringListAttribute{
|
||||
Value: procMacro.baseCompiler.Properties.Features,
|
||||
},
|
||||
Deps: bazel.MakeLabelListAttribute(
|
||||
deps,
|
||||
),
|
||||
Rustc_flags: bazel.StringListAttribute{
|
||||
Value: append(
|
||||
rustcFLags,
|
||||
procMacro.baseCompiler.Properties.Flags...,
|
||||
),
|
||||
},
|
||||
}
|
||||
// m.IsConvertedByBp2build()
|
||||
ctx.CreateBazelTargetModule(
|
||||
bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "rust_proc_macro",
|
||||
Bzl_load_location: "@rules_rust//rust:defs.bzl",
|
||||
},
|
||||
android.CommonAttributes{
|
||||
Name: m.Name(),
|
||||
},
|
||||
attrs,
|
||||
)
|
||||
}
|
||||
|
@@ -19,10 +19,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel"
|
||||
"android/soong/cc"
|
||||
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -282,77 +279,5 @@ func NewRustProtobuf(hod android.HostOrDeviceSupported) (*Module, *protobufDecor
|
||||
|
||||
module := NewSourceProviderModule(hod, protobuf, false, false)
|
||||
|
||||
android.InitBazelModule(module)
|
||||
|
||||
return module, protobuf
|
||||
}
|
||||
|
||||
type rustProtoAttributes struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
Crate_name bazel.StringAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
type protoLibraryAttributes struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
func protoLibraryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
|
||||
var protoFiles []string
|
||||
|
||||
for _, propsInterface := range m.sourceProvider.SourceProviderProps() {
|
||||
if possibleProps, ok := propsInterface.(*ProtobufProperties); ok {
|
||||
protoFiles = possibleProps.Protos
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
protoLibraryName := m.Name() + "_proto"
|
||||
|
||||
protoDeps := bazel.LabelListAttribute{
|
||||
Value: bazel.LabelList{
|
||||
Includes: []bazel.Label{
|
||||
{
|
||||
Label: ":" + protoLibraryName,
|
||||
OriginalModuleName: m.Name(),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// TODO(b/295918553): Remove androidRestriction after rust toolchain for android is checked in.
|
||||
var androidRestriction bazel.BoolAttribute
|
||||
androidRestriction.SetSelectValue(bazel.OsConfigurationAxis, "android", proptools.BoolPtr(false))
|
||||
|
||||
ctx.CreateBazelTargetModuleWithRestrictions(
|
||||
bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "proto_library",
|
||||
},
|
||||
android.CommonAttributes{
|
||||
Name: protoLibraryName,
|
||||
},
|
||||
&protoLibraryAttributes{
|
||||
Srcs: bazel.MakeLabelListAttribute(
|
||||
android.BazelLabelForModuleSrc(ctx, protoFiles),
|
||||
),
|
||||
},
|
||||
androidRestriction,
|
||||
)
|
||||
|
||||
ctx.CreateBazelTargetModuleWithRestrictions(
|
||||
bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "rust_proto_library",
|
||||
Bzl_load_location: "@rules_rust//proto/protobuf:defs.bzl",
|
||||
},
|
||||
android.CommonAttributes{
|
||||
Name: m.Name(),
|
||||
},
|
||||
&rustProtoAttributes{
|
||||
Crate_name: bazel.StringAttribute{
|
||||
Value: proptools.StringPtr(m.CrateName()),
|
||||
},
|
||||
Deps: protoDeps,
|
||||
},
|
||||
androidRestriction,
|
||||
)
|
||||
}
|
||||
|
47
rust/rust.go
47
rust/rust.go
@@ -18,11 +18,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"android/soong/bazel"
|
||||
"android/soong/bloaty"
|
||||
"android/soong/testing"
|
||||
"android/soong/ui/metrics/bp2build_metrics_proto"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
@@ -176,8 +173,6 @@ type Module struct {
|
||||
|
||||
transitiveAndroidMkSharedLibs *android.DepSet[string]
|
||||
|
||||
android.BazelModuleBase
|
||||
|
||||
// Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
|
||||
mergedAconfigFiles map[string]android.Paths
|
||||
}
|
||||
@@ -1856,48 +1851,6 @@ func (c *Module) Partition() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
||||
if ctx.ModuleType() == "rust_library_host" || ctx.ModuleType() == "rust_library" {
|
||||
libraryBp2build(ctx, m)
|
||||
} else if ctx.ModuleType() == "rust_proc_macro" {
|
||||
procMacroBp2build(ctx, m)
|
||||
} else if ctx.ModuleType() == "rust_binary_host" {
|
||||
binaryBp2build(ctx, m)
|
||||
} else if ctx.ModuleType() == "rust_protobuf_host" || ctx.ModuleType() == "rust_protobuf" {
|
||||
protoLibraryBp2build(ctx, m)
|
||||
} else if ctx.ModuleType() == "rust_ffi_static" {
|
||||
ffiStaticBp2build(ctx, m)
|
||||
} else {
|
||||
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "")
|
||||
}
|
||||
}
|
||||
|
||||
// This is a workaround by assuming the conventions that rust crate repos are structured
|
||||
// while waiting for the sandboxing work to complete.
|
||||
// TODO(b/297344471): When crate_root prop is set which enforces inputs sandboxing,
|
||||
// always use `srcs` and `compile_data` props to generate `srcs` and `compile_data` attributes
|
||||
// instead of using globs.
|
||||
func srcsAndCompileDataAttrs(ctx android.Bp2buildMutatorContext, c baseCompiler) (bazel.LabelList, bazel.LabelList) {
|
||||
var srcs bazel.LabelList
|
||||
var compileData bazel.LabelList
|
||||
|
||||
if c.Properties.Srcs[0] == "src/lib.rs" {
|
||||
srcs = android.BazelLabelForModuleSrc(ctx, []string{"src/**/*.rs"})
|
||||
compileData = android.BazelLabelForModuleSrc(
|
||||
ctx,
|
||||
[]string{
|
||||
"src/**/*.proto",
|
||||
"examples/**/*.rs",
|
||||
"**/*.md",
|
||||
},
|
||||
)
|
||||
} else {
|
||||
srcs = android.BazelLabelForModuleSrc(ctx, c.Properties.Srcs)
|
||||
}
|
||||
|
||||
return srcs, compileData
|
||||
}
|
||||
|
||||
var Bool = proptools.Bool
|
||||
var BoolDefault = proptools.BoolDefault
|
||||
var String = proptools.String
|
||||
|
Reference in New Issue
Block a user