Fix staging dir creation for adevice
Adevice does a `ninja -t inputs -i droid` and filters the results
for out/target/product/ to find files in the staging directories.
We were just copying the staging directories without creating ninja
rules before, so that failed. Actually create the ninja rules.
The rules are created in the android_device module instead of the
filesystem so that if you have multiple filesystems, they don't create
conflicting installation rules.
We should provide a way for tools like adevice to query the build system
for installed files, no matter where they are in the out/ dir, and
use that to replace this logic.
This cl produces the following diff in out/target/product compared
to soong-only builds before this change:
https://paste.googleplex.com/4624734193713152
It's mostly empty directories, which I don't think matter for adevice.
Bug: 393464638
Bug: 392957226
Test: `m installclean && m && launch_cvd && adevice update` says the device is up-to-date.
Change-Id: Ifb52aaf5bc3edd2e3900546bf9df73a52d1022c0
diff --git a/android/module_context.go b/android/module_context.go
index 1f4758c..a3dad93 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -591,7 +591,7 @@
func (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec {
fullInstallPath := installPath.Join(m, name)
- return m.packageFile(fullInstallPath, srcPath, false)
+ return m.packageFile(fullInstallPath, srcPath, false, false)
}
func (m *moduleContext) getAconfigPaths() Paths {
@@ -615,7 +615,7 @@
return owner, overrides
}
-func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool) PackagingSpec {
+func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool, requiresFullInstall bool) PackagingSpec {
licenseFiles := m.Module().EffectiveLicenseFiles()
owner, overrides := m.getOwnerAndOverrides()
spec := PackagingSpec{
@@ -630,6 +630,8 @@
archType: m.target.Arch.ArchType,
overrides: uniquelist.Make(overrides),
owner: owner,
+ requiresFullInstall: requiresFullInstall,
+ fullInstallPath: fullInstallPath,
}
m.packagingSpecs = append(m.packagingSpecs, spec)
return spec
@@ -705,7 +707,7 @@
m.installFiles = append(m.installFiles, fullInstallPath)
}
- m.packageFile(fullInstallPath, srcPath, executable)
+ m.packageFile(fullInstallPath, srcPath, executable, m.requiresFullInstall())
if checkbuild {
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
@@ -755,16 +757,18 @@
owner, overrides := m.getOwnerAndOverrides()
m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
- relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
- srcPath: nil,
- symlinkTarget: relPath,
- executable: false,
- partition: fullInstallPath.partition,
- skipInstall: m.skipInstall(),
- aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
- archType: m.target.Arch.ArchType,
- overrides: uniquelist.Make(overrides),
- owner: owner,
+ relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
+ srcPath: nil,
+ symlinkTarget: relPath,
+ executable: false,
+ partition: fullInstallPath.partition,
+ skipInstall: m.skipInstall(),
+ aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
+ archType: m.target.Arch.ArchType,
+ overrides: uniquelist.Make(overrides),
+ owner: owner,
+ requiresFullInstall: m.requiresFullInstall(),
+ fullInstallPath: fullInstallPath,
})
return fullInstallPath
@@ -803,16 +807,18 @@
owner, overrides := m.getOwnerAndOverrides()
m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
- relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
- srcPath: nil,
- symlinkTarget: absPath,
- executable: false,
- partition: fullInstallPath.partition,
- skipInstall: m.skipInstall(),
- aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
- archType: m.target.Arch.ArchType,
- overrides: uniquelist.Make(overrides),
- owner: owner,
+ relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
+ srcPath: nil,
+ symlinkTarget: absPath,
+ executable: false,
+ partition: fullInstallPath.partition,
+ skipInstall: m.skipInstall(),
+ aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
+ archType: m.target.Arch.ArchType,
+ overrides: uniquelist.Make(overrides),
+ owner: owner,
+ requiresFullInstall: m.requiresFullInstall(),
+ fullInstallPath: fullInstallPath,
})
return fullInstallPath
diff --git a/android/packaging.go b/android/packaging.go
index 738f215..d216c0c 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -63,6 +63,15 @@
// Name of the module where this packaging spec is output of
owner string
+
+ // If the ninja rule creating the FullInstallPath has already been emitted or not. Do not use,
+ // for the soong-only migration.
+ requiresFullInstall bool
+
+ // The path to the installed file in out/target/product. This is for legacy purposes, with
+ // tools that want to interact with these files outside of the build. You should not use it
+ // inside of the build. Will be nil if this module doesn't require a "full install".
+ fullInstallPath InstallPath
}
type packagingSpecGob struct {
@@ -175,6 +184,24 @@
return p.aconfigPaths.ToSlice()
}
+// The path to the installed file in out/target/product. This is for legacy purposes, with
+// tools that want to interact with these files outside of the build. You should not use it
+// inside of the build. Will be nil if this module doesn't require a "full install".
+func (p *PackagingSpec) FullInstallPath() InstallPath {
+ return p.fullInstallPath
+}
+
+// If the ninja rule creating the FullInstallPath has already been emitted or not. Do not use,
+// for the soong-only migration.
+func (p *PackagingSpec) RequiresFullInstall() bool {
+ return p.requiresFullInstall
+}
+
+// The source file to be copied to the FullInstallPath. Do not use, for the soong-only migration.
+func (p *PackagingSpec) SrcPath() Path {
+ return p.srcPath
+}
+
type PackageModule interface {
Module
packagingBase() *PackagingBase