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

Unverified Commit 6f53e144 authored by Jihoon Kang's avatar Jihoon Kang Committed by Luca Stefani
Browse files

Expand the usages of prebuilt_any in prebuilt_etc module gen

Currently, prebuilt_any is only used as a fallback behavior when the
generated prebuilt_root module tries to set the `Dsts` property, given
that prebuilt_root module type is no longer allowed to set `Dsts`
property with https://r.android.com/3540101.

This change expands the usages of the fallback behavior to when the
generated prebuilt_root module tries to set the `Relative_install_path`
property, given that this property is not also available to
prebuilt_root module type.

Test: m nothing --no-skip-soong-tests
Change-Id: I9344a8cb3e26bedbd0217a5344ac92b8def68554
parent 6b45f845
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -339,9 +339,23 @@ func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition,

		// Set appropriate srcs, dsts, and releative_install_path based on
		// the source and install file names
		if allCopyFileNamesUnchanged {
		modulePropsPtr.Srcs = srcBaseFiles

		// prebuilt_root should only be used in very limited cases in prebuilt_etc moddule gen, where:
		// - all source file names are identical to the installed file names, and
		// - all source files are installed in root, not the subdirectories of root
		// prebuilt_root currently does not have a good way to specify the names of the multiple
		// installed files, and prebuilt_root does not allow installing files at a subdirectory
		// of the root.
		// Use prebuilt_any instead of prebuilt_root if either of the conditions are not met as
		// a fallback behavior.
		if etcInstallPathKey == "" {
			if !(allCopyFileNamesUnchanged && android.InList(relDestDirFromInstallDirBase, []string{"", "."})) {
				moduleFactory = etc.PrebuiltAnyFactory
			}
		}

		if allCopyFileNamesUnchanged {
			// Specify relative_install_path if it is not installed in the root directory of the
			// partition
			if !android.InList(relDestDirFromInstallDirBase, []string{"", "."}) {
@@ -352,15 +366,10 @@ func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition,
		} else {
			// If dsts property has to be set and the selected module type is prebuilt_root,
			// use prebuilt_any instead.
			if etcInstallPathKey == "" {
				moduleFactory = etc.PrebuiltAnyFactory
			}
			modulePropsPtr.Srcs = srcBaseFiles
			dsts := proptools.NewConfigurable[[]string](nil, nil)
			for _, installBaseFile := range installBaseFiles {
				dsts.AppendSimpleValue([]string{filepath.Join(relDestDirFromInstallDirBase, installBaseFile)})
			}

			propsList = append(propsList, &etc.PrebuiltDstsProperties{
				Dsts: dsts,
			})