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

Commit a9c8c9f1 authored by Colin Cross's avatar Colin Cross
Browse files

Call ctx.InstallFile for uninstallable cc modules

SkipInstall is actually primarily used to prevent making a module
visible to Make, rename it and add new SkipInstall that actually
skips installation without affecting Make.

Call c.SkipInstall() for uninstallable cc modules to allow calling
c.installer.install, which will collect PackagingSpecs for
uninstallable cc modules, allowing them to be used by genrules.

Bug: 124313442
Test: m checkbuild
Change-Id: I8038ed5c6f05c989ac21ec06c4552fb3136b9a7a
parent 95b07f2b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -820,7 +820,7 @@ func shouldSkipAndroidMkProcessing(module *ModuleBase) bool {
	}

	return !module.Enabled() ||
		module.commonProperties.SkipInstall ||
		module.commonProperties.HideFromMake ||
		// Make does not understand LinuxBionic
		module.Os() == LinuxBionic
}
+32 −13
Original line number Diff line number Diff line
@@ -452,8 +452,8 @@ type Module interface {
	InstallInRoot() bool
	InstallBypassMake() bool
	InstallForceOS() (*OsType, *ArchType)
	SkipInstall()
	IsSkipInstall() bool
	HideFromMake()
	IsHideFromMake() bool
	MakeUninstallable()
	ReplacedByPrebuilt()
	IsReplacedByPrebuilt() bool
@@ -751,6 +751,13 @@ type commonProperties struct {
	// Set by osMutator.
	CommonOSVariant bool `blueprint:"mutated"`

	// When HideFromMake is set to true, no entry for this variant will be emitted in the
	// generated Android.mk file.
	HideFromMake bool `blueprint:"mutated"`

	// When SkipInstall is set to true, calls to ctx.InstallFile, ctx.InstallExecutable,
	// ctx.InstallSymlink and ctx.InstallAbsoluteSymlink act like calls to ctx.PackageFile
	// and don't create a rule to install the file.
	SkipInstall bool `blueprint:"mutated"`

	// Whether the module has been replaced by a prebuilt
@@ -1355,26 +1362,33 @@ func (m *ModuleBase) Disable() {
	m.commonProperties.ForcedDisabled = true
}

func (m *ModuleBase) SkipInstall() {
	m.commonProperties.SkipInstall = true
// HideFromMake marks this variant so that it is not emitted in the generated Android.mk file.
func (m *ModuleBase) HideFromMake() {
	m.commonProperties.HideFromMake = true
}

func (m *ModuleBase) IsSkipInstall() bool {
	return m.commonProperties.SkipInstall == true
// IsHideFromMake returns true if HideFromMake was previously called.
func (m *ModuleBase) IsHideFromMake() bool {
	return m.commonProperties.HideFromMake == true
}

// Similar to SkipInstall, but if the AndroidMk entry would set
// SkipInstall marks this variant to not create install rules when ctx.Install* are called.
func (m *ModuleBase) SkipInstall() {
	m.commonProperties.SkipInstall = true
}

// Similar to HideFromMake, but if the AndroidMk entry would set
// LOCAL_UNINSTALLABLE_MODULE then this variant may still output that entry
// rather than leaving it out altogether. That happens in cases where it would
// have other side effects, in particular when it adds a NOTICE file target,
// which other install targets might depend on.
func (m *ModuleBase) MakeUninstallable() {
	m.SkipInstall()
	m.HideFromMake()
}

func (m *ModuleBase) ReplacedByPrebuilt() {
	m.commonProperties.ReplacedByPrebuilt = true
	m.SkipInstall()
	m.HideFromMake()
}

func (m *ModuleBase) IsReplacedByPrebuilt() bool {
@@ -2440,11 +2454,15 @@ func (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
	return m.module.InstallForceOS()
}

func (m *moduleContext) skipInstall(fullInstallPath InstallPath) bool {
func (m *moduleContext) skipInstall() bool {
	if m.module.base().commonProperties.SkipInstall {
		return true
	}

	if m.module.base().commonProperties.HideFromMake {
		return true
	}

	// We'll need a solution for choosing which of modules with the same name in different
	// namespaces to install.  For now, reuse the list of namespaces exported to Make as the
	// list of namespaces to install in a Soong-only build.
@@ -2492,7 +2510,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
	fullInstallPath := installPath.Join(m, name)
	m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)

	if !m.skipInstall(fullInstallPath) {
	if !m.skipInstall() {
		deps = append(deps, m.module.base().installFilesDepSet.ToList().Paths()...)

		var implicitDeps, orderOnlyDeps Paths
@@ -2526,6 +2544,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
	m.packageFile(fullInstallPath, srcPath, executable)

	m.checkbuildFiles = append(m.checkbuildFiles, srcPath)

	return fullInstallPath
}

@@ -2537,7 +2556,7 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src
	if err != nil {
		panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
	}
	if !m.skipInstall(fullInstallPath) {
	if !m.skipInstall() {

		m.Build(pctx, BuildParams{
			Rule:        Symlink,
@@ -2570,7 +2589,7 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str
	fullInstallPath := installPath.Join(m, name)
	m.module.base().hooks.runInstallHooks(m, nil, fullInstallPath, true)

	if !m.skipInstall(fullInstallPath) {
	if !m.skipInstall() {
		m.Build(pctx, BuildParams{
			Rule:        Symlink,
			Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
+2 −2
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ func overrideModuleDepsMutator(ctx BottomUpMutatorContext) {
			return
		}
		// See if there's a prebuilt module that overrides this override module with prefer flag,
		// in which case we call SkipInstall on the corresponding variant later.
		// in which case we call HideFromMake on the corresponding variant later.
		ctx.VisitDirectDepsWithTag(PrebuiltDepTag, func(dep Module) {
			prebuilt, ok := dep.(PrebuiltInterface)
			if !ok {
@@ -284,7 +284,7 @@ func performOverrideMutator(ctx BottomUpMutatorContext) {
			mods[i+1].(OverridableModule).override(ctx, o)
			if o.getOverriddenByPrebuilt() {
				// The overriding module itself, too, is overridden by a prebuilt. Skip its installation.
				mods[i+1].SkipInstall()
				mods[i+1].HideFromMake()
			}
		}
	} else if o, ok := ctx.Module().(OverrideModule); ok {
+1 −1
Original line number Diff line number Diff line
@@ -289,7 +289,7 @@ func PrebuiltPostDepsMutator(ctx BottomUpMutatorContext) {
				})
			}
		} else {
			m.SkipInstall()
			m.HideFromMake()
		}
	}
}
+1 −1
Original line number Diff line number Diff line
@@ -6578,7 +6578,7 @@ func TestPrebuiltStubLibDep(t *testing.T) {
								continue
							}
							mod := ctx.ModuleForTests(modName, variant).Module().(*cc.Module)
							if !mod.Enabled() || mod.IsSkipInstall() {
							if !mod.Enabled() || mod.IsHideFromMake() {
								continue
							}
							for _, ent := range android.AndroidMkEntriesForTest(t, config, "", mod) {
Loading