Commit Graph

43 Commits

Author SHA1 Message Date
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
Michael Spang
6a8459589c pw_toolchain: Allow iOS to use the right -map flag
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>
2020-08-14 19:29:22 +00:00
Alexei Frolov
dd6fa5c7bd third_party: Add nanopb BUILD.gn file
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>
2020-08-14 16:58:59 +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
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
Ewout van Bekkum
e072fabcf0 docs: some more minor updates
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>
2020-07-18 02:38:39 +00:00
Armando Montanez
3f3546ebd5 pw_watch: Update syntax for pw_watch
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>
2020-07-13 22:28:43 +00:00
Armando Montanez
86003203b7 pw_toolchain: Update toolchain options
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
2020-06-16 18:00:06 -07:00
Armando Montanez
a761e32bf9 Update docs
First pass at docs to bring them up to date with The Great GN Refactor.
More to follow.

Change-Id: I02dc977fcdc7bf3efa8fc9080282dee9b1455cdd
2020-06-16 10:00:17 -07:00
Alexei Frolov
48d58a095f host: Don't add nanopb generator if it exists
This checks if the project has already set the nanopb protobuf generator
before adding it as part of the host target.

Change-Id: I1336d73bdcbcb786bf783909b32230bebf10bdba
2020-06-16 10:00:17 -07:00
Armando Montanez
ccc3ee14b9 Update Pigweed presubmit
Updates the upstream presubmit to play nicely with The Great GN
Refactor.

Change-Id: I2296db592b4c8e3c2d5592410b9846e7435ac1fc
2020-06-16 10:00:17 -07:00
Armando Montanez
d9a8a346bc Clean up host toolchains
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
2020-06-16 09:50:59 -07:00
Armando Montanez
82bbce4aeb Remove legacy_target.gni
Transition to args is done, so this import is no longer needed.

Change-Id: Id42e06ec9fcc16eace2cc7ef51a5dacaf012147a
2020-06-16 09:50:59 -07:00
Armando Montanez
164624f0b0 Set up all host toolchains
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
2020-06-16 09:50:59 -07:00
Alexei Frolov
258fc1b8bf Define docs target as a toolchain
This change creates a toolchain that configures the docs target and adds
it to the default build.

Change-Id: Ib2a8387253eef809f94411780174377e0d23e1a9
2020-06-16 09:50:59 -07:00
Alexei Frolov
4c0428a0d8 Define Linux clang target as toolchain
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
2020-06-16 09:50:59 -07:00
Armando Montanez
fb3d3fba79 Don't declare pigweed variables as globals
Require targets to explicitly import pigweed variable definitions. This
moves out some necessary logic from the BUILDCONFIG.gn file.

Change-Id: If9c9fe5a680cc9d897a0e8a55889873be618ed84
2020-06-16 09:50:59 -07:00
Rob Mohr
a7758f949a host: make clang the default
Make clang the default compiler on Linux.

Change-Id: I4c5d8e0a4e361f4d5b57c184ec89b09a8d789c65
2020-04-15 15:25:16 -07:00
Alexei Frolov
f39cd8b5ba pw_protobuf_compiler: nanopb support
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
2020-04-15 18:19:44 +00:00
Armando Montanez
3d92e81f1c Docs: Add target docs
Adds target docs for the `docs` and `host` builds. Also includes a few
other documentation updates.

Change-Id: Icc973d6d51707c79b7c506d89c8975023e274ef2
2020-03-19 20:49:33 +00:00
Wyatt Hepler
77bd6d23ba bootstrap.sh: Abort if PW_ROOT has spaces
- 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
2020-03-19 12:46:31 -07:00
Armando Montanez
e97f05936a host: Rename host.gni to target_config.gni
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
2020-03-19 17:42:26 +00:00
Alexei Frolov
b7e952b79f Disable host_tools by default in host build
This change disables building host tools by default as they are packaged
in CIPD.

Change-Id: Ie5129805affa748dbcbc93ade7c208f733a61c88
2020-03-18 00:32:07 +00:00
Armando Montanez
f7a5a742ab Rename pw_dumb_io to pw_sys_io
Rename pw_dumb_io facade and backends to use the more deliberate name
pw_sys_io moving forward.

