|
@@ -15,7 +15,10 @@
|
|
package android
|
|
package android
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "android/soong/bazel"
|
|
|
|
+ "fmt"
|
|
"github.com/google/blueprint"
|
|
"github.com/google/blueprint"
|
|
|
|
+ "os"
|
|
)
|
|
)
|
|
|
|
|
|
type licenseKindDependencyTag struct {
|
|
type licenseKindDependencyTag struct {
|
|
@@ -48,14 +51,53 @@ type licenseProperties struct {
|
|
Visibility []string
|
|
Visibility []string
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+var _ Bazelable = &licenseModule{}
|
|
|
|
+
|
|
type licenseModule struct {
|
|
type licenseModule struct {
|
|
ModuleBase
|
|
ModuleBase
|
|
DefaultableModuleBase
|
|
DefaultableModuleBase
|
|
SdkBase
|
|
SdkBase
|
|
|
|
+ BazelModuleBase
|
|
|
|
|
|
properties licenseProperties
|
|
properties licenseProperties
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type bazelLicenseAttributes struct {
|
|
|
|
+ License_kinds []string
|
|
|
|
+ Copyright_notice *string
|
|
|
|
+ License_text bazel.LabelAttribute
|
|
|
|
+ Package_name *string
|
|
|
|
+ Visibility []string
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (m *licenseModule) ConvertWithBp2build(ctx TopDownMutatorContext) {
|
|
|
|
+ attrs := &bazelLicenseAttributes{
|
|
|
|
+ License_kinds: m.properties.License_kinds,
|
|
|
|
+ Copyright_notice: m.properties.Copyright_notice,
|
|
|
|
+ Package_name: m.properties.Package_name,
|
|
|
|
+ Visibility: m.properties.Visibility,
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // TODO(asmundak): Soong supports multiple license texts while Bazel does not.
|
|
|
|
+ if len(m.properties.License_text) > 1 {
|
|
|
|
+ fmt.Fprintf(os.Stderr, "%s:%s: warning: using only the first license_text item\n",
|
|
|
|
+ ctx.ModuleDir(), m.Name())
|
|
|
|
+ }
|
|
|
|
+ if len(m.properties.License_text) >= 1 {
|
|
|
|
+ attrs.License_text.SetValue(BazelLabelForModuleSrcSingle(ctx, m.properties.License_text[0]))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ctx.CreateBazelTargetModule(
|
|
|
|
+ bazel.BazelTargetModuleProperties{
|
|
|
|
+ Rule_class: "android_license",
|
|
|
|
+ Bzl_load_location: "//build/bazel/rules/license:license.bzl",
|
|
|
|
+ },
|
|
|
|
+ CommonAttributes{
|
|
|
|
+ Name: m.Name(),
|
|
|
|
+ },
|
|
|
|
+ attrs)
|
|
|
|
+}
|
|
|
|
+
|
|
func (m *licenseModule) DepsMutator(ctx BottomUpMutatorContext) {
|
|
func (m *licenseModule) DepsMutator(ctx BottomUpMutatorContext) {
|
|
ctx.AddVariationDependencies(nil, licenseKindTag, m.properties.License_kinds...)
|
|
ctx.AddVariationDependencies(nil, licenseKindTag, m.properties.License_kinds...)
|
|
}
|
|
}
|
|
@@ -78,7 +120,7 @@ func LicenseFactory() Module {
|
|
module := &licenseModule{}
|
|
module := &licenseModule{}
|
|
|
|
|
|
base := module.base()
|
|
base := module.base()
|
|
- module.AddProperties(&base.nameProperties, &module.properties)
|
|
|
|
|
|
+ module.AddProperties(&base.nameProperties, &module.properties, &base.commonProperties.BazelConversionStatus)
|
|
|
|
|
|
// The visibility property needs to be checked and parsed by the visibility module.
|
|
// The visibility property needs to be checked and parsed by the visibility module.
|
|
setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)
|
|
setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)
|
|
@@ -86,6 +128,7 @@ func LicenseFactory() Module {
|
|
InitSdkAwareModule(module)
|
|
InitSdkAwareModule(module)
|
|
initAndroidModuleBase(module)
|
|
initAndroidModuleBase(module)
|
|
InitDefaultableModule(module)
|
|
InitDefaultableModule(module)
|
|
|
|
+ InitBazelModule(module)
|
|
|
|
|
|
return module
|
|
return module
|
|
}
|
|
}
|