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 ( |
Ivan Lozano | 1776a2a | 2020-11-11 10:59:52 -0500 | [diff] [blame] | 18 | "path/filepath" |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 19 | "strings" |
| 20 | |
| 21 | "github.com/google/blueprint" |
| 22 | |
| 23 | "android/soong/android" |
Thiébaud Weksteen | df229cb | 2021-02-10 14:07:57 +0100 | [diff] [blame] | 24 | "android/soong/bloaty" |
Thiébaud Weksteen | 71512f3 | 2020-11-03 15:17:51 +0100 | [diff] [blame] | 25 | "android/soong/rust/config" |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 26 | ) |
| 27 | |
| 28 | var ( |
| 29 | _ = pctx.SourcePathVariable("rustcCmd", "${config.RustBin}/rustc") |
| 30 | rustc = pctx.AndroidStaticRule("rustc", |
| 31 | blueprint.RuleParams{ |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 32 | Command: "$envVars $rustcCmd " + |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 33 | "-C linker=${config.RustLinker} " + |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 34 | "-C link-args=\"${crtBegin} ${config.RustLinkerArgs} ${linkFlags} ${crtEnd}\" " + |
Chih-Hung Hsieh | 29aa9fd | 2020-08-13 15:46:21 -0700 | [diff] [blame] | 35 | "--emit link -o $out --emit dep-info=$out.d.raw $in ${libFlags} $rustcFlags" + |
| 36 | " && grep \"^$out:\" $out.d.raw > $out.d", |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 37 | CommandDeps: []string{"$rustcCmd"}, |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 38 | // Rustc deps-info writes out make compatible dep files: https://github.com/rust-lang/rust/issues/7633 |
Chih-Hung Hsieh | 29aa9fd | 2020-08-13 15:46:21 -0700 | [diff] [blame] | 39 | // Rustc emits unneeded dependency lines for the .d and input .rs files. |
| 40 | // Those extra lines cause ninja warning: |
| 41 | // "warning: depfile has multiple output paths" |
| 42 | // For ninja, we keep/grep only the dependency rule for the rust $out file. |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 43 | Deps: blueprint.DepsGCC, |
| 44 | Depfile: "$out.d", |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 45 | }, |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 46 | "rustcFlags", "linkFlags", "libFlags", "crtBegin", "crtEnd", "envVars") |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 47 | |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 48 | _ = pctx.SourcePathVariable("clippyCmd", "${config.RustBin}/clippy-driver") |
| 49 | clippyDriver = pctx.AndroidStaticRule("clippy", |
| 50 | blueprint.RuleParams{ |
Ivan Lozano | bae62be | 2020-07-21 13:28:27 -0400 | [diff] [blame] | 51 | Command: "$envVars $clippyCmd " + |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 52 | // Because clippy-driver uses rustc as backend, we need to have some output even during the linting. |
| 53 | // Use the metadata output as it has the smallest footprint. |
| 54 | "--emit metadata -o $out $in ${libFlags} " + |
Thiébaud Weksteen | 8e46efa | 2020-06-30 21:43:35 +0200 | [diff] [blame] | 55 | "$rustcFlags $clippyFlags", |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 56 | CommandDeps: []string{"$clippyCmd"}, |
| 57 | }, |
Ivan Lozano | bae62be | 2020-07-21 13:28:27 -0400 | [diff] [blame] | 58 | "rustcFlags", "libFlags", "clippyFlags", "envVars") |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 59 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 60 | zip = pctx.AndroidStaticRule("zip", |
| 61 | blueprint.RuleParams{ |
| 62 | Command: "cat $out.rsp | tr ' ' '\\n' | tr -d \\' | sort -u > ${out}.tmp && ${SoongZipCmd} -o ${out} -C $$OUT_DIR -l ${out}.tmp", |
| 63 | CommandDeps: []string{"${SoongZipCmd}"}, |
| 64 | Rspfile: "$out.rsp", |
| 65 | RspfileContent: "$in", |
| 66 | }) |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 67 | |
| 68 | cp = pctx.AndroidStaticRule("cp", |
| 69 | blueprint.RuleParams{ |
| 70 | Command: "cp `cat $outDir.rsp` $outDir", |
| 71 | Rspfile: "${outDir}.rsp", |
| 72 | RspfileContent: "$in", |
| 73 | }, |
| 74 | "outDir") |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 75 | ) |
| 76 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 77 | type buildOutput struct { |
Joel Galenson | fa04938 | 2021-01-14 16:03:18 -0800 | [diff] [blame] | 78 | outputFile android.Path |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 79 | } |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 80 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 81 | func init() { |
| 82 | pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 85 | func TransformSrcToBinary(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 86 | outputFile android.WritablePath, linkDirs []string) buildOutput { |
Ivan Lozano | 6cd99e6 | 2020-02-11 08:24:25 -0500 | [diff] [blame] | 87 | flags.GlobalRustFlags = append(flags.GlobalRustFlags, "-C lto") |
Ivan Lozano | 31b095d | 2019-11-20 10:14:33 -0800 | [diff] [blame] | 88 | |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 89 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "bin", 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 TransformSrctoRlib(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, "rlib", 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 TransformSrctoDylib(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 { |
| 99 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "dylib", linkDirs) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 102 | func TransformSrctoStatic(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 103 | outputFile android.WritablePath, linkDirs []string) buildOutput { |
Ivan Lozano | 6cd99e6 | 2020-02-11 08:24:25 -0500 | [diff] [blame] | 104 | flags.GlobalRustFlags = append(flags.GlobalRustFlags, "-C lto") |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 105 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "staticlib", linkDirs) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 108 | func TransformSrctoShared(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 109 | outputFile android.WritablePath, linkDirs []string) buildOutput { |
Ivan Lozano | 6cd99e6 | 2020-02-11 08:24:25 -0500 | [diff] [blame] | 110 | flags.GlobalRustFlags = append(flags.GlobalRustFlags, "-C lto") |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 111 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "cdylib", linkDirs) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 114 | func TransformSrctoProcMacro(ctx ModuleContext, mainSrc android.Path, deps PathDeps, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 115 | flags Flags, outputFile android.WritablePath, linkDirs []string) buildOutput { |
| 116 | return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "proc-macro", linkDirs) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | func rustLibsToPaths(libs RustLibraries) android.Paths { |
| 120 | var paths android.Paths |
| 121 | for _, lib := range libs { |
| 122 | paths = append(paths, lib.Path) |
| 123 | } |
| 124 | return paths |
| 125 | } |
| 126 | |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 127 | func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, flags Flags, |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 128 | outputFile android.WritablePath, crate_type string, linkDirs []string) buildOutput { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 129 | |
| 130 | var inputs android.Paths |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 131 | var implicits android.Paths |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 132 | var envVars []string |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 133 | var output buildOutput |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 134 | var libFlags, rustcFlags, linkFlags []string |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 135 | var implicitOutputs android.WritablePaths |
| 136 | |
| 137 | output.outputFile = outputFile |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 138 | crateName := ctx.RustModule().CrateName() |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 139 | targetTriple := ctx.toolchain().RustTriple() |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 140 | |
Thiébaud Weksteen | 71512f3 | 2020-11-03 15:17:51 +0100 | [diff] [blame] | 141 | // libstd requires a specific environment variable to be set. This is |
| 142 | // not officially documented and may be removed in the future. See |
| 143 | // https://github.com/rust-lang/rust/blob/master/library/std/src/env.rs#L866. |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 144 | if crateName == "std" { |
Thiébaud Weksteen | 71512f3 | 2020-11-03 15:17:51 +0100 | [diff] [blame] | 145 | envVars = append(envVars, "STD_ENV_ARCH="+config.StdEnvArch[ctx.RustModule().Arch().ArchType]) |
| 146 | } |
| 147 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 148 | inputs = append(inputs, main) |
| 149 | |
| 150 | // Collect rustc flags |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 151 | rustcFlags = append(rustcFlags, flags.GlobalRustFlags...) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 152 | rustcFlags = append(rustcFlags, flags.RustFlags...) |
| 153 | rustcFlags = append(rustcFlags, "--crate-type="+crate_type) |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 154 | if crateName != "" { |
| 155 | rustcFlags = append(rustcFlags, "--crate-name="+crateName) |
Ivan Lozano | ad8b18b | 2019-10-31 19:38:29 -0700 | [diff] [blame] | 156 | } |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 157 | if targetTriple != "" { |
| 158 | rustcFlags = append(rustcFlags, "--target="+targetTriple) |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 159 | linkFlags = append(linkFlags, "-target "+targetTriple) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 160 | } |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 161 | |
| 162 | // Suppress an implicit sysroot |
| 163 | rustcFlags = append(rustcFlags, "--sysroot=/dev/null") |
| 164 | |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 165 | // Collect linker flags |
| 166 | linkFlags = append(linkFlags, flags.GlobalLinkFlags...) |
| 167 | linkFlags = append(linkFlags, flags.LinkFlags...) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 168 | |
| 169 | // Collect library/crate flags |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 170 | for _, lib := range deps.RLibs { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 171 | libFlags = append(libFlags, "--extern "+lib.CrateName+"="+lib.Path.String()) |
| 172 | } |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 173 | for _, lib := range deps.DyLibs { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 174 | libFlags = append(libFlags, "--extern "+lib.CrateName+"="+lib.Path.String()) |
| 175 | } |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 176 | for _, proc_macro := range deps.ProcMacros { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 177 | libFlags = append(libFlags, "--extern "+proc_macro.CrateName+"="+proc_macro.Path.String()) |
| 178 | } |
| 179 | |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 180 | for _, path := range linkDirs { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 181 | libFlags = append(libFlags, "-L "+path) |
| 182 | } |
| 183 | |
| 184 | // Collect dependencies |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 185 | implicits = append(implicits, rustLibsToPaths(deps.RLibs)...) |
| 186 | implicits = append(implicits, rustLibsToPaths(deps.DyLibs)...) |
| 187 | implicits = append(implicits, rustLibsToPaths(deps.ProcMacros)...) |
| 188 | implicits = append(implicits, deps.StaticLibs...) |
Ivan Lozano | ec6e991 | 2021-01-21 15:23:29 -0500 | [diff] [blame] | 189 | implicits = append(implicits, deps.SharedLibDeps...) |
Ivan Lozano | 9d74a52 | 2020-12-01 09:25:22 -0500 | [diff] [blame] | 190 | implicits = append(implicits, deps.srcProviderFiles...) |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 191 | |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 192 | if deps.CrtBegin.Valid() { |
| 193 | implicits = append(implicits, deps.CrtBegin.Path(), deps.CrtEnd.Path()) |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 194 | } |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 195 | |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 196 | if len(deps.SrcDeps) > 0 { |
Ivan Lozano | 10735d9 | 2020-07-22 09:14:47 -0400 | [diff] [blame] | 197 | genSubDir := "out/" |
| 198 | moduleGenDir := android.PathForModuleOut(ctx, genSubDir) |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 199 | var outputs android.WritablePaths |
| 200 | |
| 201 | for _, genSrc := range deps.SrcDeps { |
Ivan Lozano | 10735d9 | 2020-07-22 09:14:47 -0400 | [diff] [blame] | 202 | if android.SuffixInList(outputs.Strings(), genSubDir+genSrc.Base()) { |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 203 | ctx.PropertyErrorf("srcs", |
| 204 | "multiple source providers generate the same filename output: "+genSrc.Base()) |
| 205 | } |
Ivan Lozano | 10735d9 | 2020-07-22 09:14:47 -0400 | [diff] [blame] | 206 | outputs = append(outputs, android.PathForModuleOut(ctx, genSubDir+genSrc.Base())) |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | ctx.Build(pctx, android.BuildParams{ |
| 210 | Rule: cp, |
| 211 | Description: "cp " + moduleGenDir.Rel(), |
| 212 | Outputs: outputs, |
| 213 | Inputs: deps.SrcDeps, |
| 214 | Args: map[string]string{ |
| 215 | "outDir": moduleGenDir.String(), |
| 216 | }, |
| 217 | }) |
| 218 | implicits = append(implicits, outputs.Paths()...) |
Ivan Lozano | 1776a2a | 2020-11-11 10:59:52 -0500 | [diff] [blame] | 219 | |
| 220 | // We must calculate an absolute path for OUT_DIR since Rust's include! macro (which normally consumes this) |
| 221 | // assumes that paths are relative to the source file. |
| 222 | var outDirPrefix string |
| 223 | if !filepath.IsAbs(moduleGenDir.String()) { |
| 224 | // If OUT_DIR is not absolute, we use $$PWD to generate an absolute path (os.Getwd() returns '/') |
| 225 | outDirPrefix = "$$PWD/" |
| 226 | } else { |
| 227 | // If OUT_DIR is absolute, then moduleGenDir will be an absolute path, so we don't need to set this to anything. |
| 228 | outDirPrefix = "" |
| 229 | } |
| 230 | envVars = append(envVars, "OUT_DIR="+filepath.Join(outDirPrefix, moduleGenDir.String())) |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 231 | } |
| 232 | |
Thiébaud Weksteen | 9997ea7 | 2021-02-22 10:52:22 +0100 | [diff] [blame^] | 233 | envVars = append(envVars, "ANDROID_RUST_VERSION="+config.RustDefaultVersion) |
| 234 | |
Ivan Lozano | bae62be | 2020-07-21 13:28:27 -0400 | [diff] [blame] | 235 | if flags.Clippy { |
| 236 | clippyFile := android.PathForModuleOut(ctx, outputFile.Base()+".clippy") |
| 237 | ctx.Build(pctx, android.BuildParams{ |
| 238 | Rule: clippyDriver, |
| 239 | Description: "clippy " + main.Rel(), |
| 240 | Output: clippyFile, |
| 241 | ImplicitOutputs: nil, |
| 242 | Inputs: inputs, |
| 243 | Implicits: implicits, |
| 244 | Args: map[string]string{ |
| 245 | "rustcFlags": strings.Join(rustcFlags, " "), |
| 246 | "libFlags": strings.Join(libFlags, " "), |
| 247 | "clippyFlags": strings.Join(flags.ClippyFlags, " "), |
| 248 | "envVars": strings.Join(envVars, " "), |
| 249 | }, |
| 250 | }) |
| 251 | // Declare the clippy build as an implicit dependency of the original crate. |
| 252 | implicits = append(implicits, clippyFile) |
| 253 | } |
| 254 | |
Thiébaud Weksteen | df229cb | 2021-02-10 14:07:57 +0100 | [diff] [blame] | 255 | bloaty.MeasureSizeForPath(ctx, outputFile) |
| 256 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 257 | ctx.Build(pctx, android.BuildParams{ |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 258 | Rule: rustc, |
| 259 | Description: "rustc " + main.Rel(), |
| 260 | Output: outputFile, |
| 261 | ImplicitOutputs: implicitOutputs, |
| 262 | Inputs: inputs, |
| 263 | Implicits: implicits, |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 264 | Args: map[string]string{ |
| 265 | "rustcFlags": strings.Join(rustcFlags, " "), |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 266 | "linkFlags": strings.Join(linkFlags, " "), |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 267 | "libFlags": strings.Join(libFlags, " "), |
Ivan Lozano | b2df9f8 | 2019-11-05 12:16:46 -0800 | [diff] [blame] | 268 | "crtBegin": deps.CrtBegin.String(), |
| 269 | "crtEnd": deps.CrtEnd.String(), |
Ivan Lozano | 4384568 | 2020-07-09 21:03:28 -0400 | [diff] [blame] | 270 | "envVars": strings.Join(envVars, " "), |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 271 | }, |
| 272 | }) |
| 273 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 274 | return output |
| 275 | } |