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
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index cbdaa26..e82f12b 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -66,12 +66,12 @@
 	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 @@
 
 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 @@
 		}
 	})
 
+	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,
 	})
 }