Adds the first synchronization primitive to Pigweed: the
pw::sync::SpinLock with integrated local interrupt
masking.
This also provides the first backend for the SpinLock facade
backed by an STL implementation. Note that signals are considered
"NMIs" while spin locks are only supported up to IRQs, ergo no
local interrupt/signal masking is done in the STL implementation.
Change-Id: I34204835c55e54597077d40665f61715964803f9
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/25802
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
- Update the command line arguments to make pw watch simpler to use.
Positional arguments are interpreted as targets in the default output
directory. -C or --build_directory can be provided to support
specifying the build directory or using multiple directories.
- Find Ninja directories by build.ninja instead of args.gn to support
CMake.
- Call .kill() instead of .terminate() on Ninja to give it time to
properly clean up before closing.
- Import Path from pathlib, for consistency with other modules.
Change-Id: Ic66e58ce775de4a3a8749109d4ff65eb78a22aac
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/25760
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
- Replace the public internal method lookup generated functions with a
private array of method IDs. Create a MethodLookup class that is
friended by generated services to access this array.
- Use the generated method ID array to support method lookup in services
with multiple different protobuf implementations (Nanopb and raw).
- Ensure that the correct method implementation is selected when looking
up a method at compile time. This prevents accidentally accessing a
Nanopb method as a raw method or vice versa in a test method context.
Change-Id: I0ea334c02ae7c29e50099aa5bcfa975df625d15e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/25740
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
- Fix issue where an RPC method could be implemented with the signature
of a different RPC type. Pass the expected method type when methods
are created and check that it matches the type deduced from the method
signature.
- Reduce code duplication to limit the number of places where
compilation errors occur.
- Combine variable RPC method traits classes into MethodTraits.
- Move all Method creation functionality into the method classes.
- Put the final method invocation logic into one function that
supports member functions or static functions.
- Consolidate error messages for incorrect method signatures into one
place. Expand the messages and describe the expected function
signature.
Change-Id: Iae3c6d32df715e877e8c977ccd2232814ef590a7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/25641
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
- Include subdirectories with EXCLUDE_FROM_ALL and make sure all targets
have this property set. This gives external projects full control over
what builds by default.
- Provide a `pw_apps` top-level group that builds standalone
applications and add this to the CMake presubmit step.
Change-Id: I52f0043f78ffdf6a78ddf23e7a1a9635eb9eda58
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/25182
Reviewed-by: Zoltan Szatmary-Ban <szatmz@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
- Make the HDLC frame handling code more generic.
- Move code for collecting protos from paths or modules into
python_protos.py.
- Provide a protos variable in the RPC console for accessing proto
messages by package.
Change-Id: I0d4e514944103e0657b4228a1e1aee236aefd8cd
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/25080
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
If a ServerWriter is closed, its AcquirePayloadBuffer function returns
an empty span. The nanopb ServerWriter would then try to encode into
this span and fail, returning a cryptic INTERNAL status. This updates
the nanopb writer to correctly return FAILED_PRECONDITION if Write is
called when it is closed.
Change-Id: I30c70f0ee2a7f7c6f44bb8aded9aafa2045b99a4
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/25260
Commit-Queue: Alexei Frolov <frolv@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
This implements an RPC service that streams pw_unit_test events, as well
as a unit test main that initializes a server with the test service
registered and an HDLC serial channel.
Change-Id: I6c66f2216c54d82aa70c351d7d3d99d9a5c173de
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23901
Commit-Queue: Alexei Frolov <frolv@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
- `--library-path` can take multiple paths in order of increasing
precedence similar to Arduino IDE behavior. This is useful for
including the 'libraries' directory included in an Arduino core
and a separate user library folder.
- Remove serial wait loop from pw_sys_io_arduino
- Fix raised ValueError if arduino core install prefix is not
relative to os.getcwd()
Change-Id: I6d68b319d2a6a4bfc6a7a599bf4c86f4bea96e39
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24840
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
Adds a mention of pigweed.dev in the "Building the Documentation"
section of the getting started guide.
Change-Id: I172de3768df42b551b24ac878972260ce955c241
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24425
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Armando Montanez <amontanez@google.com>
This creates a build arg which appends additional public dependencies to
unit test targets. This is required after the .lib target change, as
dependencies which were previously included through the test main are no
longer applied to the test sources.
Change-Id: If4595724dd08763dcaac04a7b44e726a604338f8
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24920
Reviewed-by: Wyatt Hepler <hepler@google.com>
This updates the pw_test and pw_test_group templates to create a .lib
target which contains the test code as a source_set that can later be
linked into a pw_test. pw_test_groups additionally have a new .bundle
target which builds an executable with all of the group's tests.
Change-Id: Ic77d9d3a02cd29487a9f82001d9bf3314da4fa27
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24621
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
This changes ChannelOutput::SendAndReleaseBuffer to take a span instead
of a size. The previous API restricted a ChannelOutput implementation to
using a single buffer, which is limiting for larger systems. With the
new API, a ChannelOutput can hand out multiple buffers simultaneously.
Change-Id: Ie4c55bf66063493bf280353795c0295ceb7e450a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24444
Reviewed-by: Wyatt Hepler <hepler@google.com>
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>
To prevent leaking warning flags to users, make the
pw_build.strict_warnings and pw_build.extra_strict_warnings private
dependencies. They automatically apply to Pigweed code, but not code
that depends on it. CMake projects using Pigweed should configure
their own warnings as appropriate.
Change-Id: I98c4cb29246d570f8ff91f2513832773a69f6df1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24541
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Zoltan Szatmary-Ban <szatmz@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
Adds a .gni to share the stamp and copy tools between the dummy
toolchain and generated toolchains.
Change-Id: I04e044c293854b60ad8117b1a603aa1993891d92
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24441
Commit-Queue: Armando Montanez <amontanez@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
- Rather than relying on Python entry point scripts to get paths to
protoc plugins, pass the paths to the generate_protos.py script. This
works in environments where the Python entry points are not available.
- Use unique paths for generated proto code in the GN build. This allows
multiple GN targets to generate code from the same .proto files. The
CMake build already worked like this.
- Cleanup and reduce code duplication in the CMake and GN proto
generation code.
- Support Windows builds: generate .bat wrapper script for plugins, fix
compilation issue that affects some older compilers.
Change-Id: Iab27a3d193d6008567b324dc1c4e5f540894b8ff
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24380
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Zoltan Szatmary-Ban <szatmz@google.com>
It's no longer used by Pigweed or any downstream projects.
Change-Id: Ida7592bbcf625a152047cdc23ca5c7b0c60fa2f0
Bug: 287
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24202
Commit-Queue: Rob Mohr <mohrr@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
- Add IsErrorCode() functions to simplify checking for specific status
codes.
- Automatically replace some cases of status == Status::Code() with
status.IsCode() in update_style.py.
Change-Id: I13be834a2413d694d41a7755d2e317c35d34c5bf
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19521
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
- Do not recalculate tokens when adding them to a token database.
- Remove unneeded APIs for adding plain strings. These are no longer
needed and should not be used since the hash calculations are done
entirely in firmware now.
Change-Id: I8d15088f2ebe60adf6e21d6ccbd0dc99ad255fd7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24460
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
Automatically add the linker script in the CMake build, as the GN build
does.
Change-Id: Ibbad27fbb94c091c065983b80c91a85527844226
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24440
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
Add the CMake tests to the 'quick' presubmit program so they run locally
by default (on supported platforms).
Bug: 251
Change-Id: I16a1fa44d167456a7234de4b58d71aed012de9e3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24261
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
The virtualenv setup is now fast enough that it can always be run.
Bug: 287
Change-Id: I55c8de48bdcef53295f36d8814887134b31f87d5
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23502
Commit-Queue: Rob Mohr <mohrr@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
- Add CMakeLists.txt for pw_hdlc_lite's RPC example.
- Update the pw_rpc CMake to split out individual libraries.
- Small docs update for using third party code in the CMake build.
Change-Id: I3ee8b85a275c3402dc494b0ea3a8140005241ccf
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24280
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
- was broken if library_* args are not set
Change-Id: Iad987dbfe843195eef4996f075d7b2a051ee8787
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24107
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Include target support packages when bootstrapping on Windows. This also
affects downstream projects that directly invoke Pigweed's
bootstrap.bat, including the sample project. Longer-term those projects
need to do something equivalent to the POSIX bootstrap.
Change-Id: Idf0bfe40d8611e2d2769604e67ee97a2730d6af8
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24106
Commit-Queue: Rob Mohr <mohrr@google.com>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
Use "label_no_toolchain" for group names so that the canonical GN labels
are used. Previously, group names were not formatted correctly
(//path/:target).
Change-Id: I9dc0f4637fe3ceaa16f53f2b15311dee8faebd35
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24081
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
- Add -f/--follow option to pw_tokenizer.detokenize, which gives similar
behavior to tail -f.
- Default to requiring at least one database file at the command line.
Change-Id: I56813ba0e7706a121acff1f1d9c2ea2d9c64c7cd
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24056
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
Drive letters (`C:\...`) break parsing of the nanopb_out flag. Split it
into two separate flags for Windows compatibility.
Change-Id: I334708e74971cbefe1091bdaa088fa5e06d4f1f4
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24023
Commit-Queue: Armando Montanez <amontanez@google.com>
Pigweed-Auto-Submit: Armando Montanez <montanez.armando.l@gmail.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Some tools (nanopb) launch python using `py -3`. Pigweed doesn't
provide a full py launcher, so this is a stopgap change to add a
stub that should support scripts that launch python using the py
launcher.
Change-Id: Ibed1ae2ca79ef3c9698056c04110a1ab82d825c7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24022
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
Pigweed-Auto-Submit: Armando Montanez <montanez.armando.l@gmail.com>
This adds a non-blocking version of ReadByte() that enables writing, for
example, a superloop that combines custom processing simultaneously with
byte input handling for the RPC subsystem.
Change-Id: I9cb1e6ae8c944ca7cdff6d4bff101ac52e80b53a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23980
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Keir Mierle <keir@google.com>