Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 1 | // Copyright 2019 The Android Open Source Project |
| 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 | |
| 15 | package rust |
| 16 | |
| 17 | import ( |
| 18 | "strings" |
| 19 | |
| 20 | "github.com/google/blueprint" |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 21 | "github.com/google/blueprint/pathtools" |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 22 | |
| 23 | "android/soong/android" |
Ivan Lozano | f3717ee | 2020-05-20 09:03:20 -0400 | [diff] [blame] | 24 | "android/soong/cc" |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 25 | ) |
| 26 | |
| 27 | var ( |
| 28 | _ = pctx.SourcePathVariable("rustcCmd", "${config.RustBin}/rustc") |
| 29 | rustc = pctx.AndroidStaticRule("rustc", |
| 30 | blueprint.RuleParams{ |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 31 | Command: "$envVars $rustcCmd " + |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 32 | "-C linker=${config.RustLinker} " + |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 33 | "-C link-args=\"${crtBegin} ${config.RustLinkerArgs} ${linkFlags} ${crtEnd}\" " + |
Chih-Hung Hsieh | 885f1c6 | 2019-09-29 22:38:31 -0700 | [diff] [blame] | 34 | "--emit link -o $out --emit dep-info=$out.d $in ${libFlags} $rustcFlags", |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 35 | CommandDeps: []string{"$rustcCmd"}, |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 36 | // Rustc deps-info writes out make compatible dep files: https://github.com/rust-lang/rust/issues/7633 |
| 37 | Deps: blueprint.DepsGCC, |
| 38 | Depfile: "$out.d", |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 39 | }, |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 40 | "rustcFlags", "linkFlags", "libFlags", "crtBegin", "crtEnd", "envVars") |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 41 | |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 42 | _ = pctx.SourcePathVariable("clippyCmd", "${config.RustBin}/clippy-driver") |
| 43 | clippyDriver = pctx.AndroidStaticRule("clippy", |
| 44 | blueprint.RuleParams{ |
| 45 | Command: "$clippyCmd " + |
| 46 | // Because clippy-driver uses rustc as backend, we need to have some output even during the linting. |
| 47 | // Use the metadata output as it has the smallest footprint. |
| 48 | "--emit metadata -o $out $in ${libFlags} " + |
Thiébaud Weksteen | 8e46efa | 2020-06-30 21:43:35 +0200 | [diff] [blame] | 49 | "$rustcFlags $clippyFlags", |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 50 | CommandDeps: []string{"$clippyCmd"}, |
| 51 | }, |
| 52 | "rustcFlags", "libFlags", "clippyFlags") |
| 53 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 54 | zip = pctx.AndroidStaticRule("zip", |
| 55 | blueprint.RuleParams{ |
| 56 | Command: "cat $out.rsp | tr ' ' '\\n' | tr -d \\' | sort -u > ${out}.tmp && ${SoongZipCmd} -o ${out} -C $$OUT_DIR -l ${out}.tmp", |
| 57 | CommandDeps: []string{"${SoongZipCmd}"}, |
| 58 | Rspfile: "$out.rsp", |
| 59 | RspfileContent: "$in", |
| 60 | }) |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 61 | |
| 62 | cp = pctx.AndroidStaticRule("cp", |
| 63 | blueprint.RuleParams{ |
| 64 | Command: "cp `cat $outDir.rsp` $outDir", |
| 65 | Rspfile: "${outDir}.rsp", |
| 66 | RspfileContent: "$in", |
| 67 | }, |
| 68 | "outDir") |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 69 | ) |
| 70 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 71 | type buildOutput struct { |
| 72 | outputFile android.Path |
| 73 | coverageFile android.Path |
| 74 | } |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 75 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 76 | func init() { |
| 77 | pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 80 | func TransformSrcToBinary(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 81 | outputFile android.WritablePath, linkDirs []string) buildOutput { |
Ivan Lozano | 31b095d | 2019-11-20 10:14:33 -0800 | [diff] [blame] | 82 | flags.RustFlags = append(flags.RustFlags, "-C lto") |
| 83 | |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 84 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "bin", linkDirs) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 85 | } |
| 86 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 87 | func TransformSrctoRlib(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 88 | outputFile android.WritablePath, linkDirs []string) buildOutput { |
| 89 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "rlib", linkDirs) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 92 | func TransformSrctoDylib(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 93 | outputFile android.WritablePath, linkDirs []string) buildOutput { |
| 94 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "dylib", linkDirs) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 97 | func TransformSrctoStatic(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 98 | outputFile android.WritablePath, linkDirs []string) buildOutput { |
Ivan Lozano | 31b095d | 2019-11-20 10:14:33 -0800 | [diff] [blame] | 99 | flags.RustFlags = append(flags.RustFlags, "-C lto") |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 100 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "staticlib", linkDirs) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 103 | func TransformSrctoShared(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 104 | outputFile android.WritablePath, linkDirs []string) buildOutput { |
Ivan Lozano | 31b095d | 2019-11-20 10:14:33 -0800 | [diff] [blame] | 105 | flags.RustFlags = append(flags.RustFlags, "-C lto") |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 106 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "cdylib", linkDirs) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 109 | func TransformSrctoProcMacro(ctx ModuleContext, mainSrc android.Path, deps PathDeps, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 110 | flags Flags, outputFile android.WritablePath, linkDirs []string) buildOutput { |
| 111 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "proc-macro", linkDirs) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | func rustLibsToPaths(libs RustLibraries) android.Paths { |
| 115 | var paths android.Paths |
| 116 | for _, lib := range libs { |
| 117 | paths = append(paths, lib.Path) |
| 118 | } |
| 119 | return paths |
| 120 | } |
| 121 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 122 | func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 123 | outputFile android.WritablePath, crate_type string, linkDirs []string) buildOutput { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 124 | |
| 125 | var inputs android.Paths |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 126 | var implicits android.Paths |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 127 | var envVars []string |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 128 | var output buildOutput |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 129 | var libFlags, rustcFlags, linkFlags []string |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 130 | var implicitOutputs android.WritablePaths |
| 131 | |
| 132 | output.outputFile = outputFile |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 133 | crate_name := ctx.RustModule().CrateName() |
| 134 | targetTriple := ctx.toolchain().RustTriple() |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 135 | |
| 136 | inputs = append(inputs, main) |
| 137 | |
| 138 | // Collect rustc flags |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 139 | rustcFlags = append(rustcFlags, flags.GlobalRustFlags...) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 140 | rustcFlags = append(rustcFlags, flags.RustFlags...) |
| 141 | rustcFlags = append(rustcFlags, "--crate-type="+crate_type) |
Ivan Lozano | ad8b18b | 2019-10-31 19:38:29 -0700 | [diff] [blame] | 142 | if crate_name != "" { |
| 143 | rustcFlags = append(rustcFlags, "--crate-name="+crate_name) |
| 144 | } |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 145 | if targetTriple != "" { |
| 146 | rustcFlags = append(rustcFlags, "--target="+targetTriple) |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 147 | linkFlags = append(linkFlags, "-target "+targetTriple) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 148 | } |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 149 | |
| 150 | // Suppress an implicit sysroot |
| 151 | rustcFlags = append(rustcFlags, "--sysroot=/dev/null") |
| 152 | |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 153 | // Collect linker flags |
| 154 | linkFlags = append(linkFlags, flags.GlobalLinkFlags...) |
| 155 | linkFlags = append(linkFlags, flags.LinkFlags...) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 156 | |
| 157 | // Collect library/crate flags |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 158 | for _, lib := range deps.RLibs { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 159 | libFlags = append(libFlags, "--extern "+lib.CrateName+"="+lib.Path.String()) |
| 160 | } |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 161 | for _, lib := range deps.DyLibs { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 162 | libFlags = append(libFlags, "--extern "+lib.CrateName+"="+lib.Path.String()) |
| 163 | } |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 164 | for _, proc_macro := range deps.ProcMacros { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 165 | libFlags = append(libFlags, "--extern "+proc_macro.CrateName+"="+proc_macro.Path.String()) |
| 166 | } |
| 167 | |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 168 | for _, path := range linkDirs { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 169 | libFlags = append(libFlags, "-L "+path) |
| 170 | } |
| 171 | |
| 172 | // Collect dependencies |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 173 | implicits = append(implicits, rustLibsToPaths(deps.RLibs)...) |
| 174 | implicits = append(implicits, rustLibsToPaths(deps.DyLibs)...) |
| 175 | implicits = append(implicits, rustLibsToPaths(deps.ProcMacros)...) |
| 176 | implicits = append(implicits, deps.StaticLibs...) |
| 177 | implicits = append(implicits, deps.SharedLibs...) |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 178 | |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 179 | if deps.CrtBegin.Valid() { |
| 180 | implicits = append(implicits, deps.CrtBegin.Path(), deps.CrtEnd.Path()) |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 181 | } |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 182 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 183 | if flags.Coverage { |
| 184 | var gcnoFile android.WritablePath |
Ivan Lozano | f3717ee | 2020-05-20 09:03:20 -0400 | [diff] [blame] | 185 | // Provide consistency with cc gcda output, see cc/builder.go init() |
Ivan Lozano | 796fc4c | 2020-06-17 11:36:57 -0400 | [diff] [blame] | 186 | profileEmitArg := strings.TrimPrefix(cc.PwdPrefix(), "PWD=") + "/" |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 187 | |
| 188 | if outputFile.Ext() != "" { |
| 189 | gcnoFile = android.PathForModuleOut(ctx, pathtools.ReplaceExtension(outputFile.Base(), "gcno")) |
Ivan Lozano | f3717ee | 2020-05-20 09:03:20 -0400 | [diff] [blame] | 190 | rustcFlags = append(rustcFlags, "-Z profile-emit="+profileEmitArg+android.PathForModuleOut( |
| 191 | ctx, pathtools.ReplaceExtension(outputFile.Base(), "gcda")).String()) |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 192 | } else { |
| 193 | gcnoFile = android.PathForModuleOut(ctx, outputFile.Base()+".gcno") |
Ivan Lozano | f3717ee | 2020-05-20 09:03:20 -0400 | [diff] [blame] | 194 | rustcFlags = append(rustcFlags, "-Z profile-emit="+profileEmitArg+android.PathForModuleOut( |
| 195 | ctx, outputFile.Base()+".gcda").String()) |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | implicitOutputs = append(implicitOutputs, gcnoFile) |
| 199 | output.coverageFile = gcnoFile |
| 200 | } |
| 201 | |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 202 | if flags.Clippy { |
| 203 | clippyFile := android.PathForModuleOut(ctx, outputFile.Base()+".clippy") |
| 204 | ctx.Build(pctx, android.BuildParams{ |
| 205 | Rule: clippyDriver, |
| 206 | Description: "clippy " + main.Rel(), |
| 207 | Output: clippyFile, |
| 208 | ImplicitOutputs: nil, |
| 209 | Inputs: inputs, |
| 210 | Implicits: implicits, |
| 211 | Args: map[string]string{ |
| 212 | "rustcFlags": strings.Join(rustcFlags, " "), |
| 213 | "libFlags": strings.Join(libFlags, " "), |
| 214 | "clippyFlags": strings.Join(flags.ClippyFlags, " "), |
| 215 | }, |
| 216 | }) |
| 217 | // Declare the clippy build as an implicit dependency of the original crate. |
| 218 | implicits = append(implicits, clippyFile) |
| 219 | } |
| 220 | |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 221 | if len(deps.SrcDeps) > 0 { |
| 222 | moduleGenDir := android.PathForModuleOut(ctx, "out/") |
| 223 | var outputs android.WritablePaths |
| 224 | |
| 225 | for _, genSrc := range deps.SrcDeps { |
| 226 | if android.SuffixInList(outputs.Strings(), "out/"+genSrc.Base()) { |
| 227 | ctx.PropertyErrorf("srcs", |
| 228 | "multiple source providers generate the same filename output: "+genSrc.Base()) |
| 229 | } |
| 230 | outputs = append(outputs, android.PathForModuleOut(ctx, "out/"+genSrc.Base())) |
| 231 | } |
| 232 | |
| 233 | ctx.Build(pctx, android.BuildParams{ |
| 234 | Rule: cp, |
| 235 | Description: "cp " + moduleGenDir.Rel(), |
| 236 | Outputs: outputs, |
| 237 | Inputs: deps.SrcDeps, |
| 238 | Args: map[string]string{ |
| 239 | "outDir": moduleGenDir.String(), |
| 240 | }, |
| 241 | }) |
| 242 | implicits = append(implicits, outputs.Paths()...) |
| 243 | envVars = append(envVars, "OUT_DIR=$$PWD/"+moduleGenDir.String()) |
| 244 | } |
| 245 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 246 | ctx.Build(pctx, android.BuildParams{ |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 247 | Rule: rustc, |
| 248 | Description: "rustc " + main.Rel(), |
| 249 | Output: outputFile, |
| 250 | ImplicitOutputs: implicitOutputs, |
| 251 | Inputs: inputs, |
| 252 | Implicits: implicits, |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 253 | Args: map[string]string{ |
| 254 | "rustcFlags": strings.Join(rustcFlags, " "), |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 255 | "linkFlags": strings.Join(linkFlags, " "), |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 256 | "libFlags": strings.Join(libFlags, " "), |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 257 | "crtBegin": deps.CrtBegin.String(), |
| 258 | "crtEnd": deps.CrtEnd.String(), |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 259 | "envVars": strings.Join(envVars, " "), |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 260 | }, |
| 261 | }) |
| 262 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 263 | return output |
| 264 | } |
| 265 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 266 | func TransformCoverageFilesToZip(ctx ModuleContext, |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 267 | covFiles android.Paths, baseName string) android.OptionalPath { |
| 268 | if len(covFiles) > 0 { |
| 269 | |
| 270 | outputFile := android.PathForModuleOut(ctx, baseName+".zip") |
| 271 | |
| 272 | ctx.Build(pctx, android.BuildParams{ |
| 273 | Rule: zip, |
| 274 | Description: "zip " + outputFile.Base(), |
| 275 | Inputs: covFiles, |
| 276 | Output: outputFile, |
| 277 | }) |
| 278 | |
| 279 | return android.OptionalPathForPath(outputFile) |
| 280 | } |
| 281 | return android.OptionalPath{} |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 282 | } |