Change-Id: I968480715967ab8de491856afa1b7692b973ed7e
2020-03-03 18:19:17 +00:00
Alexei Frolov
8e58e88665 Make pw_target_toolchain a build arg on Windows
This makes Windows consistent with the other host platforms and this
behavior is required by CI builds.

Change-Id: I35b3df2d82364d3d43f6c334e71e7bef8d8a0f4d
2020-02-08 01:15:00 +00:00
Keir Mierle
3cee879769 pw_assert: Initial assert module
This starts the assert and assert_basic modules, which are the beginning
of our assert foundation. Much more is needed; in particular the "tests"
don't really do much other than check for compilation.

Screenshot
==========

   ▄████▄      ██▀███      ▄▄▄           ██████     ██░ ██
  ▒██▀ ▀█     ▓██ ▒ ██▒   ▒████▄       ▒██    ▒    ▓██░ ██▒
  ▒▓█ 💥 ▄    ▓██ ░▄█ ▒   ▒██  ▀█▄     ░ ▓██▄      ▒██▀▀██░
  ▒▓▓▄ ▄██▒   ▒██▀▀█▄     ░██▄▄▄▄██      ▒   ██▒   ░▓█ ░██
  ▒ ▓███▀ ░   ░██▓ ▒██▒    ▓█   ▓██▒   ▒██████▒▒   ░▓█▒░██▓
  ░ ░▒ ▒  ░   ░ ▒▓ ░▒▓░    ▒▒   ▓▒█░   ▒ ▒▓▒ ▒ ░    ▒ ░░▒░▒
    ░  ▒        ░▒ ░ ▒░     ▒   ▒▒ ░   ░ ░▒  ░ ░    ▒ ░▒░ ░
  ░             ░░   ░      ░   ▒      ░  ░  ░      ░  ░░ ░
  ░ ░            ░              ░  ░         ░      ░  ░  ░
  ░

  Welp, that didn't go as planned. It seems we crashed. Terribly sorry!

  CRASH MESSAGE

     Check failed: x (=50) > y (=51300): You SHOULD see this message

  CRASH FILE & LINE

     ../../pw_assert/assert_test.cc:46

  CRASH FUNCTION

     PigweedTestBody

==========

Change-Id: I9dbb460b3b33040d8009749f44b9fc174e2c8138
2020-02-07 23:18:07 +00:00
Alexei Frolov
dddc4fd7ce Initial Windows GN build
This change configures the Windows host target for GN. It should allow
building unit tests for the host.

Change-Id: Ib92c9a83b9b858a9b7ed55487199c63896580af1
2020-01-22 13:54:15 -08:00
Alexei Frolov
aad92a9060
Windows host test runner script
This change adds a test runner script for a Windows host build.

Change-Id: I2bc983b245a6c4396cab4df9db9c9b7efcb30cce
2020-01-22 11:04:50 -08:00
Keir Mierle
da0bccb98f pw_unit_test: pw_log unit test event handler
This adds a pw_log based unit test event handler, and switches it to be
the default.

Change-Id: I83808e1e0ffcb0061644a45d4acc1d47f1161f57
2020-01-17 23:02:29 +00:00
Keir Mierle
af5e358b00 pw_log: Logging module first steps
This starts a logging module facade, with a frontend and a dumb IO based
backend. The initial version is lacking many features, like an API to
control enabling or disabling logs.

Change-Id: I3075aed33d9600a1190ca5237b5f7cfcfdc8f2ed
2020-01-17 12:42:05 -08:00
Alexei Frolov
799be5d81f Add docs target
This change moves building documentation out of the host and disco targets
into a special docs target.

The presubmit script is updated to handle the docs target.

Change-Id: I975170c9e8941d126d85a391c0f3b355e4fa44dd
2020-01-10 00:56:50 +00:00
Alexei Frolov
4905eae6f8 Make pw_build_host_tools a build arg in host build
This defines pw_build_host_tools as a GN build arg, allowing it to be
toggled without changing the host target.

