diff options
author | Ewout van Bekkum <ewout@google.com> | 2022-02-23 09:53:33 -0800 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-03-04 03:01:52 +0000 |
commit | 2cf83d9b1b7280eaa6669998c73fa3643fef75c7 (patch) | |
tree | 60ee56240ff76d33b2b0dca81d2defac3739d584 /pw_bloat | |
parent | fc94fc7532c6009980a17c324bd7a8ae9bddd707 (diff) | |
download | pigweed-2cf83d9b1b7280eaa6669998c73fa3643fef75c7.tar.gz |
pw_bloat: Adds the pw_bloaty_config CMake function
Adds a new pw_bloaty_config CMake function to generate Bloaty
configuration files using pw_bloat.bloaty_config as part of CMake
builds.
Change-Id: I7383b444d84db6b00d231c6e3b147757d8f41efb
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/85342
Reviewed-by: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Diffstat (limited to 'pw_bloat')
-rw-r--r-- | pw_bloat/bloat.cmake | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/pw_bloat/bloat.cmake b/pw_bloat/bloat.cmake new file mode 100644 index 000000000..6a4e9c703 --- /dev/null +++ b/pw_bloat/bloat.cmake @@ -0,0 +1,64 @@ +# Copyright 2021 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +include_guard(GLOBAL) + +include($ENV{PW_ROOT}/pw_build/pigweed.cmake) + +# This function creates a library under the specified ${NAME} which provides a +# a generated bloaty configuration for a given ELF file using +# pw_bloat.bloaty_config. +# +# Produces the ${OUTPUT} Bloaty McBloatface configuration file. +# +# Args: +# +# NAME - name of the library to create +# ELF_FILE - The input ELF file to process using pw_bloat.bloaty_config +# OUTPUT - The output Bloaty McBloatface configuration file +function(pw_bloaty_config NAME) + set(option_args) + set(one_value_args ELF_FILE OUTPUT) + set(multi_value_args) + _pw_parse_argv_strict(pw_bloaty_config + 1 "${option_args}" "${one_value_args}" "${multi_value_args}" + ) + + if("${arg_ELF_FILE}" STREQUAL "") + message(FATAL_ERROR + "pw_bloaty_config requires an input ELF file in ELF_FILE. " + "No ELF_FILE was listed for ${NAME}") + endif() + + if("${arg_OUTPUT}" STREQUAL "") + message(FATAL_ERROR + "pw_bloaty_config requires an output config file in OUTPUT. " + "No OUTPUT was listed for ${NAME}") + endif() + + add_library(${NAME} INTERFACE) + add_dependencies(${NAME} INTERFACE ${NAME}_generated_config) + + add_custom_command( + COMMENT "Generating ${NAME}'s ${arg_OUTPUT} for ${arg_ELF_FILE}." + COMMAND + ${Python3_EXECUTABLE} + "$ENV{PW_ROOT}/pw_bloat/py/pw_bloat/bloaty_config.py" + ${arg_ELF_FILE} -o ${arg_OUTPUT} -l warning + DEPENDS ${arg_ELF_FILE} + OUTPUT ${arg_OUTPUT} POST_BUILD + ) + add_custom_target(${NAME}_generated_config + DEPENDS ${arg_OUTPUT} + ) +endfunction() |