From b4dff134db8f70ae4441654efe4563178688db36 Mon Sep 17 00:00:00 2001 From: Anas Sulaiman Date: Wed, 7 Feb 2024 21:58:46 +0000 Subject: [PATCH] Allow specifying sub-dir in sbox output xsdc commands end up using the same output directory inside sbox for reading and writing the output archive, resulting in including a partial copy of the archive in itself. This change allows that rule to specify a sub-directory for the inputs leaving the output archive outside of it. Used by https://r.android.com/2955427 Bug: b/322788229 Test: Ran a couple of builds and confirmed no cache misses from xsdc. Also manually checked an archive and confirmed abcence of partial self-copies. Change-Id: If709b111458a83d58906d919c3d2a7787bcbe4ee --- android/rule_builder.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/rule_builder.go b/android/rule_builder.go index e8dbd48c6..85e29bd20 100644 --- a/android/rule_builder.go +++ b/android/rule_builder.go @@ -1157,11 +1157,15 @@ func (c *RuleBuilderCommand) Outputs(paths WritablePaths) *RuleBuilderCommand { // OutputDir adds the output directory to the command line. This is only available when used with RuleBuilder.Sbox, // and will be the temporary output directory managed by sbox, not the final one. -func (c *RuleBuilderCommand) OutputDir() *RuleBuilderCommand { +func (c *RuleBuilderCommand) OutputDir(subPathComponents ...string) *RuleBuilderCommand { if !c.rule.sbox { panic("OutputDir only valid with Sbox") } - return c.Text(sboxOutDir) + path := sboxOutDir + if len(subPathComponents) > 0 { + path = filepath.Join(append([]string{sboxOutDir}, subPathComponents...)...) + } + return c.Text(path) } // DepFile adds the specified depfile path to the paths returned by RuleBuilder.DepFiles and adds it to the command