From 9865ad0c0b83c2a7b63b9b1c12653020309e581f Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 18 Apr 2023 06:08:55 -0700 Subject: [PATCH] Use TemplateMetadata in TemplateExpansionAction.execute() instead of passing arguments separately. PiperOrigin-RevId: 525125577 Change-Id: I952873d29b75175451186615d17e11471a4bf0d1 --- .../actions/BuildInfoFileWriteAction.java | 10 ++++---- .../actions/TemplateExpansionAction.java | 24 ++++++++----------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/BuildInfoFileWriteAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/BuildInfoFileWriteAction.java index 43bf055004c2ec..32fa130408874c 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/actions/BuildInfoFileWriteAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/BuildInfoFileWriteAction.java @@ -172,10 +172,12 @@ public ActionResult execute(ActionExecutionContext ctx) return TemplateExpansionAction.execute( /* actionExecutionContext= */ ctx, /* action= */ this, - Template.forArtifact(template), - getPrimaryOutput(), - substitutionList, - /* makeExecutable= */ false); + TemplateExpansionContext.TemplateMetadata.builder() + .setTemplate(Template.forArtifact(template)) + .setPrimaryOutput(getPrimaryOutput()) + .setSubstitutions(substitutionList) + .setMakeExecutable(false) + .build()); } } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionAction.java index a0238482cb5cd7..f1e622e14ccd6e 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionAction.java @@ -131,24 +131,13 @@ public TemplateExpansionAction(ActionOwner owner, static ActionResult execute( ActionExecutionContext actionExecutionContext, AbstractAction action, - Template template, - Artifact primaryOutput, - List substitutions, - boolean makeExecutable) + TemplateExpansionContext.TemplateMetadata templateMetadata) throws ActionExecutionException, InterruptedException { try { ImmutableList result = actionExecutionContext .getContext(TemplateExpansionContext.class) - .expandTemplate( - action, - actionExecutionContext, - TemplateExpansionContext.TemplateMetadata.builder() - .setTemplate(template) - .setPrimaryOutput(primaryOutput) - .setSubstitutions(ImmutableList.copyOf(substitutions)) - .setMakeExecutable(makeExecutable) - .build()); + .expandTemplate(action, actionExecutionContext, templateMetadata); return ActionResult.create(result); } catch (EvalException e) { @@ -169,7 +158,14 @@ static ActionResult execute( public ActionResult execute(ActionExecutionContext actionExecutionContext) throws ActionExecutionException, InterruptedException { return TemplateExpansionAction.execute( - actionExecutionContext, this, template, getPrimaryOutput(), substitutions, makeExecutable); + actionExecutionContext, + this, + TemplateExpansionContext.TemplateMetadata.builder() + .setTemplate(template) + .setPrimaryOutput(getPrimaryOutput()) + .setSubstitutions(substitutions) + .setMakeExecutable(makeExecutable) + .build()); } @VisibleForTesting