Commit Graph

31 Commits

Author SHA1 Message Date
Wyatt Hepler
438caa0ddb pw_build: Make GN Python installation more robust
- Since protobuf Python packages are generated and installed from the
  build directory now, add dependencies on package installs in the
  build. This ensures packages are properly installed before tests or
  linting.
- Instantiate all Python actions in the default toolchain. This prevents
  duplicate instantiations of Python actions for each toolchain, which
  causes flakiness as packages are reinstalled for each toolchain.
- Add python_deps to pw_python_action that Python actions can depend on
  Python package installations.
- Add various missing dependencies between Python packages.

Change-Id: I4ec34f06c04014b3552cc1b60aa506ac9a89b329
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/30000
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
2021-01-22 04:42:12 +00:00
Wyatt Hepler
f276c6b6c0 pw_status: Use new functions instead of variables
Run python -m pw_status.update_style to migrate to the new
Status::Code() functions from the Status::CODE variables.

Change-Id: I8757cf1f46586c04cd822c01f9868de7d3ea0583
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24481
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
2021-01-12 00:44:10 +00:00
Wyatt Hepler
1b3da3a983 pw_status: Replace Status::Ok() with OkStatus()
- Mark Status::Ok() and StatusWithSize::Ok() as deprecated.
- Replace Status::Ok() with OkStatus().
- Replace StatusWithSize::Ok() with StatusWithSize().

Change-Id: If7192282446bf6d7f90990bb0b4f1b1b89a9228a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/29003
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Keir Mierle <keir@google.com>
2021-01-11 20:28:12 +00:00
Wyatt Hepler
8ce9013bfd pw_build: Support specifying mypy/pylint config
- Add pylintrc and mypy_ini options to the pw_python_package template.
  These can be used to specify configuration files to use for Pylint and
  Mypy.
- Run pylint and mypy from the setup directory. This allows tools to
  find per-package configuration files (if they aren't specified by the
  pylintrc or mypy_ini arguments).
- Fix some incorrect import ordering that Pylint detects now that it
  runs from package directories. PEP8 states imports should be grouped
  by standard library, third party, and local package imports.

Change-Id: I8017341178ac5920d623ebbed4535432d69527c3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/26700
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
2020-12-04 17:59:45 +00:00
Wyatt Hepler
a17fbddbf4 pw_status: Remove implicit conversion to pw_Status
Conversions to the pw_Status enum are dangerous, since they make Status
convertible to bool. This means statements like `if (status)` compile,
and status evaluates false for OK and true for non-OK.

This change replaces pw::Status's conversion to pw_Status with an
explicit code() function.

Change-Id: I2075a73c3e59ec051bd50b60a089baefc5f05dca
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24520
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-11-12 23:22:55 +00:00
Wyatt Hepler
0a6f763b12 CMake: Revamp CMake build
- Define CMake cache variables (similar to gn args) for facade backends.
- Create simple initial toolchain files for GCC and Clang.
- Misc updates to pigweed.cmake and pw_build/CMakeLists.txt.
- Add or expand various CMakeLists.txt files.
- Watch CMake files in watch.py to support using CMake in pw watch.

Change-Id: I490d157485d02811a11f6a3589a0508ea1851f58
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22840
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Keir Mierle <keir@google.com>
2020-11-04 22:31:07 +00:00
Ewout van Bekkum
1502a40b68 pw_trace_tokenized: use steady_clock, not system_clock
Updates the pw_trace_tokenized's host_trace_time backend to use
the std::chrono::steady_clock which is monotonic, instead of the
std::chrono::system_clock which may unexpectedly jump backwards
causing odd trace artifacts.

Change-Id: I42749e7a8272650c23f2ff420615a23191df3b1a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23222
Reviewed-by: Rob Oliver <rgoliver@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
2020-11-03 16:21:43 +00:00
Robert Oliver
f69f069a75 pw_trace: fix clear on enable
Change-Id: I582e75afc2fb50a9f851d39c1df8b922773a0242
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22708
Reviewed-by: Paul Mathieu <paulmathieu@google.com>
Commit-Queue: Rob Oliver <rgoliver@google.com>
2020-10-28 18:58:31 +00:00
Robert Oliver
5077c7c365 pw_trace: improve locks
Add an internal queue with a separate lock, this is a small section
which just copies the arguments making it suitable for a critical
section.

Emptying this queue is handled from a separate lock, which is a trylock.
If the queue is already being emptied, it is safe to return after adding
to the queue (no need to block).

Change-Id: I45bbf749b2cb8687bb5d8e485adde2256b2c99a8
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21881
Reviewed-by: Paul Mathieu <paulmathieu@google.com>
Commit-Queue: Rob Oliver <rgoliver@google.com>
2020-10-28 18:05:43 +00:00
Robert Oliver
19468fb44d pw_trace: Make the module configurable
Create a config header and expose through facade
(pw_trace_tokenized_CONFIG).

