| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| declare_args() { |
| # The input to the size checker. |
| # The build system will produce a JSON file to be consumed by the size checker, which |
| # will check and prevent integration of subsystems that are over their space allocation. |
| # The input consists of the following keys: |
| # |
| # asset_ext(string array): a list of extensions that should be considered as assets. |
| # |
| # asset_limit(number): maximum size (in bytes) allocated for the assets. |
| # |
| # core_limit(number): maximum size (in bytes) allocated for the core system and/or services. |
| # This is sort of a "catch all" component that consists of all the area / packages that weren't |
| # specified in the components list below. |
| # |
| # components(object array): a list of component objects. Each object should contain the following keys: |
| # |
| # component(string): name of the component. |
| # |
| # src(string array): path of the area / package to be included as part of the component. |
| # The path should be relative to the obj/ in the output directory. |
| # For example, consider two packages foo and far, built to out/.../obj/some_big_component/foo and out/.../obj/some_big_component/bar. |
| # If you want to impose a limit on foo, your src will be ["some_big_component/foo"]. |
| # If you want to impose a limit on both foo and far, your src will be ["some_big_component"]. |
| # If a package has config-data, those prebuilt blobs actually live under the config-data package. |
| # If you wish to impose a limit of those data as well, you should add "build/images/config-data/$for_pkg" to your src. |
| # The $for_pkg corresponds to the $for_pkg field in config.gni. |
| # |
| # limit(number): maximum size (in bytes) allocated for the component. |
| # |
| # Example: |
| # size_checker_input = { |
| # asset_ext = [ ".ttf" ] |
| # asset_limit = 10240 |
| # core_limit = 10240 |
| # components = [ |
| # { |
| # component = "Foo" |
| # src = [ "topaz/runtime/foo_runner" ] |
| # limit = 10240 |
| # }, |
| # { |
| # component = "Bar" |
| # src = [ "build/images" ] |
| # limit = 20480 |
| # }, |
| # ] |
| # } |
| size_checker_input = { |
| } |
| } |
| |
| import("//build/go/go_binary.gni") |
| import("//build/go/go_library.gni") |
| import("//build/go/go_test.gni") |
| import("//build/host.gni") |
| |
| group("cmd") { |
| testonly = true |
| public_deps = [ |
| ":host", |
| ":tests", |
| ] |
| } |
| |
| generated_file("size_checker_json") { |
| outputs = [ "$root_build_dir/size_checker.json" ] |
| contents = size_checker_input |
| output_conversion = "json" |
| } |
| |
| go_library("size_checker_lib") { |
| sources = [ |
| "size_checker.go", |
| "size_checker_test.go", |
| ] |
| } |
| |
| go_binary("size_checker") { |
| gopackage = "go.fuchsia.dev/fuchsia/tools/size_checker/cmd" |
| |
| deps = [ ":size_checker_lib" ] |
| |
| non_go_deps = [ ":size_checker_json" ] |
| } |
| |
| if (host_toolchain == current_toolchain) { |
| go_test("size_checker_tests") { |
| gopackages = [ "go.fuchsia.dev/fuchsia/tools/size_checker/cmd" ] |
| deps = [ ":size_checker_lib" ] |
| } |
| } |
| |
| install_host_tools("host") { |
| deps = [ ":size_checker" ] |
| outputs = [ "size_checker" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":size_checker_tests($host_toolchain)", |
| |
| # To be able to run `fx test`. |
| "//tools/symbolizer($host_toolchain)", |
| ] |
| } |