blob: 2e1f8dbd63c13abe37772d56cf2a0e0dd43195dc [file] [log] [blame]
Colin Crossf24a22a2019-01-31 14:12:44 -08001// Copyright 2019 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package java
16
17import (
Paul Duffind3c15132021-04-21 22:12:35 +010018 "strings"
19
Colin Crossf24a22a2019-01-31 14:12:44 -080020 "android/soong/android"
21)
22
23func init() {
Paul Duffin01289a22021-02-04 17:49:33 +000024 RegisterHiddenApiSingletonComponents(android.InitRegistrationContext)
25}
26
27func RegisterHiddenApiSingletonComponents(ctx android.RegistrationContext) {
28 ctx.RegisterSingletonType("hiddenapi", hiddenAPISingletonFactory)
Colin Crossf24a22a2019-01-31 14:12:44 -080029}
30
Paul Duffin175947f2021-03-12 21:44:02 +000031var PrepareForTestWithHiddenApiBuildComponents = android.FixtureRegisterWithContext(RegisterHiddenApiSingletonComponents)
32
Colin Crossf24a22a2019-01-31 14:12:44 -080033type hiddenAPISingletonPathsStruct struct {
Paul Duffinff774a02021-01-29 12:53:15 +000034 // The path to the CSV file that contains the flags that will be encoded into the dex boot jars.
35 //
36 // It is created by the generate_hiddenapi_lists.py tool that is passed the stubFlags along with
37 // a number of additional files that are used to augment the information in the stubFlags with
38 // manually curated data.
39 flags android.OutputPath
40
41 // The path to the CSV index file that contains mappings from Java signature to source location
42 // information for all Java elements annotated with the UnsupportedAppUsage annotation in the
43 // source of all the boot jars.
44 //
45 // It is created by the merge_csv tool which merges all the hiddenAPI.indexCSVPath files that have
46 // been created by the rest of the build. That includes the index files generated for
47 // <x>-hiddenapi modules.
48 index android.OutputPath
49
50 // The path to the CSV metadata file that contains mappings from Java signature to the value of
51 // properties specified on UnsupportedAppUsage annotations in the source of all the boot jars.
52 //
53 // It is created by the merge_csv tool which merges all the hiddenAPI.metadataCSVPath files that
54 // have been created by the rest of the build. That includes the metadata files generated for
55 // <x>-hiddenapi modules.
56 metadata android.OutputPath
57
58 // The path to the CSV metadata file that contains mappings from Java signature to flags obtained
59 // from the public, system and test API stubs.
60 //
61 // This is created by the hiddenapi tool which is given dex files for the public, system and test
62 // API stubs (including product specific stubs) along with dex boot jars, so does not include
63 // <x>-hiddenapi modules. For each API surface (i.e. public, system, test) it records which
64 // members in the dex boot jars match a member in the dex stub jars for that API surface and then
65 // outputs a file containing the signatures of all members in the dex boot jars along with the
66 // flags that indicate which API surface it belongs, if any.
67 //
68 // e.g. a dex member that matches a member in the public dex stubs would have flags
69 // "public-api,system-api,test-api" set (as system and test are both supersets of public). A dex
70 // member that didn't match a member in any of the dex stubs is still output it just has an empty
71 // set of flags.
72 //
73 // The notion of matching is quite complex, it is not restricted to just exact matching but also
74 // follows the Java inheritance rules. e.g. if a method is public then all overriding/implementing
75 // methods are also public. If an interface method is public and a class inherits an
76 // implementation of that method from a super class then that super class method is also public.
77 // That ensures that any method that can be called directly by an App through a public method is
78 // visible to that App.
79 //
80 // Propagating the visibility of members across the inheritance hierarchy at build time will cause
81 // problems when modularizing and unbundling as it that propagation can cross module boundaries.
82 // e.g. Say that a private framework class implements a public interface and inherits an
83 // implementation of one of its methods from a core platform ART class. In that case the ART
84 // implementation method needs to be marked as public which requires the build to have access to
85 // the framework implementation classes at build time. The work to rectify this is being tracked
86 // at http://b/178693149.
87 //
88 // This file (or at least those items marked as being in the public-api) is used by hiddenapi when
89 // creating the metadata and flags for the individual modules in order to perform consistency
90 // checks and filter out bridge methods that are part of the public API. The latter relies on the
91 // propagation of visibility across the inheritance hierarchy.
Artur Satayevb5df8a02020-02-19 16:39:59 +000092 stubFlags android.OutputPath
Colin Crossf24a22a2019-01-31 14:12:44 -080093}
94
95var hiddenAPISingletonPathsKey = android.NewOnceKey("hiddenAPISingletonPathsKey")
96
97// hiddenAPISingletonPaths creates all the paths for singleton files the first time it is called, which may be
98// from a ModuleContext that needs to reference a file that will be created by a singleton rule that hasn't
99// yet been created.
100func hiddenAPISingletonPaths(ctx android.PathContext) hiddenAPISingletonPathsStruct {
101 return ctx.Config().Once(hiddenAPISingletonPathsKey, func() interface{} {
Paul Duffin6a766452021-04-12 14:15:22 +0100102 // Make the paths relative to the out/soong/hiddenapi directory instead of to the out/soong/
103 // directory. This ensures that if they are used as java_resources they do not end up in a
104 // hiddenapi directory in the resulting APK.
105 hiddenapiDir := android.PathForOutput(ctx, "hiddenapi")
Colin Crossf24a22a2019-01-31 14:12:44 -0800106 return hiddenAPISingletonPathsStruct{
Paul Duffin6a766452021-04-12 14:15:22 +0100107 flags: hiddenapiDir.Join(ctx, "hiddenapi-flags.csv"),
108 index: hiddenapiDir.Join(ctx, "hiddenapi-index.csv"),
109 metadata: hiddenapiDir.Join(ctx, "hiddenapi-unsupported.csv"),
110 stubFlags: hiddenapiDir.Join(ctx, "hiddenapi-stub-flags.txt"),
Colin Crossf24a22a2019-01-31 14:12:44 -0800111 }
112 }).(hiddenAPISingletonPathsStruct)
113}
114
Colin Crossf24a22a2019-01-31 14:12:44 -0800115func hiddenAPISingletonFactory() android.Singleton {
Colin Crossed023ec2019-02-19 12:38:45 -0800116 return &hiddenAPISingleton{}
Colin Crossf24a22a2019-01-31 14:12:44 -0800117}
118
Colin Crossed023ec2019-02-19 12:38:45 -0800119type hiddenAPISingleton struct {
Paul Duffin85dee5d2021-04-13 00:14:38 +0100120 flags android.Path
Colin Crossed023ec2019-02-19 12:38:45 -0800121}
Colin Crossf24a22a2019-01-31 14:12:44 -0800122
123// hiddenAPI singleton rules
Colin Crossed023ec2019-02-19 12:38:45 -0800124func (h *hiddenAPISingleton) GenerateBuildActions(ctx android.SingletonContext) {
Colin Crossf24a22a2019-01-31 14:12:44 -0800125 // Don't run any hiddenapi rules if UNSAFE_DISABLE_HIDDENAPI_FLAGS=true
126 if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
127 return
128 }
129
130 stubFlagsRule(ctx)
131
Bill Peckhambae47492021-01-08 09:34:44 -0800132 // If there is a prebuilt hiddenapi dir, generate rules to use the
133 // files within. Generally, we build the hiddenapi files from source
134 // during the build, ensuring consistency. It's possible, in a split
135 // build (framework and vendor) scenario, for the vendor build to use
136 // prebuilt hiddenapi files from the framework build. In this scenario,
137 // the framework and vendor builds must use the same source to ensure
138 // consistency.
139
140 if ctx.Config().PrebuiltHiddenApiDir(ctx) != "" {
141 h.flags = prebuiltFlagsRule(ctx)
Paul Duffin22c74312021-04-12 16:39:39 +0100142 prebuiltIndexRule(ctx)
Bill Peckhambae47492021-01-08 09:34:44 -0800143 return
144 }
145
Colin Crossf24a22a2019-01-31 14:12:44 -0800146 // These rules depend on files located in frameworks/base, skip them if running in a tree that doesn't have them.
Jiyong Park09cb6292019-07-15 15:29:23 +0900147 if ctx.Config().FrameworksBaseDirExists(ctx) {
Colin Crossed023ec2019-02-19 12:38:45 -0800148 h.flags = flagsRule(ctx)
Colin Crossf24a22a2019-01-31 14:12:44 -0800149 } else {
Colin Crossed023ec2019-02-19 12:38:45 -0800150 h.flags = emptyFlagsRule(ctx)
151 }
152}
153
154// Export paths to Make. INTERNAL_PLATFORM_HIDDENAPI_FLAGS is used by Make rules in art/ and cts/.
Colin Crossed023ec2019-02-19 12:38:45 -0800155func (h *hiddenAPISingleton) MakeVars(ctx android.MakeVarsContext) {
156 if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
157 return
158 }
159
160 ctx.Strict("INTERNAL_PLATFORM_HIDDENAPI_FLAGS", h.flags.String())
Colin Crossf24a22a2019-01-31 14:12:44 -0800161}
162
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100163// hiddenAPIComputeMonolithicStubLibModules computes the set of module names that provide stubs
164// needed to produce the hidden API monolithic stub flags file.
165func hiddenAPIComputeMonolithicStubLibModules(ctx android.BuilderContext) map[android.SdkKind][]string {
Anton Hanssona2adc372020-07-03 15:31:32 +0100166 var publicStubModules []string
167 var systemStubModules []string
168 var testStubModules []string
169 var corePlatformStubModules []string
170
171 if ctx.Config().AlwaysUsePrebuiltSdks() {
172 // Build configuration mandates using prebuilt stub modules
173 publicStubModules = append(publicStubModules, "sdk_public_current_android")
174 systemStubModules = append(systemStubModules, "sdk_system_current_android")
175 testStubModules = append(testStubModules, "sdk_test_current_android")
176 } else {
177 // Use stub modules built from source
178 publicStubModules = append(publicStubModules, "android_stubs_current")
179 systemStubModules = append(systemStubModules, "android_system_stubs_current")
180 testStubModules = append(testStubModules, "android_test_stubs_current")
Paul Duffin719fed42019-02-28 16:15:44 +0000181 }
Anton Hanssona2adc372020-07-03 15:31:32 +0100182 // We do not have prebuilts of the core platform api yet
183 corePlatformStubModules = append(corePlatformStubModules, "legacy.core.platform.api.stubs")
Paul Duffin719fed42019-02-28 16:15:44 +0000184
Colin Crossf24a22a2019-01-31 14:12:44 -0800185 // Allow products to define their own stubs for custom product jars that apps can use.
186 publicStubModules = append(publicStubModules, ctx.Config().ProductHiddenAPIStubs()...)
187 systemStubModules = append(systemStubModules, ctx.Config().ProductHiddenAPIStubsSystem()...)
188 testStubModules = append(testStubModules, ctx.Config().ProductHiddenAPIStubsTest()...)
Allen Hairde816cf2019-02-25 16:37:42 -0800189 if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") {
190 publicStubModules = append(publicStubModules, "jacoco-stubs")
191 }
Colin Crossf24a22a2019-01-31 14:12:44 -0800192
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100193 m := map[android.SdkKind][]string{}
194 m[android.SdkPublic] = publicStubModules
195 m[android.SdkSystem] = systemStubModules
196 m[android.SdkTest] = testStubModules
197 m[android.SdkCorePlatform] = corePlatformStubModules
198 return m
199}
Colin Crossf24a22a2019-01-31 14:12:44 -0800200
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100201// stubFlagsRule creates the rule to build hiddenapi-stub-flags.txt out of dex jars from stub modules and boot image
202// modules.
203func stubFlagsRule(ctx android.SingletonContext) {
204
205 sdkKindToModules := hiddenAPIComputeMonolithicStubLibModules(ctx)
206
207 // Create a set of path slices into which the DexJarBuildPath from the stub modules can be stored.
208 sdkKindToPathList := map[android.SdkKind]android.Paths{}
209 for sdkKind, modules := range sdkKindToModules {
210 sdkKindToPathList[sdkKind] = make(android.Paths, len(modules))
Colin Crossf24a22a2019-01-31 14:12:44 -0800211 }
212
213 var bootDexJars android.Paths
Colin Crossf24a22a2019-01-31 14:12:44 -0800214 ctx.VisitAllModules(func(module android.Module) {
215 // Collect dex jar paths for the modules listed above.
Colin Crossdcf71b22021-02-01 13:59:03 -0800216 if j, ok := module.(UsesLibraryDependency); ok {
Colin Crossf24a22a2019-01-31 14:12:44 -0800217 name := ctx.ModuleName(module)
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100218 for _, sdkKind := range hiddenAPIRelevantSdkKinds {
219 if i := android.IndexList(name, sdkKindToModules[sdkKind]); i != -1 {
220 sdkKindToPathList[sdkKind][i] = j.DexJarBuildPath()
Colin Crossf24a22a2019-01-31 14:12:44 -0800221 }
222 }
223 }
224
225 // Collect dex jar paths for modules that had hiddenapi encode called on them.
226 if h, ok := module.(hiddenAPIIntf); ok {
227 if jar := h.bootDexJar(); jar != nil {
228 bootDexJars = append(bootDexJars, jar)
229 }
230 }
231 })
232
233 var missingDeps []string
234 // Ensure all modules were converted to paths
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100235 for _, sdkKind := range hiddenAPIRelevantSdkKinds {
236 pathList := sdkKindToPathList[sdkKind]
Colin Crossf24a22a2019-01-31 14:12:44 -0800237 for i := range pathList {
238 if pathList[i] == nil {
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100239 moduleName := sdkKindToModules[sdkKind][i]
Paul Duffin7f48eef2020-12-03 11:15:58 +0000240 pathList[i] = android.PathForOutput(ctx, "missing/module", moduleName)
Colin Crossf24a22a2019-01-31 14:12:44 -0800241 if ctx.Config().AllowMissingDependencies() {
Paul Duffin7f48eef2020-12-03 11:15:58 +0000242 missingDeps = append(missingDeps, moduleName)
Colin Crossf24a22a2019-01-31 14:12:44 -0800243 } else {
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100244 ctx.Errorf("failed to find dex jar path for module %q", moduleName)
Colin Crossf24a22a2019-01-31 14:12:44 -0800245 }
246 }
247 }
248 }
249
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100250 outputPath := hiddenAPISingletonPaths(ctx).stubFlags
251 rule := ruleToGenerateHiddenAPIStubFlagsFile(ctx, outputPath, bootDexJars, sdkKindToPathList)
252 rule.MissingDeps(missingDeps)
253 rule.Build("hiddenAPIStubFlagsFile", "hiddenapi stub flags")
254}
255
256var sdkKindToHiddenapiListOption = map[android.SdkKind]string{
257 android.SdkPublic: "public-stub-classpath",
258 android.SdkSystem: "system-stub-classpath",
259 android.SdkTest: "test-stub-classpath",
260 android.SdkCorePlatform: "core-platform-stub-classpath",
261}
262
263// ruleToGenerateHiddenAPIStubFlagsFile creates a rule to create a hidden API stub flags file.
264//
265// The rule is initialized but not built so that the caller can modify it and select an appropriate
266// name.
267func ruleToGenerateHiddenAPIStubFlagsFile(ctx android.SingletonContext, outputPath android.OutputPath, bootDexJars android.Paths, sdkKindToPathList map[android.SdkKind]android.Paths) *android.RuleBuilder {
Colin Crossf24a22a2019-01-31 14:12:44 -0800268 // Singleton rule which applies hiddenapi on all boot class path dex files.
Colin Crossf1a035e2020-11-16 17:32:30 -0800269 rule := android.NewRuleBuilder(pctx, ctx)
Colin Crossf24a22a2019-01-31 14:12:44 -0800270
Paul Duffind3c15132021-04-21 22:12:35 +0100271 tempPath := tempPathForRestat(ctx, outputPath)
Colin Crossf24a22a2019-01-31 14:12:44 -0800272
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100273 command := rule.Command().
Martin Stjernholm7260d062019-12-09 21:47:14 +0000274 Tool(ctx.Config().HostToolPath(ctx, "hiddenapi")).
Colin Crossf24a22a2019-01-31 14:12:44 -0800275 Text("list").
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100276 FlagForEachInput("--boot-dex=", bootDexJars)
277
278 // Iterate over the sdk
279 for _, sdkKind := range hiddenAPIRelevantSdkKinds {
280 paths := sdkKindToPathList[sdkKind]
281 if len(paths) > 0 {
282 option := sdkKindToHiddenapiListOption[sdkKind]
283 command.FlagWithInputList("--"+option+"=", paths, ":")
284 }
285 }
286
287 // Add the output path.
288 command.FlagWithOutput("--out-api-flags=", tempPath)
Colin Crossf24a22a2019-01-31 14:12:44 -0800289
290 commitChangeForRestat(rule, tempPath, outputPath)
Paul Duffin3e7fcc32021-04-15 13:31:38 +0100291 return rule
Colin Crossf24a22a2019-01-31 14:12:44 -0800292}
293
Paul Duffindd63d6d2021-02-03 18:34:00 +0000294// Checks to see whether the supplied module variant is in the list of boot jars.
295//
296// This is similar to logic in getBootImageJar() so any changes needed here are likely to be needed
297// there too.
298//
299// TODO(b/179354495): Avoid having to perform this type of check or if necessary dedup it.
Paul Duffin82b3fcf2021-02-12 15:42:46 +0000300func isModuleInConfiguredList(ctx android.BaseModuleContext, module android.Module, configuredBootJars android.ConfiguredJarList) bool {
301 name := ctx.OtherModuleName(module)
Paul Duffindd63d6d2021-02-03 18:34:00 +0000302
303 // Strip a prebuilt_ prefix so that this can match a prebuilt module that has not been renamed.
304 name = android.RemoveOptionalPrebuiltPrefix(name)
305
306 // Ignore any module that is not listed in the boot image configuration.
307 index := configuredBootJars.IndexOfJar(name)
308 if index == -1 {
309 return false
310 }
311
312 // It is an error if the module is not an ApexModule.
313 if _, ok := module.(android.ApexModule); !ok {
Paul Duffin82b3fcf2021-02-12 15:42:46 +0000314 ctx.ModuleErrorf("is configured in boot jars but does not support being added to an apex")
Paul Duffindd63d6d2021-02-03 18:34:00 +0000315 return false
316 }
317
Paul Duffin82b3fcf2021-02-12 15:42:46 +0000318 apexInfo := ctx.OtherModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
Paul Duffindd63d6d2021-02-03 18:34:00 +0000319
320 // Now match the apex part of the boot image configuration.
321 requiredApex := configuredBootJars.Apex(index)
322 if requiredApex == "platform" {
323 if len(apexInfo.InApexes) != 0 {
324 // A platform variant is required but this is for an apex so ignore it.
325 return false
326 }
327 } else if !apexInfo.InApexByBaseName(requiredApex) {
328 // An apex variant for a specific apex is required but this is the wrong apex.
329 return false
330 }
331
332 return true
333}
334
Bill Peckhambae47492021-01-08 09:34:44 -0800335func prebuiltFlagsRule(ctx android.SingletonContext) android.Path {
336 outputPath := hiddenAPISingletonPaths(ctx).flags
337 inputPath := android.PathForSource(ctx, ctx.Config().PrebuiltHiddenApiDir(ctx), "hiddenapi-flags.csv")
338
339 ctx.Build(pctx, android.BuildParams{
340 Rule: android.Cp,
341 Output: outputPath,
342 Input: inputPath,
343 })
344
345 return outputPath
346}
347
Paul Duffin22c74312021-04-12 16:39:39 +0100348func prebuiltIndexRule(ctx android.SingletonContext) {
349 outputPath := hiddenAPISingletonPaths(ctx).index
350 inputPath := android.PathForSource(ctx, ctx.Config().PrebuiltHiddenApiDir(ctx), "hiddenapi-index.csv")
351
352 ctx.Build(pctx, android.BuildParams{
353 Rule: android.Cp,
354 Output: outputPath,
355 Input: inputPath,
356 })
357}
358
Paul Duffin702210b2021-04-08 20:12:41 +0100359// flagsRule is a placeholder that simply returns the location of the file, the generation of the
360// ninja rules is done in generateHiddenAPIBuildActions.
Colin Crossed023ec2019-02-19 12:38:45 -0800361func flagsRule(ctx android.SingletonContext) android.Path {
Colin Crossf24a22a2019-01-31 14:12:44 -0800362 outputPath := hiddenAPISingletonPaths(ctx).flags
Paul Duffinc6bb7cf2021-04-08 17:49:27 +0100363 return outputPath
364}
365
Colin Crossf24a22a2019-01-31 14:12:44 -0800366// emptyFlagsRule creates a rule to build an empty hiddenapi-flags.csv, which is needed by master-art-host builds that
367// have a partial manifest without frameworks/base but still need to build a boot image.
Colin Crossed023ec2019-02-19 12:38:45 -0800368func emptyFlagsRule(ctx android.SingletonContext) android.Path {
Colin Crossf1a035e2020-11-16 17:32:30 -0800369 rule := android.NewRuleBuilder(pctx, ctx)
Colin Crossf24a22a2019-01-31 14:12:44 -0800370
371 outputPath := hiddenAPISingletonPaths(ctx).flags
372
Colin Cross69f59a32019-02-15 10:39:37 -0800373 rule.Command().Text("rm").Flag("-f").Output(outputPath)
374 rule.Command().Text("touch").Output(outputPath)
Colin Crossf24a22a2019-01-31 14:12:44 -0800375
Colin Crossf1a035e2020-11-16 17:32:30 -0800376 rule.Build("emptyHiddenAPIFlagsFile", "empty hiddenapi flags")
Colin Crossed023ec2019-02-19 12:38:45 -0800377
378 return outputPath
Colin Crossf24a22a2019-01-31 14:12:44 -0800379}
380
Paul Duffind3c15132021-04-21 22:12:35 +0100381// tempPathForRestat creates a path of the same type as the supplied type but with a name of
382// <path>.tmp.
383//
384// e.g. If path is an OutputPath for out/soong/hiddenapi/hiddenapi-flags.csv then this will return
385// an OutputPath for out/soong/hiddenapi/hiddenapi-flags.csv.tmp
386func tempPathForRestat(ctx android.PathContext, path android.WritablePath) android.WritablePath {
387 extWithoutLeadingDot := strings.TrimPrefix(path.Ext(), ".")
388 return path.ReplaceExtension(ctx, extWithoutLeadingDot+".tmp")
389}
390
Colin Crossf24a22a2019-01-31 14:12:44 -0800391// commitChangeForRestat adds a command to a rule that updates outputPath from tempPath if they are different. It
392// also marks the rule as restat and marks the tempPath as a temporary file that should not be considered an output of
393// the rule.
394func commitChangeForRestat(rule *android.RuleBuilder, tempPath, outputPath android.WritablePath) {
395 rule.Restat()
Colin Cross69f59a32019-02-15 10:39:37 -0800396 rule.Temporary(tempPath)
Colin Crossf24a22a2019-01-31 14:12:44 -0800397 rule.Command().
398 Text("(").
399 Text("if").
Colin Cross69f59a32019-02-15 10:39:37 -0800400 Text("cmp -s").Input(tempPath).Output(outputPath).Text(";").
Colin Crossf24a22a2019-01-31 14:12:44 -0800401 Text("then").
Colin Cross69f59a32019-02-15 10:39:37 -0800402 Text("rm").Input(tempPath).Text(";").
Colin Crossf24a22a2019-01-31 14:12:44 -0800403 Text("else").
Colin Cross69f59a32019-02-15 10:39:37 -0800404 Text("mv").Input(tempPath).Output(outputPath).Text(";").
Colin Crossf24a22a2019-01-31 14:12:44 -0800405 Text("fi").
406 Text(")")
407}