Change-Id: I9b053b26e4deffc04885015c6981496bb857ee33
2020-01-10 00:24:00 +00:00
Alexei Frolov
213060fd22
Move pw_build_host_tools var to host_common.gni
This change moves the pw_build_host_tools variable from host.gni to
host_common.gni, where it belongs.

Change-Id: I8f7188900344d9ce7cff33a99b8725d5347b9b02
2020-01-02 15:00:26 -08:00
Alexei Frolov
ca9cf604dc Add pw_host_tool GN template
This change cerates a GN template called pw_host_tool which copies a
binary target to a common host_tools directory that can be added to a
user's PATH.

Change-Id: I9eb38ab4ff9d11a4a87e6be2547d5224370e3412
2019-12-26 21:58:46 +00:00
Alexei Frolov
3fde6b116f pw_toolchain_size_report template
This change adds a GN template which creates a size report card across
a set of different toolchains. The toolchains are defined in a build
variable, each with an optional linker script and Bloaty config. The
size report template builds a base and diff executable with each of the
toolchains and compares the size difference of each.

Example output for the host target:

             simple_bloat_toolchain
             ──────────────────────
┌───────────┬─────────┬────────┬───────┬───────┐
│   Label   │ Segment │ Before │ Delta │ After │
├═══════════┼═════════┼════════┼═══════┼═══════┤
│   gcc -Og │    CODE │    413 │   +32 │   445 │
│           │     RAM │    576 │    +8 │   584 │
├───────────┼─────────┼────────┼───────┼───────┤
│   gcc -Os │    CODE │    429 │   +16 │   445 │
│           │     RAM │    576 │    +8 │   584 │
├───────────┼─────────┼────────┼───────┼───────┤
│   gcc -O2 │    CODE │    429 │   +32 │   461 │
│           │     RAM │    576 │    +8 │   584 │
├───────────┼─────────┼────────┼───────┼───────┤
│ clang -Og │    CODE │    448 │   +32 │   480 │
│           │     RAM │    113 │   +15 │   128 │
├───────────┼─────────┼────────┼───────┼───────┤
│ clang -Os │    CODE │    432 │   +16 │   448 │
│           │     RAM │    113 │   +15 │   128 │
├───────────┼─────────┼────────┼───────┼───────┤
│ clang -O2 │    CODE │    448 │   +80 │   528 │
│           │     RAM │    113 │   +15 │   128 │
└───────────┴─────────┴────────┴───────┴───────┘

Change-Id: I2c65f4d4f61354b9779628f207297eacd04470b9
2019-12-23 20:37:42 +00:00
Alexei Frolov
8403f0a2db Update test runner to run tests from metadata
This change adds functionality to the test runner script to search a
directory tree for generated test metadata files, build up a graph of
test groups, and run a user-specified list of groups with all of their
dependencies.

Tests are run through an external runner executable provided on the
command line. The executable is called with the path to a unit test
binary file.

The old test runner functionality to run a single test directly from its
binary path is maintained, but now uses a runner executable. This is
configured in GN using the build variable "pw_automatic_test_runner",
which replaces the functionality of "pw_unit_test_create_run_targets".

Change-Id: Ic1ed959d87a71266408e1f26e0ae1bf906eebfb0
2019-11-22 17:58:51 +00:00
Keir Mierle
49caa10484 Fix macOS build by adding bloaty config
This fixes the macOS host build by adding a bloaty config. However, the
bloaty config isn't quite right; followup work will be needed to decide
if it makes sense to have Mach-O bloat reports.

Change-Id: I4148c85d73a1b8dbd02b1772688259dbe59e950e
2019-11-20 22:38:17 +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
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
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
Alexei Frolov
e899dcf4a3 Start build target config files
This change defines the build target system used by Pigweed, where the
build is configured using per-target globals imported from a target .gni
file. A single build arg specifying the path to the target file replaces
the previous args.

A default build variables file is provided in the Pigweed root. This
file defines and documents all of the build variables used by Pigweed.

A top-level targets directory is added to define the targets used by
Pigweed developers. Currently, only a "host" target is added, which
configures the build for a development system based on the host OS.

Change-Id: Ie62b8d41e5789bfe7fffe20462160142c79076c4
2019-11-14 00:34:25 +00:00