From e3845057836c42e197c117815088dfac0fe38d2c Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 13 Feb 2025 12:45:35 -0800 Subject: Make soong-only builds adb-sync compatible Historically, the build has put the staging directories for partitions in out/target/product. But in soong-only builds, the main staging directory is in the out/soong/.intermediates path for the filesystem modules, and then later also replicated in out/target/product for backwards compatibility with tools like adb sync. However, adb sync determines which files to push by if they have a different timestamp than on device. Since the device images were built using a different staging directory than the one adb sync is looking at, the have different timestamps, and adb sync syncs all files on the device the first time it's run. To work around this, ensure the files in both staging directories have the same timestamp by preserving the timestamp from their source file with the `cp -p` flag. This cl only does that change for real files right now, not symlinks. We could also do it for symlinks in the future, but they're more complicated and I didn't want to deal with that right now. This means the first adb sync will resync all symlinks on the device, but there are relatively few of them and they're small so it's not that big of an issue. Long term, we should rewrite adb sync to not depend on staging directories. If it looks at the actual module intermediates files, it will see a more consistent timestamp. Bug: 396466053 Test: Manually ran m sync workflows. Also testing togging soong-only on and off and rebuilding Change-Id: Ia0076a2f8e58404c5c3a0bf0d33b09b6846e95bd --- filesystem/filesystem.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'filesystem/filesystem.go') diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 0381951ca..979dba5a1 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -868,7 +868,9 @@ func (f *filesystem) copyPackagingSpecs(ctx android.ModuleContext, builder *andr dirsToSpecs[rootDir] = rootDirSpecs dirsToSpecs[rebasedDir] = rebasedDirSpecs - return f.CopySpecsToDirs(ctx, builder, dirsToSpecs) + // Preserve timestamps for adb sync, so that this staging dir file matches the timestamp in the + // out/target/product staging directory. + return f.CopySpecsToDirs(ctx, builder, dirsToSpecs, true) } func (f *filesystem) rootDirString() string { -- cgit v1.2.3-59-g8ed1b