Adds in buildifier bazel targets that autoformat/lint the entire
WORKSPACE. This can be invoked by running;
'bazel run //:buildifier'
or
'bazel run //:buildifier_test'
Change-Id: Iaaf7f6241e29894eca94aa6b5d0ca3b33255b7f7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/36160
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Keir Mierle <keir@google.com>
- pw_kvs: Remove use of std::enable_if that wasn't working property.
- pw_result, pw_rpc: Disable spurious GCC 10 warnings.
- pw_string: Size report code that is never executed was using the same
pointer for snprintf input and output, which is not legal. This caused
-Wrestrict warnings. Update the size report code to avoid this.
- Add the -pthread flag in GCC host builds to support building
pw_thread.
- pw_tokenizer: For host builds, insert the tokenizer sections after
.debug_info instead of .strtab, since inserting after .strtab does not
work for GCC.
Change-Id: Ib141a102ed50eb639c8d0bcb236572b3dc142ec1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/40620
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Adds clang thread safety annotations to the interrupt spin lock for
C++ usage. Note that this is only checked when compiling with clang.
C APIs explicitly escape the thread safety annotations.
Change-Id: Ic829afd41b3978c507ebe294d34e1e0dc03865b4
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/40241
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Migrates Pigweed off of SpinLock to use the new InterruptSpinLock
name.
Also updates some stale documentation regarding SystemClock backends
which use InterruptSpinLocks before C++ construction now that there
is a constexpr constructor, as it was already getting updated for
the rename.
Change-Id: Ie821b7c5c59f21a16bcc9bd9674c5df6a85e27b1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/37561
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Renames the existing pw::sync::SpinLock to InterruptSpinLock to
make it obvious that this is not just a spin lock and that interrupt
masking is included.
This change leaves C++ & GN redirects in place in order to support
migrating Pigweed and customers in follow up changes.
Change-Id: If9fb5594e7d71778b15cd15a9cd7ec71ca0e403b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/37560
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
moves pw_trace-related build args into imports so toolchains can import
them and silence unused build-arg warnings for downstream projects that
use Pigweed's default host toolchain but don't use pw_trace.
Change-Id: I25cd8b59e2b05e0345e9ed738c4b06beff9a5069
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/36080
Pigweed-Auto-Submit: Armando Montanez <amontanez@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Adds the SocketStream::Connect member function, allowing a SocketStream
to be established from the client side of a socket rather than only the
serving side as before.
Additionally, this change renames the existing Init member function to
Serve instead to make it clear that it is not required before calling
Connect and is instead an alternative way of establishing a SocketStream
connection.
Change-Id: Ib3fdb9f5405eee92ae1a166c64e990cb9c05fca7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/31261
Pigweed-Auto-Submit: Jason Graffius <jgraff@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Adds a std::thread like API through a new pw_thread facade based
on the STL's std::thread API, however with more restricted function
entry routine format support and backend specific option support
to permit non-portable configuration of thread settings/parameters
including static context allocations.
In addition this provides an initial set of backends based on using
the STL's std::thread directly.
Change-Id: Ib8c3cbdc434044e204e67e58d861a40e4acec9b4
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/30920
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Adds a "//targets/host:host_clang_fuzz" target so fuzzers get built
along with other build targets. This new target uses "address" as the
default sanitizer for fuzzing. Sanitizers are overridable via
pw_toolchain_SANITIZERS.
Adds a top-level "fuzzers" target so it could be used (e.g. by
OSS-Fuzz) to just fuzzers.
Test: build normally and run
`//out/host_clang_fuzz/obj/pw_fuzzer/bin/toy_fuzzer`
Change-Id: I4f1df389289ae7a47b29738a3c245f7bac308a08
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/31301
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Pigweed-Auto-Submit: Ali Zhang <alizhang@google.com>
Adds a std::this_thread like API through the pw_thread facades, that
is:
1) this_thread::yield
2) this_thread::sleep_{for,until}
3) this_thread::get_id
This module is split into many different facades in order to let users
decide what functionality they want to use as they may not always
be available, for example when using opaque SDKs.
In addition this provides an initial set of backends based on using
the STL's std::this_thread directly and selects them for the host
target.
Change-Id: I0ee8e4390ba988b2b13e9ee59f976f2333715f1f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/30040
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
This renames the hdlc_lite module to just HDLC to accommodate for future
development.
Change-Id: Ic96502a9f41d3a10179435347d4e8615bc3ae844
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/29042
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
This adds an channel output wrapper which synchronizes a ChannelOutput's
operations with a sync::Mutex, and updates the host target's system RPC server
to use it.
Change-Id: I3d2407a8c81a8f0370fd714ded850293d7030209
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/28540
Commit-Queue: Alexei Frolov <frolv@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Backends for the pw_rpc/system_server facade were defined in the pw_rpc
module, preventing targets from customizing their server configurations
and channels. This change moves the backends into the respective target
directories. Additionally, pw_unit_test's RPC main is updated to use the
system server.
Change-Id: I670e13dd178ab8a7fc8dfa8fade3f82a46d5208c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/28500
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Alexei Frolov <frolv@google.com>
- Add the --fail-on-unused-args option to gn gen by default in
presubmit.
- Import .gni files for backend build args into the toolchains
that set them.
- Skip the init_cipd and init_virtualenv steps in local presubmits.
Instead, use the current environment. This is much faster and avoids
confusion about which environment is in use.
Fixes: 294
Change-Id: Ib86da7c3d4560b6c92cbacced725ee54c485e3d6
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/27580
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Michael Spang <spang@google.com>
Using socket or sys_io to connect to server and client on host.
Test: Manually tested
Requires: pigweed:25460
Change-Id: I174121b90cea69621a885202b0d4d2df78a9aba8
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/20040
Commit-Queue: Jiaming (Charlie) Wang <jiamingw@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Adds the BinarySemaphore, CountingSemaphore, and Mutex to the
pw_sync module along with an STL backend for each.
Change-Id: I54a3a64e702202a319ed2c9068bf37412d3fd240
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24241
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>
Adds the initial pw_chrono module to Pigweed with a facade for the
pw::chrono::SystemClock. In adition, the pw_chrono_stl module is
provided with the first STL based backend of said module by using
std::chrono::steady_clock.
Change-Id: Id29f4280aa399a81518f6d13183cf495b2ee72dc
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23260
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>
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>
This updates pw_protobuf_compiler to always create a target for each
supported protobuf generator, instead of having a build arg to select
which ones to use, simplifying the use of pw_proto_library.
Change-Id: I2699c9c5045e8671a061f8c8bc11a94244d008f1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22721
Reviewed-by: Armando Montanez <amontanez@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Alexei Frolov <frolv@google.com>
Updates all Pigweed targets, except for arduino, to use the
extra_strict_warnings where relevant.
Also fixes up several places which wouldn't compile with "-Wshadow"
enabled.
Change-Id: Ieb2c7f4870e4609181825e2c894ccbac56135cad
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21688
Reviewed-by: Armando Montanez <amontanez@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
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>
- 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>
In general toolchains should set values for the builtin arguments
current_cpu and current_os; this configures both the toolchain itself
and everything it builds. Make it so in Pigweed.
If there's a toolchain with current_os = "ios", use the arguments for
Apple's linker.
Bug: 241
Change-Id: I2ce8c46eb48cbc70c5d14086934bdf59c2fc3f36
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/16006
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Michael Spang <spang@google.com>
This change creates a Pigweed third_party directory and defines a GN
build file for nanopb which exposes a pw_source_set for the nanopb
library from a build arg pointing to a local nanopb installation.
Change-Id: I6779203626abce7821dc3fcef6dcbc11c319b43c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/15763
Reviewed-by: Keir Mierle <keir@google.com>
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>
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>
Fixes some errors and some stale references and formats.
Change-Id: I5a2f6d4a20591b61ae49eaab3310dc7abf51d83d
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/14122
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Updates syntax for using pw_watch in a few other locations.
Change-Id: I599fc3cb552c75e9f546447556fb756633093391
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13804
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Armando Montanez <amontanez@google.com>
Updates pigweed to depend directly on is_host_toolchain provided by the
toolchain. Also adds a toolchain option that controls the extension of
final linked binaries.
Change-Id: Ia9499fe5974997a5bbc0bb9cfb89b5569b987189
This checks if the project has already set the nanopb protobuf generator
before adding it as part of the host target.
Change-Id: I1336d73bdcbcb786bf783909b32230bebf10bdba
Update the host toolchains to be prefixed with their target name and use
a slightly more compact style to define the toolchain scopes.
Change-Id: Ib0dae237299e74c6c48cd4c35869fd215563a7bf
Sets up clang and gcc based toolchains for all host target builds.
Defaults to using Clang for linux/mac and GCC for windows.
Change-Id: I1a15d98581cbf886fbb86321f2d7dabb0dd43cf1
This change configures the Linux clang -Og target as a toolchain with
args. To support this, all Pigweed variables from pw_vars_default are
made into build args, defined within their respective modules.
The Linux clang target/toolchain is the only one that currently works.
Pigweed's other targets will be ported in later changes.
Change-Id: I051e29fde7577e41a3184c37031a4e04936404e1
Require targets to explicitly import pigweed variable definitions. This
moves out some necessary logic from the BUILDCONFIG.gn file.
Change-Id: If9c9fe5a680cc9d897a0e8a55889873be618ed84
This change adds support for compiling nanopb protobufs using
pw_protobuf_compiler.
The pw_protobuf_langs build variable is renamed to
pw_protobuf_generators as there is no longer a 1:1 mapping of languages.
To compile nanopb, add the "nanopb" generator to pw_protobuf_generators.
The build variable $dir_third_party_nanopb must be set to point to a
local installation of nanopb with GN support:
https://github.com/frolv/nanopb/tree/gn-build
The host build will run a test which compiles nanopb code if
$dir_third_party_nanopb is set.
Change-Id: I29bf8780644917f35203a538b0bd7e4f3ec40180
Adds target docs for the `docs` and `host` builds. Also includes a few
other documentation updates.
Change-Id: Icc973d6d51707c79b7c506d89c8975023e274ef2
- The scripts in .python3-env/bin use a shebang line to point to
Python. If the Python path has spaces, this line will not work
correctly. Until this can be fixed, abort bootstrap.sh if Pigweed's
path has spaces.
- Quote expansions in environment setup to prepare for eventually
allowing paths with spaces.
Change-Id: I85333bd930e03731e5ae093c5f63b6a2a26c6316
Renames host.gni to target_config.gni so all targets have a
target_config.gni, and it's clear which .gni file to use for target
configuration.
Change-Id: I1bd0442a9dc00201bff46eb776a4a59c1d339a4e
This makes Windows consistent with the other host platforms and this
behavior is required by CI builds.
Change-Id: I35b3df2d82364d3d43f6c334e71e7bef8d8a0f4d
This change configures the Windows host target for GN. It should allow
building unit tests for the host.
Change-Id: Ib92c9a83b9b858a9b7ed55487199c63896580af1