diff options
author | ThiƩbaud Weksteen <tweek@google.com> | 2021-04-14 11:18:47 +0200 |
---|---|---|
committer | ThiƩbaud Weksteen <tweek@google.com> | 2021-04-15 12:02:51 +0200 |
commit | e4dd14b25fe65b2fc6a5a2fb51d3647f1d455890 (patch) | |
tree | 5a406992407fcba97fe3c22e9186225ce276156d /rust | |
parent | 4fab05a2ade36fe74cf3af2aacbb6f53fe280da8 (diff) |
bloaty: measure stripped Rust binaries
Modify bloaty's MeasureSizeForPath to allow a module to provide multiple
paths. This is used to measure both unstripped and stripped
libraries/binaries. Add unit test to ensure correct measurements are
generated for Rust.
Test: m out/soong/binary_sizes.pb.gz
Change-Id: I59439b77dbf1cf5ad71e1c02996a6a90938536b4
Diffstat (limited to 'rust')
-rw-r--r-- | rust/builder.go | 3 | ||||
-rw-r--r-- | rust/rust.go | 3 | ||||
-rw-r--r-- | rust/rust_test.go | 14 | ||||
-rw-r--r-- | rust/testing.go | 2 |
4 files changed, 18 insertions, 4 deletions
diff --git a/rust/builder.go b/rust/builder.go index 197c7033b..208b73450 100644 --- a/rust/builder.go +++ b/rust/builder.go @@ -21,7 +21,6 @@ import ( "github.com/google/blueprint" "android/soong/android" - "android/soong/bloaty" "android/soong/rust/config" ) @@ -254,8 +253,6 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl implicits = append(implicits, clippyFile) } - bloaty.MeasureSizeForPath(ctx, outputFile) - ctx.Build(pctx, android.BuildParams{ Rule: rustc, Description: "rustc " + main.Rel(), diff --git a/rust/rust.go b/rust/rust.go index ca85d74cc..fb0be2a2a 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -22,6 +22,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/bloaty" "android/soong/cc" cc_config "android/soong/cc/config" "android/soong/rust/config" @@ -731,8 +732,8 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { if mod.compiler != nil && !mod.compiler.Disabled() { mod.compiler.initialize(ctx) unstrippedOutputFile := mod.compiler.compile(ctx, flags, deps) - mod.unstrippedOutputFile = android.OptionalPathForPath(unstrippedOutputFile) + bloaty.MeasureSizeForPaths(ctx, mod.compiler.strippedOutputFilePath(), mod.unstrippedOutputFile) apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo) if mod.installable(apexInfo) { diff --git a/rust/rust_test.go b/rust/rust_test.go index 890fb262b..3354d1de4 100644 --- a/rust/rust_test.go +++ b/rust/rust_test.go @@ -384,3 +384,17 @@ func TestMultilib(t *testing.T) { _ = ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_rlib_dylib-std") _ = ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_rlib_dylib-std") } + +// Test that library size measurements are generated. +func TestLibrarySizes(t *testing.T) { + ctx := testRust(t, ` + rust_library_dylib { + name: "libwaldo", + srcs: ["foo.rs"], + crate_name: "waldo", + }`) + + m := ctx.SingletonForTests("file_metrics") + m.Output("libwaldo.dylib.so.bloaty.csv") + m.Output("stripped/libwaldo.dylib.so.bloaty.csv") +} diff --git a/rust/testing.go b/rust/testing.go index 1e01cc0c5..10b768ca9 100644 --- a/rust/testing.go +++ b/rust/testing.go @@ -16,6 +16,7 @@ package rust import ( "android/soong/android" + "android/soong/bloaty" "android/soong/cc" ) @@ -34,6 +35,7 @@ const rustDefaultsDir = "defaults/rust/" // Preparer that will define default rust modules, e.g. standard prebuilt modules. var PrepareForTestWithRustDefaultModules = android.GroupFixturePreparers( cc.PrepareForTestWithCcDefaultModules, + bloaty.PrepareForTestWithBloatyDefaultModules, PrepareForTestWithRustBuildComponents, android.FixtureAddTextFile(rustDefaultsDir+"Android.bp", GatherRequiredDepsForTest()), ) |