size_report: create a main() function
Refactor code and add main() function. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
de311407bd
commit
de713534b6
1 changed files with 48 additions and 41 deletions
|
@ -16,27 +16,6 @@ import operator
|
|||
import platform
|
||||
from pathlib import Path
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-d", "--depth", dest="depth", type="int",
|
||||
help="How deep should we go into the tree", metavar="DEPTH")
|
||||
parser.add_option("-o", "--outdir", dest="outdir",
|
||||
help="read files from directory OUT", metavar="OUT")
|
||||
parser.add_option("-k", "--kernel-name", dest="binary", default="zephyr",
|
||||
help="kernel binary name")
|
||||
parser.add_option("-r", "--ram",
|
||||
action="store_true", dest="ram", default=False,
|
||||
help="print RAM statistics")
|
||||
parser.add_option("-F", "--rom",
|
||||
action="store_true", dest="rom", default=False,
|
||||
help="print ROM statistics")
|
||||
parser.add_option("-s", "--objdump", type="string", dest="bin_objdump",
|
||||
help="Path to the GNU binary utility objdump")
|
||||
parser.add_option("-c", "--objcopy", type="string", dest="bin_objcopy",
|
||||
help="Path to the GNU binary utility objcopy")
|
||||
parser.add_option("-n", "--nm", type="string", dest="bin_nm",
|
||||
help="Path to the GNU binary utility nm")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# Return a dict containing {
|
||||
# symbol_name: {:,path/to/file}/symbol
|
||||
|
@ -408,6 +387,30 @@ def print_tree(data, total, depth):
|
|||
print('{:92d}'.format(total))
|
||||
return totp
|
||||
|
||||
|
||||
def main():
|
||||
parser = OptionParser()
|
||||
parser.add_option("-d", "--depth", dest="depth", type="int",
|
||||
help="How deep should we go into the tree", metavar="DEPTH")
|
||||
parser.add_option("-o", "--outdir", dest="outdir",
|
||||
help="read files from directory OUT", metavar="OUT")
|
||||
parser.add_option("-k", "--kernel-name", dest="binary", default="zephyr",
|
||||
help="kernel binary name")
|
||||
parser.add_option("-r", "--ram",
|
||||
action="store_true", dest="ram", default=False,
|
||||
help="print RAM statistics")
|
||||
parser.add_option("-F", "--rom",
|
||||
action="store_true", dest="rom", default=False,
|
||||
help="print ROM statistics")
|
||||
parser.add_option("-s", "--objdump", type="string", dest="bin_objdump",
|
||||
help="Path to the GNU binary utility objdump")
|
||||
parser.add_option("-c", "--objcopy", type="string", dest="bin_objcopy",
|
||||
help="Path to the GNU binary utility objcopy")
|
||||
parser.add_option("-n", "--nm", type="string", dest="bin_nm",
|
||||
help="Path to the GNU binary utility nm")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
bin_file = os.path.join(options.outdir, options.binary + ".bin")
|
||||
stat_file = os.path.join(options.outdir, options.binary + ".stat")
|
||||
elf_file = os.path.join(options.outdir, options.binary + ".elf")
|
||||
|
@ -431,3 +434,7 @@ if options.outdir and os.path.exists(elf_file):
|
|||
|
||||
else:
|
||||
print("%s does not exist." % (elf_file))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue