diff options
author | 2021-04-22 02:22:58 +0000 | |
---|---|---|
committer | 2021-04-22 02:22:58 +0000 | |
commit | f434cb5c1d116de44b19ef70a7b8fa6dbd3bb253 (patch) | |
tree | 495286af9c88559cdee5c777de0f1b399aa8a204 /java/hiddenapi_singleton.go | |
parent | 752d63cd83e56047ca02b30c40d6ee4fdedc24bb (diff) | |
parent | d3c1513df94c1494aa84f3c4cdfb29bb6b9d8252 (diff) |
Merge "Add tempPathForRestat to improve consistency"
Diffstat (limited to 'java/hiddenapi_singleton.go')
-rw-r--r-- | java/hiddenapi_singleton.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go index ed0b72250..0149609f5 100644 --- a/java/hiddenapi_singleton.go +++ b/java/hiddenapi_singleton.go @@ -15,6 +15,8 @@ package java import ( + "strings" + "android/soong/android" ) @@ -242,7 +244,7 @@ func stubFlagsRule(ctx android.SingletonContext) { rule := android.NewRuleBuilder(pctx, ctx) outputPath := hiddenAPISingletonPaths(ctx).stubFlags - tempPath := android.PathForOutput(ctx, outputPath.Rel()+".tmp") + tempPath := tempPathForRestat(ctx, outputPath) rule.MissingDeps(missingDeps) @@ -348,6 +350,16 @@ func emptyFlagsRule(ctx android.SingletonContext) android.Path { return outputPath } +// tempPathForRestat creates a path of the same type as the supplied type but with a name of +// <path>.tmp. +// +// e.g. If path is an OutputPath for out/soong/hiddenapi/hiddenapi-flags.csv then this will return +// an OutputPath for out/soong/hiddenapi/hiddenapi-flags.csv.tmp +func tempPathForRestat(ctx android.PathContext, path android.WritablePath) android.WritablePath { + extWithoutLeadingDot := strings.TrimPrefix(path.Ext(), ".") + return path.ReplaceExtension(ctx, extWithoutLeadingDot+".tmp") +} + // commitChangeForRestat adds a command to a rule that updates outputPath from tempPath if they are different. It // also marks the rule as restat and marks the tempPath as a temporary file that should not be considered an output of // the rule. |