Change-Id: I8068589434cfe6a4a1d9a6f6d7bbcd8959c550c3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21880
Commit-Queue: Rob Oliver <rgoliver@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Paul Mathieu <paulmathieu@google.com>
2020-10-28 15:42:17 +00:00
Wyatt Hepler
01a85d6b0e Python: Generate BUILD.gn files for Python packages
- Generate BUILD.gn files with pw_python_packages using
  pw_build.generate_python_package_gn.
- Add the new pw_python_package targets to the default build.
- Remove the unncecessary "python_packages" group.
- Fix some Windows path issues in Python tests.

Change-Id: I50c9b1f650652554f0836cbdc1781a00ec7e8e56
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22203
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
2020-10-22 21:12:11 +00:00
Wyatt Hepler
3b4047da68 Python: Add py.typed files per PEP 561
- PEP 561 (https://www.python.org/dev/peps/pep-0561/) specifies that
  packages that wish to support type checking must provide a py.typed
  marker file. Add py.typed to all packages.
- Add missing __init__.py files to pw_cli and pw_hdlc_lite.

Change-Id: I32d652222e9909a5ac4a5612c2dd1683b18b2d36
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22200
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-10-22 19:24:02 +00:00
Wyatt Hepler
d7dc6550c9 pw_build: pw_python_package and mypy fixes
- Use the target-relative path for pylint's stamp so it is unique when
  there are multiple files with the same basename (e.g. __init__.py).
- Serialize pip install commands since in-parallel --editable installs
  do not work correctly.
- Run mypy over the entire package directory rather than individual
  files.
- Fix various mypy issues so that mypy passes without
  --ignore-missing-imports.

Change-Id: I8129144d7c963616e5b836dd2f082c41f1dc1416
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22201
Reviewed-by: Alexei Frolov <frolv@google.com>
2020-10-22 18:28:07 +00:00
Paul Mathieu
787ce97a03 pw_trace_tokenized: add tickrate to python script
Testing done:
- tested with data obtained on my own target

Change-Id: I16c11a632917d4758b5df97c120171af88af85f1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/20283
Commit-Queue: Paul Mathieu <paulmathieu@google.com>
Reviewed-by: Rob Oliver <rgoliver@google.com>
2020-10-20 20:07:51 +00:00
Wyatt Hepler
d49f8fe3f3 BUILD.gn files: Improve import formatting
The "# gn-format disable" comments are no longer necessary. Delete these
comments and reformat with a Vim macro and gn format.

Change-Id: Ia62c40ad73eef91187d0d443d6e3b0fa723e5aa9
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21380
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-10-15 18:12:55 +00:00
Wyatt Hepler
f9fb90f299 docs: Make labels consistent; remove boilerplate
- Update labels so they use consistent naming. Instead of the
  copy-and-pasted `chapter` prefix, name labels with a prefix consistent
  with what they point to:
  - "module-" for module
  - "target-" for targets
  - "docs-" for general documentation
- Remove the unnecessary highlight and default-domain directives.
  Neither is necessary since the Pigweed docs always specify the
  language in code snippets and other directives.

Change-Id: I55c34e9ec919f6f4670e5d3d008e0edf5fecf05b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19328
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2020-10-01 21:47:35 +00:00
Wyatt Hepler
d78f7c6b75 pw_status: Update Status::CODE to Status::Code()
- Update Status::CODE style to Status::Code() using
  pw_status/update_style.py.
- Make minor adjustments to the pw_assert tests to get them passing.

Change-Id: Ie54c3c605178fd1e42c7cedbcff324115f3ed279
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19165
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
2020-09-30 18:09:44 +00:00
Ewout van Bekkum
bd33812e82 pw_varint: expose kMaxVarint{32,64}SizeBytes
Renames the existing pw::varint::kMaxVarintSizeBytes to
pw::varint::kMaxVarint64SizeBytes and adds a new
pw::varint::kMaxVarint32SizeBytes.

Note this does not yet remove pw::varint::kMaxVarintSizeBytes, as
the existing users need to be migrated first.

Change-Id: Ie57e32b9526347df95282f7bba2d6f2ff34b4a08
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/18686
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
2020-09-23 00:38:55 +00:00
Prashanth Swaminathan
0a9129c0d8 pw_trace_tokenized: Dump trace buffer to log
Adds a support function that dumps the current trace buffer using the
pw_log module.

Change-Id: Ie3b5bb666602ed0b0f294514e8c55646fba5c902
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/18160
Reviewed-by: Paul Mathieu <paulmathieu@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Prashanth Swaminathan <prashanthsw@google.com>
2020-09-17 19:41:57 +00:00
Wyatt Hepler
eb3304c276 pw_preprocessor: Rename macro_arg_count.h
- Rename macro_arg_count.h to arguments.h
- Have macro_arg_count.h #include the renamed header for compatibility.

Change-Id: I781a457af88c6dd63ab8f8394bfe45cff9bc71e9
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/17500
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-09-08 17:45:35 +00:00
Wyatt Hepler
d9a1b82b37 pw_tokenizer: Make LoadTokenDatabases public
Change-Id: I3c4e9e316c92fe8abb90e21abb48566406d79c64
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/16860
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Joe Ethier <jethier@google.com>
2020-08-26 20:58:36 +00:00
Paul Mathieu
0b374c2f2a pw_trace_tokenized: move py code to a library
Change-Id: Id01d5213b913eae23f06de09180a93d7c32b22c4
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/15941
Commit-Queue: Paul Mathieu <paulmathieu@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2020-08-14 08:34:29 +00:00
Paul Mathieu
54d63ec6c1 pw_trace_tokenized: add trace buffer size GN arg
Change-Id: Ia61de1aa4a0d1e188514bd59108432f0cedec39e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/15940
Commit-Queue: Paul Mathieu <paulmathieu@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2020-08-14 08:27:59 +00:00
Wyatt Hepler
a4d8dceb33 pw_trace_tokenized: Tokenize to the "trace" domain
Tokenize trace strings to the "trace" domain to avoid cluttering the
default domain.

Change-Id: Ie74240153d203ce9a315357e22823c0f76e15384
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/15960
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-08-13 17:13:51 +00:00
Wyatt Hepler
7e3f1d9bb1 GN build: No longer add public to sources
Adding public to sources is unnecessary. Clean up the remaining places
where this is done.

Change-Id: I63f1df64054b319d0a3297f62227756a1e3847ed
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/15665
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-08-08 01:58:46 +00:00
Robert Oliver
9da6af8952 pw_trace: Initial tokenized trace python tool
Generates json trace files viewable using chrome://tracing from binary
trace files.

Example usage:
python pw_trace_tokenized/py/trace_tokenized.py -i trace.bin -o trace.json
./out/host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_basic

Change-Id: Ia660ee339ebfd26d67377d12618fb9e588865fc8
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/15200
Commit-Queue: Rob Oliver <rgoliver@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2020-07-31 21:18:03 +00:00
Robert Oliver
0cc2075e56 pw_trace: tokenizer filter example
Add a example for how to filter out traces. in this example, all traces
from the processing task which aren't trace_id 3 are skipped.

Change-Id: I8c1ad1931cf2319df85c13c01b6d41e359e6cbb6
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13922
Commit-Queue: Rob Oliver <rgoliver@google.com>
Reviewed-by: (☞゚∀゚)☞ Tennessee Carmel-Veilleux  <tennessee@google.com>
2020-07-31 21:04:12 +00:00
Robert Oliver
19146916e6 pw_trace: tokenizer trigger example
Uses the trace sample app to demonstrate how to use trace events as
triggrs to capture a specific sequence of events. in this case the
example captures all events when handling job 3 of the sample app.

Change-Id: Ib278ad5318f428e1dee8813fd0d6cff9b77b1c1a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13921
Commit-Queue: Rob Oliver <rgoliver@google.com>
Reviewed-by: (☞゚∀゚)☞ Tennessee Carmel-Veilleux  <tennessee@google.com>
2020-07-31 21:03:43 +00:00
Robert Oliver
6d05de13e7 pw_trace: tokenizer basic example
Run the trace sample app and dump all trace data to a file.
- Use std::chrono::system_clock as the time source for host builds.
- Add trace_to_file.h which registers callbacks and saves all trace data
to a provided binary file.

Change-Id: I57fac75ed91fc98646e7aae920897687a39549ab
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13802
Commit-Queue: Rob Oliver <rgoliver@google.com>
Reviewed-by: (☞゚∀゚)☞ Tennessee Carmel-Veilleux  <tennessee@google.com>
2020-07-31 20:57:23 +00:00
Robert Oliver
81e6e3e44c pw_trace: Add buffer
Add an optional ring buffer which holds the encoded trace data. When
included the buffer registers automatically and captures and stores
encoded trace events. This is a work in progress, future CLs will add
more/better methods of accessing the data.

Test: passes the included tests.
Change-Id: I0744547471086171dd47a22ed53312b1033930c7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13322
Commit-Queue: Rob Oliver <rgoliver@google.com>
Reviewed-by: (☞゚∀゚)☞ Tennessee Carmel-Veilleux  <tennessee@google.com>
2020-07-31 12:46:11 +00:00
Robert Oliver
21dcf27113 pw_trace: Initial tokenized trace backend
Tokenized trace, implements trace events by tokenizing all compile time
information of the event into a 32bit number (using tokenizer module).

This CL just adds the encoding of trace events and callback hooks,
buffering which usies the callback will be added in a future CL.

Test: passes included test
Change-Id: Ibfcc34211c09965af8da030e28dba5e8f7c6ccdb
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/11428
Commit-Queue: Rob Oliver <rgoliver@google.com>
Reviewed-by: (☞゚∀゚)☞ Tennessee Carmel-Veilleux  <tennessee@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2020-07-31 12:44:51 +00:00