Commit Graph

68 Commits

Author SHA1 Message Date
Armando Montanez
759ff77d81 Add WriteLine() to pw_dumb_io
Adds WriteLine() to pw_dumb_io, and updates all function names to use
read/write.

Change-Id: I0c3358fa264f9a5e7c8b49736e960015df0e67fc
2019-11-20 18:30:11 +00:00
Keir Mierle
88726e83f6 pw_cmd: Support multiple build directories
This change extends 'pw watch' to support watching multiple build
directories. It also switches the command handling to use argparse's
native subcommand handling.

Example use:

  pw watch --build_dir out-clang --build_dir out-arm-cortex-m4-gcc

Example output:

PW - 2019-11-19 19:27:03 - INFO - [2/2] Finished build: out-arm-cortex-m4-gcc
PW - 2019-11-19 19:27:03 - INFO - Finished; all successful.

 .------------------------------------
 |
 |   OK     build: out-clang
 |   OK     build: out-arm-cortex-m4-gcc
 |
 '------------------------------------

  ██████╗  █████╗ ███████╗███████╗██╗
  ██╔══██╗██╔══██╗██╔════╝██╔════╝██║
  ██████╔╝███████║███████╗███████╗██║
  ██╔═══╝ ██╔══██║╚════██║╚════██║╚═╝
  ██║     ██║  ██║███████║███████║██╗
  ╚═╝     ╚═╝  ╚═╝╚══════╝╚══════╝╚═╝

Change-Id: Iecefffa8a2dfb2e69fb64bfd616d71b71c93f3ee
2019-11-20 18:29:36 +00:00
Wyatt Hepler
83d42485f0 pw_span: Update deduction guides
- Use the deduction guides specified in the C++20 draft standard.
- Expand tests to cover all deduction guides.

Change-Id: I9ab0c44b7bb1097c554c7e56f0b174b2615cacd3
2019-11-19 18:57:26 -08:00
Keir Mierle
1ce7f00d04 pw_cmd: Update code from incorrect rebase
Change-Id: Ie9f002728a87b2e11e59859e71477e2dc3d1f209
2019-11-19 17:44:18 -08:00
Wyatt Hepler
8a823ceebb Size report for pw::string::Format
Add size report comparing pw::string::Format to std::snprintf.

Report with arm-none-eabi-gcc at -Os:

            Using pw::string::Format instead of snprintf
            ────────────────────────────────────────────
┌────────────────────────────┬───────────┬────────┬───────┬────────┐
│            Label           │  Segment  │ Before │ Delta │  After │
├════════════════════════════┼═══════════┼════════┼═══════┼════════┤
│    One string, return size │ SEG FLASH │  2,840 │   +80 │  2,920 │
├────────────────────────────┼───────────┼────────┼───────┼────────┤
│ Ten strings, handle errors │     (all) │ (same) │     0 │ (same) │
├────────────────────────────┼───────────┼────────┼───────┼────────┤
│   Fifty calls, same buffer │ SEG FLASH │  3,816 │   -72 │  3,744 │
└────────────────────────────┴───────────┴────────┴───────┴────────┘

Change-Id: Id484530320b0334cddf676a49ad79444fbbbde9b
2019-11-19 12:58:31 -08:00
Wyatt Hepler
0e892b5b27 pw_bloat: Handle identical binaries
Prints "(all)" as the segment and "(same)" for before/after when bloat
binaries have identical segments. Previously, nothing was printed.

Example output:
┌────────────┬───────────┬────────┬───────┬────────┐
│    Label   │  Segment  │ Before │ Delta │  After │
├════════════┼═══════════┼════════┼═══════┼════════┤
│ Identical! │     (all) │ (same) │     0 │ (same) │
└────────────┴───────────┴────────┴───────┴────────┘

Change-Id: Ib02f0db55a6c8fbba053444b3a33408805e8e0aa
2019-11-19 12:58:31 -08:00
Wyatt Hepler
32d86bb686 python_runner.py and pw_bloat updates
- Support specifying per-binary bases instead of a global base in size
  reports.
- Resolve paths in semicolon-separated paths in python_runner.py.
- Remove --base-target option from bloat.py. Instead, the base must be
  specified for each target.
- Add '\n' to the end of size report text files.
- Apply yapf to python_runner.py and bloat.py.

