From d1e366a0724d602fc65d93092261752ec831444e Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 5 Oct 2021 09:12:41 +0900 Subject: [PATCH] Installation routine for rust is similar to that of cc This change makes the installation routine for rust be similar to that of cc. Previously, rust.baseCompiler.install() (which internally calls android.ModuleContext.InstallFile()) was not called when the module is not installable. Although this may sound right at first glance, it is a behavior different from that of cc and prevents an uninstallable rust module from being packaged into a packaging module like android_filesystem. This is because the packaging happens inside InstallFile(). Fixing the issue by following the behavior of cc modules; Call HideFromMake() or SkipInstall() when a rust module is not installable, but call InstallFile() as long as the output file is valid. InstallFile() internally skips the installation (but the packaging) when HideFromMake() or SkipInstall() was called. Bug: N/A Test: atest MicrodroidHostTestCases Change-Id: I15f4adc8544dac53647647d8bc4273f9f4acbeb2 --- rust/rust.go | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/rust/rust.go b/rust/rust.go index b9afc7f82..93dbd0010 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -130,9 +130,10 @@ type BaseProperties struct { // Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX). Min_sdk_version *string - PreventInstall bool - HideFromMake bool - Installable *bool + HideFromMake bool `blueprint:"mutated"` + PreventInstall bool `blueprint:"mutated"` + + Installable *bool } type Module struct { @@ -177,8 +178,8 @@ func (mod *Module) SetHideFromMake() { mod.Properties.HideFromMake = true } -func (c *Module) HiddenFromMake() bool { - return c.Properties.HideFromMake +func (mod *Module) HiddenFromMake() bool { + return mod.Properties.HideFromMake } func (mod *Module) SanitizePropDefined() bool { @@ -526,10 +527,6 @@ func (mod *Module) PreventInstall() bool { return mod.Properties.PreventInstall } -func (mod *Module) HideFromMake() { - mod.Properties.HideFromMake = true -} - func (mod *Module) MarkAsCoverageVariant(coverage bool) { mod.coverage.Properties.IsCoverageVariant = coverage } @@ -898,8 +895,24 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo) - if mod.installable(apexInfo) { + if !proptools.BoolDefault(mod.Installable(), mod.EverInstallable()) { + // If the module has been specifically configure to not be installed then + // hide from make as otherwise it will break when running inside make as the + // output path to install will not be specified. Not all uninstallable + // modules can be hidden from make as some are needed for resolving make + // side dependencies. + mod.HideFromMake() + } else if !mod.installable(apexInfo) { + mod.SkipInstall() + } + + // Still call install though, the installs will be stored as PackageSpecs to allow + // using the outputs in a genrule. + if mod.OutputFile().Valid() { mod.compiler.install(ctx) + if ctx.Failed() { + return + } } ctx.Phony("rust", ctx.RustModule().OutputFile().Path())