Add a "license" property to ndk_headers.
This field points to the license file for the headers being shipped. Test: make ndk && less $SOONG_OUT/ndk/NOTICE Bug: None Change-Id: I386f4e6f6d9776f422ffc09b8dab69e1911b08a4
This commit is contained in:
@@ -74,6 +74,12 @@ var (
|
||||
},
|
||||
"error")
|
||||
|
||||
Cat = pctx.AndroidStaticRule("Cat",
|
||||
blueprint.RuleParams{
|
||||
Command: "cat $in > $out",
|
||||
Description: "concatenate licenses $out",
|
||||
})
|
||||
|
||||
// Used only when USE_GOMA=true is set, to restrict non-goma jobs to the local parallelism value
|
||||
localPool = blueprint.NewBuiltinPool("local_pool")
|
||||
)
|
||||
|
@@ -170,6 +170,7 @@ type HostOrDeviceSupported int
|
||||
const (
|
||||
_ HostOrDeviceSupported = iota
|
||||
HostSupported
|
||||
HostSupportedNoCross
|
||||
DeviceSupported
|
||||
HostAndDeviceSupported
|
||||
HostAndDeviceDefault
|
||||
@@ -326,8 +327,9 @@ func (a *ModuleBase) ArchSpecific() bool {
|
||||
func (a *ModuleBase) OsClassSupported() []OsClass {
|
||||
switch a.commonProperties.HostOrDeviceSupported {
|
||||
case HostSupported:
|
||||
// TODO(ccross): explicitly mark host cross support
|
||||
return []OsClass{Host, HostCross}
|
||||
case HostSupportedNoCross:
|
||||
return []OsClass{Host}
|
||||
case DeviceSupported:
|
||||
return []OsClass{Device}
|
||||
case HostAndDeviceSupported:
|
||||
|
@@ -46,6 +46,9 @@ type headerProperies struct {
|
||||
|
||||
// List of headers to install. Glob compatible. Common case is "include/**/*.h".
|
||||
Srcs []string
|
||||
|
||||
// Path to the NOTICE file associated with the headers.
|
||||
License string
|
||||
}
|
||||
|
||||
type headerModule struct {
|
||||
@@ -54,12 +57,19 @@ type headerModule struct {
|
||||
properties headerProperies
|
||||
|
||||
installPaths []string
|
||||
licensePath android.ModuleSrcPath
|
||||
}
|
||||
|
||||
func (m *headerModule) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
|
||||
func (m *headerModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
if m.properties.License == "" {
|
||||
ctx.PropertyErrorf("license", "field is required")
|
||||
}
|
||||
|
||||
m.licensePath = android.PathForModuleSrc(ctx, m.properties.License)
|
||||
|
||||
srcFiles := ctx.ExpandSources(m.properties.Srcs, nil)
|
||||
for _, header := range srcFiles {
|
||||
// Output path is the sysroot base + "usr/include" + to directory + directory component
|
||||
@@ -100,6 +110,10 @@ func (m *headerModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
func ndkHeadersFactory() (blueprint.Module, []interface{}) {
|
||||
module := &headerModule{}
|
||||
return android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst,
|
||||
&module.properties)
|
||||
// Host module rather than device module because device module install steps
|
||||
// do not get run when embedded in make. We're not any of the existing
|
||||
// module types that can be exposed via the Android.mk exporter, so just use
|
||||
// a host module.
|
||||
return android.InitAndroidArchModule(module, android.HostSupportedNoCross,
|
||||
android.MultilibFirst, &module.properties)
|
||||
}
|
||||
|
@@ -66,12 +66,12 @@ func init() {
|
||||
pctx.Import("android/soong/common")
|
||||
}
|
||||
|
||||
func getNdkInstallBase(ctx android.ModuleContext) android.OutputPath {
|
||||
func getNdkInstallBase(ctx android.PathContext) android.OutputPath {
|
||||
return android.PathForOutput(ctx, "ndk")
|
||||
}
|
||||
|
||||
// Returns the main install directory for the NDK sysroot. Usable with --sysroot.
|
||||
func getNdkSysrootBase(ctx android.ModuleContext) android.OutputPath {
|
||||
func getNdkSysrootBase(ctx android.PathContext) android.OutputPath {
|
||||
return getNdkInstallBase(ctx).Join(ctx, "sysroot")
|
||||
}
|
||||
|
||||
@@ -87,9 +87,11 @@ type ndkSingleton struct{}
|
||||
|
||||
func (n *ndkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
||||
installPaths := []string{}
|
||||
licensePaths := []string{}
|
||||
ctx.VisitAllModules(func(module blueprint.Module) {
|
||||
if m, ok := module.(*headerModule); ok {
|
||||
installPaths = append(installPaths, m.installPaths...)
|
||||
licensePaths = append(licensePaths, m.licensePath.String())
|
||||
}
|
||||
})
|
||||
|
||||
@@ -101,12 +103,22 @@ func (n *ndkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
||||
}
|
||||
})
|
||||
|
||||
combinedLicense := getNdkInstallBase(ctx).Join(ctx, "NOTICE")
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: android.Cat,
|
||||
Outputs: []string{combinedLicense.String()},
|
||||
Inputs: licensePaths,
|
||||
Optional: true,
|
||||
})
|
||||
|
||||
depPaths := append(installPaths, combinedLicense.String())
|
||||
|
||||
// There's a dummy "ndk" rule defined in ndk/Android.mk that depends on
|
||||
// this. `m ndk` will build the sysroots.
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: android.Touch,
|
||||
Outputs: []string{getNdkSysrootTimestampFile(ctx).String()},
|
||||
Implicits: installPaths,
|
||||
Implicits: depPaths,
|
||||
Optional: true,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user