Change-Id: I3f0e6f16b028e97ed6db4b3d975a9aada98c076a
2019-11-19 12:58:14 -08:00
Alexei Frolov
a454c68bd8 Define pw_test_group template
This change adds a GN template to the pw_unit_test module which defines
a group of unit tests. The template creates a generated_file target with
JSON metadata for the unit tests and dependencies within the test group.
These metadata files are intended to be parsed by the test runner script
to run unit tests outside of GN.

A pw_test_group target is added to each of the existing modules which
have unit tests.

Change-Id: I363b937da365d0a3482a979feace18ecba1807a9
2019-11-19 20:52:52 +00:00
Keir Mierle
cf87283072 pw_cmd: Start basic module with compile watcher
This starts the pw_cmd module, which will eventually have a command line
tool to make working with Pigweed easier. The initial command has only 1
abilitiy: to watch the Pigweed source directory for changes and trigger
a recompile & test re-run if something changed. This makes for a fast
iteration time that avoids having to explicitly compile.

In the future this will expand to have multiple other sub-commands.

Change-Id: Ic82ab376716900914660fd8ae2787384a69110bd
2019-11-19 11:45:12 -08:00
Keir Mierle
2c1e56bbf0 docs: Initial checkin of style & embedded guides
These will need a bunch of work still but are a reasonable starting
place.

Change-Id: I91a64a6910a4acb8d657c43cd67af9e60f39616a
2019-11-19 19:44:25 +00:00
Rob Mohr
5c9ca40150 Remove SUBDIRS from BUILD. (Apparently unused.)
Change-Id: I93ceb8c05797d8775f6ad9580e016470b1cda211
2019-11-19 18:28:54 +00:00
Rob Mohr
c2787500d5 Move loads to beginning of BUILD files.
Change-Id: Idb918a48cfe6149f624295f6712fbf0a3a36a7ff
2019-11-19 18:20:03 +00:00
Rob Mohr
cd59b7e076 Change 'size() == 0' to 'empty()'.
This came from a clang-tidy warning.

Change-Id: Ieee35262ab773e7314fbb0d3c0b197016734297d
2019-11-19 18:19:51 +00:00
Rob Mohr
af7bd883d8 Add docstring to pigweed.bzl.
Change-Id: I1b7783f71b0e98fcb3e36e0fcd1724d64d407213
2019-11-19 18:19:41 +00:00
Rob Mohr
8fc09da1ca Make IntToString argument names consistent.
This came from a clang-tidy warning.

Change-Id: I3a1b715e87c0dbe9e79013c15e14cf19dc5932cb
2019-11-19 09:59:19 -08:00
Rob Mohr
c8dd7fd723 Add missing format_test dep.
Change-Id: If5107700a9c8dab0c8f617fb2bd23741c3dfe080
2019-11-19 09:15:26 -08:00
Rob Mohr
f8328f3821 Move headers to hdrs for in pw_unit_test.
Change-Id: Ic08d878d91c44c5bfba1beabc8e1b55e056118d6
2019-11-19 05:12:08 +00:00
Rob Mohr
905d628b0b Add pw_status dep to to_string_test.
Change-Id: I6fd09f310b9d362551d05b0eb27192ecba808748
2019-11-19 05:11:52 +00:00
Rob Mohr
57211c25ff Add pw_dumb_io to bazel build.
Change-Id: I2ebc9f7e850195740e71a05ec97ab38e452781ce
2019-11-19 05:11:32 +00:00
Rob Mohr
e6cbdf8a9b Add -Wnon-virtual-dtor.
This has come up a couple times already, and when I import this
internally I get errors.

https://pigweed-review.git.corp.google.com/c/pigweed/pigweed/+/1900
https://pigweed-review.git.corp.google.com/c/pigweed/pigweed/+/2000

Change-Id: I96444edba75b7bbefdeb9d3718117a6dafa77bfb
2019-11-18 14:37:48 -08:00
Rob Mohr
7b49619a76 Add virtual destructor to Test class.
Change-Id: I76c48e519007f32a8c22efd36c094e2600d8e73e
2019-11-18 22:24:46 +00:00
Rob Mohr
df2b13b72d Add -use_header_modules.
This is for compatibility when migrating to other repositories.

Change-Id: I442b3d0a767c86a93427aed753a410262166df98
2019-11-18 14:04:25 -08:00
Armando Montanez
4f803342ba Small Cortex-M4 toolchain tweaks
Updates Cortex-M4 toolchain to use nano.specs and soft FPU.

