Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1871f900 authored by Justin Yun's avatar Justin Yun
Browse files

Include license texts and kinds for VNDK snapshot

VNDK snapshot must include the information of the license texts and
kinds. Include them when packaging the snapshot prebuilt files.
This will be used to generate the VNDK snapshot files.

Bug: 270625053
Bug: 277317599
Test: development/vndk/snapshot/build.sh --build-artifacts
Change-Id: I0a39ff598efbb80faaf63807cdf5ce685fa074cc
parent f2abc7b9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -550,6 +550,7 @@ type Module interface {
	ExportedToMake() bool
	InitRc() Paths
	VintfFragments() Paths
	EffectiveLicenseKinds() []string
	EffectiveLicenseFiles() Paths

	AddProperties(props ...interface{})
@@ -2024,6 +2025,10 @@ func (m *ModuleBase) ExportedToMake() bool {
	return m.commonProperties.NamespaceExportedToMake
}

func (m *ModuleBase) EffectiveLicenseKinds() []string {
	return m.commonProperties.Effective_license_kinds
}

func (m *ModuleBase) EffectiveLicenseFiles() Paths {
	result := make(Paths, 0, len(m.commonProperties.Effective_license_text))
	for _, p := range m.commonProperties.Effective_license_text {
+33 −13
Original line number Diff line number Diff line
@@ -674,8 +674,12 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
	snapshotArchDir := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())

	configsDir := filepath.Join(snapshotArchDir, "configs")
	noticeDir := filepath.Join(snapshotArchDir, "NOTICE_FILES")
	includeDir := filepath.Join(snapshotArchDir, "include")

	// set of notice files copied.
	noticeBuilt := make(map[string]bool)

	// paths of VNDK modules for GPL license checking
	modulePaths := make(map[string]string)

@@ -700,18 +704,26 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
		snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, "shared", vndkType, libPath.Base())
		ret = append(ret, snapshot.CopyFileRule(pctx, ctx, libPath, snapshotLibOut))

		if ctx.Config().VndkSnapshotBuildArtifacts() {
		// json struct to export snapshot information
		prop := struct {
			LicenseKinds        []string `json:",omitempty"`
			LicenseTexts        []string `json:",omitempty"`
			ExportedDirs        []string `json:",omitempty"`
			ExportedSystemDirs  []string `json:",omitempty"`
			ExportedFlags       []string `json:",omitempty"`
			RelativeInstallPath string   `json:",omitempty"`
		}{}

		prop.LicenseKinds = m.EffectiveLicenseKinds()
		prop.LicenseTexts = m.EffectiveLicenseFiles().Strings()

		if ctx.Config().VndkSnapshotBuildArtifacts() {
			exportedInfo := ctx.ModuleProvider(m, FlagExporterInfoProvider).(FlagExporterInfo)
			prop.ExportedFlags = exportedInfo.Flags
			prop.ExportedDirs = exportedInfo.IncludeDirs.Strings()
			prop.ExportedSystemDirs = exportedInfo.SystemIncludeDirs.Strings()
			prop.RelativeInstallPath = m.RelativeInstallPath()
		}

		propOut := snapshotLibOut + ".json"

@@ -721,7 +733,7 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
			return nil, false
		}
		ret = append(ret, snapshot.WriteStringToFileRule(ctx, string(j), propOut))
		}

		return ret, true
	}

@@ -761,6 +773,14 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
		moduleNames[stem] = ctx.ModuleName(m)
		modulePaths[stem] = ctx.ModuleDir(m)

		for _, notice := range m.EffectiveLicenseFiles() {
			if _, ok := noticeBuilt[notice.String()]; !ok {
				noticeBuilt[notice.String()] = true
				snapshotOutputs = append(snapshotOutputs, snapshot.CopyFileRule(
					pctx, ctx, notice, filepath.Join(noticeDir, notice.String())))
			}
		}

		if ctx.Config().VndkSnapshotBuildArtifacts() {
			headers = append(headers, m.SnapshotHeaders()...)
		}