Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 1 | // Copyright 2017 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 | |
| 15 | package build |
| 16 | |
| 17 | import ( |
Colin Cross | b72c909 | 2020-02-10 11:23:49 -0800 | [diff] [blame] | 18 | "io/ioutil" |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 19 | "os" |
Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 20 | "path/filepath" |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 21 | "strconv" |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 22 | |
Lukacs T. Berki | 3243aa5 | 2021-02-25 14:44:14 +0100 | [diff] [blame] | 23 | "android/soong/shared" |
Lukacs T. Berki | 7690c09 | 2021-02-26 14:27:36 +0100 | [diff] [blame] | 24 | |
Colin Cross | b72c909 | 2020-02-10 11:23:49 -0800 | [diff] [blame] | 25 | soong_metrics_proto "android/soong/ui/metrics/metrics_proto" |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 26 | "github.com/google/blueprint" |
| 27 | "github.com/google/blueprint/bootstrap" |
Colin Cross | b72c909 | 2020-02-10 11:23:49 -0800 | [diff] [blame] | 28 | |
| 29 | "github.com/golang/protobuf/proto" |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 30 | "github.com/google/blueprint/microfactory" |
Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 31 | |
Nan Zhang | 17f2767 | 2018-12-12 16:01:49 -0800 | [diff] [blame] | 32 | "android/soong/ui/metrics" |
Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 33 | "android/soong/ui/status" |
Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 34 | ) |
| 35 | |
Lukacs T. Berki | 7690c09 | 2021-02-26 14:27:36 +0100 | [diff] [blame] | 36 | func writeEnvironmentFile(ctx Context, envFile string, envDeps map[string]string) error { |
| 37 | data, err := shared.EnvFileContents(envDeps) |
| 38 | if err != nil { |
| 39 | return err |
| 40 | } |
| 41 | |
| 42 | return ioutil.WriteFile(envFile, data, 0644) |
| 43 | } |
| 44 | |
Rupert Shuttleworth | b7d9710 | 2020-11-25 10:19:29 +0000 | [diff] [blame] | 45 | // This uses Android.bp files and various tools to generate <builddir>/build.ninja. |
| 46 | // |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 47 | // However, the execution of <builddir>/build.ninja happens later in |
| 48 | // build/soong/ui/build/build.go#Build() |
Rupert Shuttleworth | b7d9710 | 2020-11-25 10:19:29 +0000 | [diff] [blame] | 49 | // |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 50 | // We want to rely on as few prebuilts as possible, so we need to bootstrap |
| 51 | // Soong. The process is as follows: |
Rupert Shuttleworth | b7d9710 | 2020-11-25 10:19:29 +0000 | [diff] [blame] | 52 | // |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 53 | // 1. We use "Microfactory", a simple tool to compile Go code, to build |
| 54 | // first itself, then soong_ui from soong_ui.bash. This binary contains |
| 55 | // parts of soong_build that are needed to build itself. |
| 56 | // 2. This simplified version of soong_build then reads the Blueprint files |
| 57 | // that describe itself and emits .bootstrap/build.ninja that describes |
| 58 | // how to build its full version and use that to produce the final Ninja |
| 59 | // file Soong emits. |
| 60 | // 3. soong_ui executes .bootstrap/build.ninja |
Rupert Shuttleworth | b7d9710 | 2020-11-25 10:19:29 +0000 | [diff] [blame] | 61 | // |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 62 | // (After this, Kati is executed to parse the Makefiles, but that's not part of |
| 63 | // bootstrapping Soong) |
| 64 | |
| 65 | // A tiny struct used to tell Blueprint that it's in bootstrap mode. It would |
| 66 | // probably be nicer to use a flag in bootstrap.Args instead. |
| 67 | type BlueprintConfig struct { |
Lukacs T. Berki | 5f6cb1d | 2021-03-17 15:03:14 +0100 | [diff] [blame^] | 68 | srcDir string |
| 69 | buildDir string |
| 70 | ninjaBuildDir string |
| 71 | debugCompilation bool |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 72 | } |
| 73 | |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 74 | func (c BlueprintConfig) SrcDir() string { |
| 75 | return "." |
| 76 | } |
| 77 | |
| 78 | func (c BlueprintConfig) BuildDir() string { |
| 79 | return c.buildDir |
| 80 | } |
| 81 | |
| 82 | func (c BlueprintConfig) NinjaBuildDir() string { |
| 83 | return c.ninjaBuildDir |
| 84 | } |
| 85 | |
Lukacs T. Berki | 5f6cb1d | 2021-03-17 15:03:14 +0100 | [diff] [blame^] | 86 | func (c BlueprintConfig) DebugCompilation() bool { |
| 87 | return c.debugCompilation |
| 88 | } |
| 89 | |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 90 | func bootstrapBlueprint(ctx Context, config Config) { |
| 91 | ctx.BeginTrace(metrics.RunSoong, "blueprint bootstrap") |
| 92 | defer ctx.EndTrace() |
| 93 | |
| 94 | var args bootstrap.Args |
| 95 | |
| 96 | args.RunGoTests = !config.skipSoongTests |
| 97 | args.UseValidations = true // Use validations to depend on tests |
| 98 | args.BuildDir = config.SoongOutDir() |
| 99 | args.NinjaBuildDir = config.OutDir() |
| 100 | args.TopFile = "Android.bp" |
| 101 | args.ModuleListFile = filepath.Join(config.FileListDir(), "Android.bp.list") |
| 102 | args.OutFile = shared.JoinPath(config.SoongOutDir(), ".bootstrap/build.ninja") |
| 103 | args.DepFile = shared.JoinPath(config.SoongOutDir(), ".bootstrap/build.ninja.d") |
| 104 | args.GlobFile = shared.JoinPath(config.SoongOutDir(), ".bootstrap/soong-build-globs.ninja") |
Lukacs T. Berki | d7ce840 | 2021-03-17 14:03:51 +0100 | [diff] [blame] | 105 | args.GeneratingPrimaryBuilder = true |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 106 | |
| 107 | blueprintCtx := blueprint.NewContext() |
| 108 | blueprintCtx.SetIgnoreUnknownModuleTypes(true) |
| 109 | blueprintConfig := BlueprintConfig{ |
Lukacs T. Berki | 5f6cb1d | 2021-03-17 15:03:14 +0100 | [diff] [blame^] | 110 | srcDir: os.Getenv("TOP"), |
| 111 | buildDir: config.SoongOutDir(), |
| 112 | ninjaBuildDir: config.OutDir(), |
| 113 | debugCompilation: os.Getenv("SOONG_DELVE") != "", |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | bootstrap.RunBlueprint(args, blueprintCtx, blueprintConfig) |
| 117 | } |
| 118 | |
Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 119 | func runSoong(ctx Context, config Config) { |
Nan Zhang | 17f2767 | 2018-12-12 16:01:49 -0800 | [diff] [blame] | 120 | ctx.BeginTrace(metrics.RunSoong, "soong") |
Dan Willemsen | d9f6fa2 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 121 | defer ctx.EndTrace() |
| 122 | |
Lukacs T. Berki | 7690c09 | 2021-02-26 14:27:36 +0100 | [diff] [blame] | 123 | // We have two environment files: .available is the one with every variable, |
| 124 | // .used with the ones that were actually used. The latter is used to |
| 125 | // determine whether Soong needs to be re-run since why re-run it if only |
| 126 | // unused variables were changed? |
| 127 | envFile := filepath.Join(config.SoongOutDir(), "soong.environment.available") |
| 128 | |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 129 | for _, n := range []string{".bootstrap", ".minibootstrap"} { |
| 130 | dir := filepath.Join(config.SoongOutDir(), n) |
| 131 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 132 | ctx.Fatalf("Cannot mkdir " + dir) |
Colin Cross | 00a8a3f | 2020-10-29 14:08:31 -0700 | [diff] [blame] | 133 | } |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 134 | } |
Colin Cross | 00a8a3f | 2020-10-29 14:08:31 -0700 | [diff] [blame] | 135 | |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 136 | // This is done unconditionally, but does not take a measurable amount of time |
| 137 | bootstrapBlueprint(ctx, config) |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 138 | |
Lukacs T. Berki | 7690c09 | 2021-02-26 14:27:36 +0100 | [diff] [blame] | 139 | soongBuildEnv := config.Environment().Copy() |
| 140 | soongBuildEnv.Set("TOP", os.Getenv("TOP")) |
| 141 | // These two dependencies are read from bootstrap.go, but also need to be here |
| 142 | // so that soong_build can declare a dependency on them |
| 143 | soongBuildEnv.Set("SOONG_DELVE", os.Getenv("SOONG_DELVE")) |
| 144 | soongBuildEnv.Set("SOONG_DELVE_PATH", os.Getenv("SOONG_DELVE_PATH")) |
| 145 | soongBuildEnv.Set("SOONG_OUTDIR", config.SoongOutDir()) |
| 146 | // For Bazel mixed builds. |
| 147 | soongBuildEnv.Set("BAZEL_PATH", "./tools/bazel") |
| 148 | soongBuildEnv.Set("BAZEL_HOME", filepath.Join(config.BazelOutDir(), "bazelhome")) |
| 149 | soongBuildEnv.Set("BAZEL_OUTPUT_BASE", filepath.Join(config.BazelOutDir(), "output")) |
| 150 | soongBuildEnv.Set("BAZEL_WORKSPACE", absPath(ctx, ".")) |
| 151 | soongBuildEnv.Set("BAZEL_METRICS_DIR", config.BazelMetricsDir()) |
| 152 | |
Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 153 | // For Soong bootstrapping tests |
| 154 | if os.Getenv("ALLOW_MISSING_DEPENDENCIES") == "true" { |
| 155 | soongBuildEnv.Set("ALLOW_MISSING_DEPENDENCIES", "true") |
| 156 | } |
| 157 | |
Paul Duffin | 5e85c66 | 2021-03-05 12:26:14 +0000 | [diff] [blame] | 158 | err := writeEnvironmentFile(ctx, envFile, soongBuildEnv.AsMap()) |
| 159 | if err != nil { |
| 160 | ctx.Fatalf("failed to write environment file %s: %s", envFile, err) |
| 161 | } |
Lukacs T. Berki | 7690c09 | 2021-02-26 14:27:36 +0100 | [diff] [blame] | 162 | |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 163 | func() { |
Nan Zhang | 17f2767 | 2018-12-12 16:01:49 -0800 | [diff] [blame] | 164 | ctx.BeginTrace(metrics.RunSoong, "environment check") |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 165 | defer ctx.EndTrace() |
| 166 | |
Lukacs T. Berki | 7690c09 | 2021-02-26 14:27:36 +0100 | [diff] [blame] | 167 | envFile := filepath.Join(config.SoongOutDir(), "soong.environment.used") |
Lukacs T. Berki | 3243aa5 | 2021-02-25 14:44:14 +0100 | [diff] [blame] | 168 | getenv := func(k string) string { |
Lukacs T. Berki | b4ced9d | 2021-03-10 15:43:06 +0100 | [diff] [blame] | 169 | v, _ := soongBuildEnv.Get(k) |
Lukacs T. Berki | 3243aa5 | 2021-02-25 14:44:14 +0100 | [diff] [blame] | 170 | return v |
| 171 | } |
| 172 | if stale, _ := shared.StaleEnvFile(envFile, getenv); stale { |
| 173 | os.Remove(envFile) |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 174 | } |
| 175 | }() |
| 176 | |
Dan Willemsen | 5af1cbe | 2018-07-05 21:46:51 -0700 | [diff] [blame] | 177 | var cfg microfactory.Config |
| 178 | cfg.Map("github.com/google/blueprint", "build/blueprint") |
| 179 | |
| 180 | cfg.TrimPath = absPath(ctx, ".") |
| 181 | |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 182 | func() { |
Nan Zhang | 17f2767 | 2018-12-12 16:01:49 -0800 | [diff] [blame] | 183 | ctx.BeginTrace(metrics.RunSoong, "bpglob") |
Dan Willemsen | 5af1cbe | 2018-07-05 21:46:51 -0700 | [diff] [blame] | 184 | defer ctx.EndTrace() |
| 185 | |
| 186 | bpglob := filepath.Join(config.SoongOutDir(), ".minibootstrap/bpglob") |
| 187 | if _, err := microfactory.Build(&cfg, bpglob, "github.com/google/blueprint/bootstrap/bpglob"); err != nil { |
| 188 | ctx.Fatalln("Failed to build bpglob:", err) |
| 189 | } |
| 190 | }() |
| 191 | |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 192 | ninja := func(name, file string) { |
Nan Zhang | 17f2767 | 2018-12-12 16:01:49 -0800 | [diff] [blame] | 193 | ctx.BeginTrace(metrics.RunSoong, name) |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 194 | defer ctx.EndTrace() |
| 195 | |
Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 196 | fifo := filepath.Join(config.OutDir(), ".ninja_fifo") |
Colin Cross | b98d3bc | 2019-03-21 16:02:58 -0700 | [diff] [blame] | 197 | nr := status.NewNinjaReader(ctx, ctx.Status.StartTool(), fifo) |
| 198 | defer nr.Close() |
Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 199 | |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 200 | cmd := Command(ctx, config, "soong "+name, |
| 201 | config.PrebuiltBuildTool("ninja"), |
| 202 | "-d", "keepdepfile", |
Dan Willemsen | 0821822 | 2020-05-18 14:02:02 -0700 | [diff] [blame] | 203 | "-d", "stats", |
Dan Willemsen | 6587bed | 2020-04-18 20:25:59 -0700 | [diff] [blame] | 204 | "-o", "usesphonyoutputs=yes", |
| 205 | "-o", "preremoveoutputs=yes", |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 206 | "-w", "dupbuild=err", |
Dan Willemsen | 6587bed | 2020-04-18 20:25:59 -0700 | [diff] [blame] | 207 | "-w", "outputdir=err", |
| 208 | "-w", "missingoutfile=err", |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 209 | "-j", strconv.Itoa(config.Parallel()), |
Dan Willemsen | 0273667 | 2018-07-17 17:54:31 -0700 | [diff] [blame] | 210 | "--frontend_file", fifo, |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 211 | "-f", filepath.Join(config.SoongOutDir(), file)) |
Jingwen Chen | 7c6089a | 2020-11-02 02:56:20 -0500 | [diff] [blame] | 212 | |
Lukacs T. Berki | b14ad7b | 2021-03-09 10:43:57 +0100 | [diff] [blame] | 213 | var ninjaEnv Environment |
Lukacs T. Berki | 73ab928 | 2021-03-10 10:48:39 +0100 | [diff] [blame] | 214 | |
| 215 | // This is currently how the command line to invoke soong_build finds the |
| 216 | // root of the source tree and the output root |
Lukacs T. Berki | b14ad7b | 2021-03-09 10:43:57 +0100 | [diff] [blame] | 217 | ninjaEnv.Set("TOP", os.Getenv("TOP")) |
| 218 | ninjaEnv.Set("SOONG_OUTDIR", config.SoongOutDir()) |
Lukacs T. Berki | 73ab928 | 2021-03-10 10:48:39 +0100 | [diff] [blame] | 219 | |
Lukacs T. Berki | 73ab928 | 2021-03-10 10:48:39 +0100 | [diff] [blame] | 220 | // For debugging |
Lukacs T. Berki | 7d613bf | 2021-03-02 10:09:41 +0100 | [diff] [blame] | 221 | if os.Getenv("SOONG_DELVE") != "" { |
Lukacs T. Berki | b4ced9d | 2021-03-10 15:43:06 +0100 | [diff] [blame] | 222 | ninjaEnv.Set("SOONG_DELVE", os.Getenv("SOONG_DELVE")) |
Lukacs T. Berki | b14ad7b | 2021-03-09 10:43:57 +0100 | [diff] [blame] | 223 | ninjaEnv.Set("SOONG_DELVE_PATH", shared.ResolveDelveBinary()) |
Lukacs T. Berki | 7d613bf | 2021-03-02 10:09:41 +0100 | [diff] [blame] | 224 | } |
| 225 | |
Lukacs T. Berki | b14ad7b | 2021-03-09 10:43:57 +0100 | [diff] [blame] | 226 | cmd.Environment = &ninjaEnv |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 227 | cmd.Sandbox = soongSandbox |
Colin Cross | 7b97ecd | 2019-06-19 13:17:59 -0700 | [diff] [blame] | 228 | cmd.RunAndStreamOrFatal() |
Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 229 | } |
Rupert Shuttleworth | b7d9710 | 2020-11-25 10:19:29 +0000 | [diff] [blame] | 230 | // This build generates <builddir>/build.ninja, which is used later by build/soong/ui/build/build.go#Build(). |
Dan Willemsen | 99a75cd | 2017-08-04 16:04:04 -0700 | [diff] [blame] | 231 | ninja("bootstrap", ".bootstrap/build.ninja") |
Colin Cross | b72c909 | 2020-02-10 11:23:49 -0800 | [diff] [blame] | 232 | |
Jingwen Chen | eb76c43 | 2021-01-28 08:22:12 -0500 | [diff] [blame] | 233 | var soongBuildMetrics *soong_metrics_proto.SoongBuildMetrics |
| 234 | if shouldCollectBuildSoongMetrics(config) { |
| 235 | soongBuildMetrics := loadSoongBuildMetrics(ctx, config) |
| 236 | logSoongBuildMetrics(ctx, soongBuildMetrics) |
| 237 | } |
Colin Cross | b72c909 | 2020-02-10 11:23:49 -0800 | [diff] [blame] | 238 | |
Colin Cross | 8ba7d47 | 2020-06-25 11:27:52 -0700 | [diff] [blame] | 239 | distGzipFile(ctx, config, config.SoongNinjaFile(), "soong") |
| 240 | |
Anton Hansson | 5e5c48b | 2020-11-27 12:35:20 +0000 | [diff] [blame] | 241 | if !config.SkipKati() { |
Colin Cross | 8ba7d47 | 2020-06-25 11:27:52 -0700 | [diff] [blame] | 242 | distGzipFile(ctx, config, config.SoongAndroidMk(), "soong") |
| 243 | distGzipFile(ctx, config, config.SoongMakeVarsMk(), "soong") |
| 244 | } |
| 245 | |
Jingwen Chen | eb76c43 | 2021-01-28 08:22:12 -0500 | [diff] [blame] | 246 | if shouldCollectBuildSoongMetrics(config) && ctx.Metrics != nil { |
Colin Cross | b72c909 | 2020-02-10 11:23:49 -0800 | [diff] [blame] | 247 | ctx.Metrics.SetSoongBuildMetrics(soongBuildMetrics) |
| 248 | } |
| 249 | } |
| 250 | |
Jingwen Chen | eb76c43 | 2021-01-28 08:22:12 -0500 | [diff] [blame] | 251 | func shouldCollectBuildSoongMetrics(config Config) bool { |
| 252 | // Do not collect metrics protobuf if the soong_build binary ran as the bp2build converter. |
| 253 | return config.Environment().IsFalse("GENERATE_BAZEL_FILES") |
| 254 | } |
| 255 | |
Colin Cross | b72c909 | 2020-02-10 11:23:49 -0800 | [diff] [blame] | 256 | func loadSoongBuildMetrics(ctx Context, config Config) *soong_metrics_proto.SoongBuildMetrics { |
| 257 | soongBuildMetricsFile := filepath.Join(config.OutDir(), "soong", "soong_build_metrics.pb") |
| 258 | buf, err := ioutil.ReadFile(soongBuildMetricsFile) |
| 259 | if err != nil { |
| 260 | ctx.Fatalf("Failed to load %s: %s", soongBuildMetricsFile, err) |
| 261 | } |
| 262 | soongBuildMetrics := &soong_metrics_proto.SoongBuildMetrics{} |
| 263 | err = proto.Unmarshal(buf, soongBuildMetrics) |
| 264 | if err != nil { |
| 265 | ctx.Fatalf("Failed to unmarshal %s: %s", soongBuildMetricsFile, err) |
| 266 | } |
| 267 | return soongBuildMetrics |
| 268 | } |
| 269 | |
| 270 | func logSoongBuildMetrics(ctx Context, metrics *soong_metrics_proto.SoongBuildMetrics) { |
| 271 | ctx.Verbosef("soong_build metrics:") |
| 272 | ctx.Verbosef(" modules: %v", metrics.GetModules()) |
| 273 | ctx.Verbosef(" variants: %v", metrics.GetVariants()) |
| 274 | ctx.Verbosef(" max heap size: %v MB", metrics.GetMaxHeapSize()/1e6) |
| 275 | ctx.Verbosef(" total allocation count: %v", metrics.GetTotalAllocCount()) |
| 276 | ctx.Verbosef(" total allocation size: %v MB", metrics.GetTotalAllocSize()/1e6) |
| 277 | |
Dan Willemsen | 1e70446 | 2016-08-21 15:17:17 -0700 | [diff] [blame] | 278 | } |