Change-Id: I7f4d97bb428b38d90cae9041487460e6c2eed184
2019-11-18 21:14:52 +00:00
Rob Mohr
0a57954b8f Force use of CIPD packages in presubmit.py.
Change-Id: I778515463d1f899b24591e5e779072ca3a675305
2019-11-18 20:08:00 +00:00
Rob Mohr
c70366e906 Simplify bazel build.
Use variables instead of functions, and add wrappers for builtins.

Change-Id: If6e75efe35ce2fe754f2ed7421497bc1f5d47507
2019-11-18 11:24:53 -08:00
Rob Mohr
79ccb9f102 Remove "create_run_targets" from presubmit.py.
Change-Id: I5d1913fd113a0cc3b77afcf8a07d3a70bfe8d0fe
2019-11-18 19:10:10 +00:00
Armando Montanez
a69244e4c1 Add stm32f429i-disc1 target and pw_dumb_io
Adds both the stm32f429i-disc1 target and a pw_dumb_io uart-based
backend.

Change-Id: If24379118fc2877485653d61ca66ceeb59ef920a
2019-11-16 00:14:52 +00:00
Armando Montanez
68de071c7d Add pw_dumb_io with host backend
This change introduces the pw_dumb_io module, a module intended for
pigweed testing and bringup. pw_dumb_io includes a facade, and a backend
implementation using stdio (pw_dumb_io_stdio).

Change-Id: I5d9ca3c256c7e7c6d60cc07292aaead808a7f3dd
2019-11-16 00:14:15 +00:00
Rob Mohr
afe23d96c3 Minor formatting change in pigweed.bzl.
This will be easier to deal with in code migrations.

Change-Id: Id3d62e3dbdce666c05547d298f82ef07f8724054
2019-11-15 23:34:26 +00:00
Alexei Frolov
0944784e8e Minor pw_bloat updates
This change renames the bloat_report template to pw_size_report as it is
more explicit.

Additionally, the option to override the global Bloaty config file on a
per-report basis is removed. This is due to Pigweed's policy of having
one target per build invocation. The Bloaty config is inherently tied to
an executable build target and linker script, both of which are provided
by the target. Overriding the Bloaty config without changing the target
can result in meaningless report output.

Change-Id: I1fa444d065d964a3a85ade50039e06ae807050f2
2019-11-15 23:23:26 +00:00
Rob Mohr
007d66d1b5 Add pw_toolchain to bazel build.
Change-Id: Ia6213f4b62c158c7ce4c39b13c122ddf0de5f693
2019-11-15 23:00:54 +00:00
Rob Mohr
92a4247623 Add virtual destructor to EventHandler.
Change-Id: I004629c2f9853aa857ee2db8b3b6a637b801c6f7
2019-11-15 23:00:27 +00:00
Wyatt Hepler
e2dc6d18d6 Safer snprintf / vsnprintf functions
Provide a string::Format function that writes to a span. The snprintf
return value is interpreted and returned as a StatusWithSize.

Change-Id: Ib7fed684dc333d5feaef85c1bb558cb45e3936bd
2019-11-15 21:54:48 +00:00
Wyatt Hepler
cfe3526996 Move pw_bloat infinite loop into BloatThisBinary
To avoid bloat binaries from needing an infinite loop at the end of the
main function, put an infinite loop at the start of BloatThisBinary.
Now, bloat binaries based on the standard pw_bloat base only have to
call BloatThisBinary in their main function.

Change-Id: I165bb76a3d7a85fb1a10b5f55a0538da7d920f82
2019-11-15 21:53:01 +00:00
Wyatt Hepler
190feccb8c Hexadecimal printing function
Add IntToHexString, a simple hexadecimal output function.
PointerToString uses IntToHexString instead of IntToString.

Change-Id: Ib64ab888850d5050da84b4b84a2a279f0381f48f
2019-11-15 21:52:38 +00:00
Wyatt Hepler
a29c391311 Expand and organize .gitignore
Change-Id: Ic6efa8a33e71b96731ecf0ca5d6ab45baccf6d5a
2019-11-15 21:52:38 +00:00
Rob Mohr
e8fbe6a882 Add license metadata to bazel files.
Change-Id: Id32c7db700f3fba809d4e90473cbd3e8b8d7ca47
2019-11-15 11:52:14 -08:00
Rob Mohr
7f519e26bf Change presubmit.py to Python 3.
Change-Id: I7367e32c752353d78dd78a59e3288f3d1666db1a
2019-11-15 09:05:16 -08:00
Keir Mierle
367493555e pw_string: Add missing string_view include
Change-Id: I0e6cdb68c48d9e8f21e64af719acf53e4e6495c6
2019-11-15 03:17:30 +00:00
Rob Mohr
443bb9d20e Initial presubmit.py script.
Change-Id: I4b22f34222078ed139fca747da3f5f1733951d63
2019-11-15 01:51:54 +00:00
Alexei Frolov
0efdb117e1
Add root docs directory
This change adds a docs directory at the root level of the Pigweed
repository for building documentation for the entirety of Pigweed.
The directory contains a top-level index.rst and conf.py for docgen,
and a pw_doc_gen build target to render the documentation.

Change-Id: Iba981c64662d48a1d23bb7bda9bf0ed5a104873b
2019-11-14 17:29:23 -08:00
Alexei Frolov
4c035b0487
Integrate bloat reports into docgen
This change updates the bloat script to output an RST version of its
report card table. Metadata is added to the bloat_report GN template
indicating its RST output, allowing it to be listed as a dependency of
pw_doc_group targets.

Change-Id: I3f098d352856a9dd8688bac44e3b60ddbb97a3a6
2019-11-14 16:39:09 -08:00
Alexei Frolov
e2016763a8
Add pw_bloat module
This change adds a size reporting module named pw_bloat. The module
uses Bloaty McBloatface to generate size report cards for binaries. It
provides a GN template which defines an action to perform a size diff
on a group of binary targets.

Example output:

                       simple_bloat
                       ────────────
┌────────────────┬──────────────┬────────┬───────┬───────┐
│      Label     │    Segment   │ Before │ Delta │ After │
├════════════════┼══════════════┼════════┼═══════┼═══════┤
│     Add a loop │ EXAMPLE CODE │    429 │   +32 │   461 │
│                │ EXAMPLE  RAM │    576 │    +8 │   584 │
├────────────────┼──────────────┼────────┼───────┼───────┤
│ Add a function │ EXAMPLE CODE │    429 │   +16 │   445 │
│                │ EXAMPLE  RAM │    576 │    +8 │   584 │
└────────────────┴──────────────┴────────┴───────┴───────┘

Change-Id: I14b3d383ec450bc6d017bf5d0111e266b0a3c368
2019-11-14 14:29:28 -08:00
Wyatt Hepler
09517ed9b8 Have targets set pw_unit_test_create_run_targets
- Move pw_unit_test_create_run_targets to pw_vars_default.gni so that
  targets can set it.
- Keep the default false, but set it to true for the host targets.

Change-Id: Ia1af584642d0dd4d16b801b2ee4a8bb1a78c286e
2019-11-14 12:45:18 -08:00
Wyatt Hepler
cca0daf7b1 Clang toolchain Linux support
- Update host_clang to work on Linux: switch to -Map and --gc-sections
  options
- Make pw_target_toolchain a build arg for Linux and macOS targets.
  Default to gcc on Linux, clang on macOS.
- Rename x86_linux_gcc to host_gcc.

Change-Id: I72eef9ba9398a331f6567b68ad404092186eb15b
2019-11-14 12:34:15 -08:00
Wyatt Hepler
0dae2d63db Use EXPECT_STREQ instead of EXPECT_EQ
EXPECT_EQ happens to work (sometimes) because of string interning, but
these strings should be compared by value with EXPECT_STREQ.

Change-Id: Ifdcc7cf12d9c0868d8e7976baf549935ef117efc
2019-11-14 10:43:51 -08:00
Rob Mohr
cf185b4ccc Update bazel for pw_status and pw_string changes.
Change-Id: I698260e5dbb82625bb34e8a2c68a683eb569eddc
2019-11-14 18:29:39 +00:00
Keir Mierle
586719197a pw_toolchain: Start host_clang toolchain
This adds a generic host_clang toolchain, targeting hosts running Mac and
Linux to start, and likely Windows later.

For now, on Mac the default toolchain is set to host_clang_og

Change-Id: Iea457c61586930d509439c6616574c9a74919433
2019-11-14 18:26:54 +00:00
Rob Mohr
cb0558101b Add pw_docgen to bazel build.
Even though it does nothing, it makes importing elsewhere easier.

Change-Id: I2c2d6dcdcfa5d9f6113b8cde57e027beb26da5c6
2019-11-14 18:18:20 +00:00
Wyatt Hepler
58823c1bea pw_string: ToString function
ToString allows writing string representations of arbitrary types to a
buffer.

Change-Id: Ie0e327560847509b03c651bd1697be8bc084b360
2019-11-14 17:58:56 +00:00