Commit Graph

26 Commits

Author SHA1 Message Date
Scott James Remnant
81713a33a0 pw_boot_cortex_m: Rename pw_boot_armv7m to pw_boot_cortex_m:armv7m
Since the implementation is closer to a generic Cortex-M implementation,
rename pw_boot_armv7m to pw_boot_cortex_m, and add a core-specific
target named "armv7m".

This matches pw_cpu_exception_cortex_m.

Toolchain definitions will need ot be changed from:
  pw_boot_BACKEND = dir_pw_boot_armv7m
to
  pw_boot_BACKEND = "$dir_pw_boot_cortex_m:arm7vm"

Change-Id: Id6f4bbf8e6c1ec89afa63de7c93be1f3afa59f09
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/54242
Commit-Queue: Scott James Remnant <keybuk@google.com>
Pigweed-Auto-Submit: Scott James Remnant <keybuk@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2021-07-23 02:00:37 +00:00
Akira Baruah
40a9c3f128 bazel: Rename BUILD to BUILD.bazel
Avoids potential naming conflicts with other build systems.

Change-Id: Ib6569cc05c028d5680879724304b17dfc1fae0af
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/49306
Commit-Queue: Akira Baruah <akirabaruah@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
Reviewed-by: Nathaniel Brough <nathaniel.brough@gmail.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2021-07-14 19:36:41 +00:00
Rob Mohr
5fc2541e8a bazel: Remove unnecessary license comments
We get warnings when these are imported into google3.

Change-Id: I8daaef65c3ae35d81e75815460d659b53c122ee3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/50580
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Keir Mierle <keir@google.com>
2021-06-29 15:37:52 +00:00
Michael Spang
c8b939009b Remove absolute paths from build command lines
The GN convention is to specify paths in command lines relative to the
build directory. Unfortunately and contrary to pigweed's expectations
this is not what rebase_path(path) does; that outputs an absolute path.

Absolute paths are not desirable in most circumstances as they contain
sources of nondeterminism such as the developer's home directory. Using
them can for example reduce hit rate in build caches.

Replace rebase_path(path) with rebase_path(path, root_build_dir) which
is the correct idiom and matches GN's builtin behavior (e.g. for
sources, include_dirs, etc).

This also removes the --directory argument to python_action(). Changing
the directory during the build while using relative paths is likely to
result in confusion and should be discouraged.

There's a couple more things to do on top of this for identical
binaries between build directories / machines / developers:

- pass options to avoid embedding the working directory
- pass options to use relative paths for the vendored clang & libc++

See [1]-[2] for how to do that.

[1] https://source.chromium.org/chromium/chromium/src/+/main:build/config/compiler/BUILD.gn;l=1170-1239;drc=ab531c265c533cba1c2f6d8240cc0bf7679f605a
[2] https://cs.opensource.google/fuchsia/fuchsia/+/main:build/config/BUILD.gn;l=145-216;drc=f6d705f0937c778d5d5f807a4580113612b02f5a

Change-Id: I17708102c03d6488d68c8571b6e9343191fd47de
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/47461
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Michael Spang <spang@google.com>
2021-06-09 19:15:51 +00:00
Prashanth Swaminathan
f605f2d2ed pw_sync_baremetal: Add simple mutex implementation
Adds a dummy mutex implementation for baremetal configurations.

The provided implementation makes a single attempt to acquire the
lock and asserts if it is unavailable. It does not perform interrupt
masking or disable global interrupts, so this implementation does
not support simultaneous multi-threaded environments including IRQs,
and is only meant to prevent data corruption.

Change-Id: Id122f890a37822c3b752b810e0e687f19f8c9dbd
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/45721
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Prashanth Swaminathan <prashanthsw@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
2021-05-18 17:55:29 +00:00
Ewout van Bekkum
eac9440445 pw_log: Migrate pw_log facade to use link deps like pw_assert
Migrates pw_log to use pw_build_LINK_DEPS w/ require_link_deps.

Updates the upstream log backends to refactor them accordingly.

Also updates the targets to pull in both assert and log through
pw_build_LINK_DEPS.

Note this does not yet move the actual impls, which is blocked by
migrating all users to use pw_build_LINK_DEPS for logging.

Change-Id: I17a4647e2ce2341b8cea6ee5c11cd1227a324c83
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/44147
Reviewed-by: Armando Montanez <amontanez@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
2021-05-12 19:06:36 +00:00
Wyatt Hepler
6166322c2e pw_build: pw_facade require_link_deps arg
- Make the pw_build_LINK_DEPS check in pw_assert a generic feature in
  pw_facade.
- Use "impl" instead of "deps" for the pw_assert dependencies and
  restructure the impl / backend split.

Change-Id: I75c0f7e67b3b97bfe333760897223ab4601649c0
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/43980
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
2021-05-07 17:54:44 +00:00
Wyatt Hepler
8bd4fb003c pw_build: Support specifying final link dependencies
- pw_build_LINK_DEPS is a list of build targets that are linked into
  all build artifacts produced by pw_executable, pw_static_library, and
  pw_shared_library.
- Add a ":deps" group to the pw_assert build interface. Require
  $dir_pw_assert:deps to be listed in pw_build_LINK_DEPS if
  pw_assert_BACKEND is set.

Change-Id: Icc01dbe86f95d971e76aa357c7b7174ce85546ba
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/43521
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
2021-05-04 22:30:42 +00:00
Nathaniel Brough
a1113be66c workspace: Adding bazel build formatter/linter
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>
2021-04-18 18:56:15 +00:00
Ewout van Bekkum
da2a62d890 pw_sync: Migrate upstream to use InterruptSpinLock
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>
2021-03-12 21:16:44 +00:00
Ewout van Bekkum
126e01176c pw_sync: rename SpinLock -> InterruptSpinLock
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>
2021-03-12 20:52:04 +00:00
Prashanth Swaminathan
325319fd63 arduino: Add baremetal sync backend
Resolve build breakage by installing baremetal backend for spin lock.

Change-Id: I1bc4caa899266677413fd51213e80557382af33e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/31501
Pigweed-Auto-Submit: Prashanth Swaminathan <prashanthsw@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
2021-02-01 20:08:51 +00:00
Anthony DiGirolamo
383be05904 pw_package: Arduino core installers and teensy presubmit
Summary of Changes
==================
1. Rename arduino build args to support cores in any location and have
   consistent naming.
2. Update docs to reflect above.
3. `pw package install teensy` working with nice status message on how
   to use ge pw_arduino_build_* args.
4. Added gn_teensy_build presubmit test step, not run by default.
   `pw presubmit --step gn_teensy_build`
5. Added missing system_rpc_server impl for //targets/arduino. This is
   just a copy of the stm32f429i one.

Build arg Change Examples
=========================

OLD:
    dir_pw_third_party_arduino = "//third_party/arduino"
    arduino_core_name = "teensy"
    arduino_package_name = "teensy/avr"
    arduino_board = "teensy41"
    arduino_menu_options = ["menu.usb.serial",
                            "menu.opt.o2std"]
NEW:
    pw_arduino_build_CORE_PATH =
      "/mnt/pigweed/pigweed/.environment/packages"
    pw_arduino_build_CORE_NAME = "teensy"
    pw_arduino_build_PACKAGE_NAME = "teensy/avr"
    pw_arduino_build_BOARD = "teensy41"
    pw_arduino_build_MENU_OPTIONS = ["menu.usb.serial",
                                     "menu.opt.o2std"]

All BUILD.gn checks for enabled arduino builds changed too:

OLD:
    if (dir_pw_third_party_arduino != "") {}
NEW:
    if (pw_arduino_build_CORE_PATH != "") {}

All gn target deps on arduino core sources changed.

OLD:
    "$dir_pw_third_party_arduino:arduino_core_sources",
NEW:
    "$dir_pw_third_party/arduino:arduino_core_sources",

Teensy package post install & status message
============================================

$ pw package status teensy

20210114 11:58:18 INF teensy is installed.
20210114 11:58:18 INF teensy currently installed in:
  /mnt/pigweed/pigweed/.environment/packages/teensy
20210114 11:58:18 INF Enable by running "gn args out" and adding
these lines:
  pw_arduino_build_CORE_PATH =
    "/mnt/pigweed/pigweed/.environment/packages"
  pw_arduino_build_CORE_NAME = "teensy"
  pw_arduino_build_PACKAGE_NAME = "teensy/avr"
  pw_arduino_build_BOARD = "BOARD_NAME"
20210114 11:58:18 INF Where BOARD_NAME is any supported board.
20210114 11:58:18 INF List available boards by running:
  arduino_builder
  --arduino-package-path
    /mnt/pigweed/pigweed/.environment/packages/teensy
  --arduino-package-name teensy/avr
  list-boards

Requires: pigweed:29490
Change-Id: Ifd0bd214777392a29af3ab24711edf2f2c1086f3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/26240
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
2021-01-22 16:28:36 +00:00
Anthony DiGirolamo
14f3a06a42 pw_arduino_build: Teensy and stm32duino fixes
- Switch teensy core to 1.53 release
- Add patching mechanism
- Add patch to fix teensy core cpp17 compatibility.
  Contains these commits:
  - https://github.com/PaulStoffregen/cores/commit/a8046bb
  - https://github.com/PaulStoffregen/cores/commit/914219e
  - https://github.com/PaulStoffregen/cores/commit/1f3f914
  - a patch to make flash_* functions non-static for teensy4
- Add delete message for downloads that fail checksums
- stm32duino: Always include built-in SrcWrapper library

Change-Id: Ib9e98de1bafbb81473cc7a350d8abb60a654e64f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/27620
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>
2021-01-13 18:07:17 +00:00
Wyatt Hepler
cb9a892446 pw_sys_io: Move sys_io's build arg to a .gni file
Change-Id: I1a6e7aed6c5720c60d1c224558c2913fe4d648a5
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/27940
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-12-17 01:32:38 +00:00
Anthony DiGirolamo
00e773eafb pw_arduino_build: Arduino library searching support
- Adds commands to return arduino library source files and include dirs.
- Example GN rule in targets/arduino/target_docs.rst
- Show error if a .elf doesn't exist in the unit_test_runner

Change-Id: Ic317c5c061799a7e02fdad834c685d8cb37ba9ce
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23460
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: David Rogers <davidrogers@google.com>
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
2020-11-06 01:16:45 +00:00
Anthony DiGirolamo
efdd24002f pw_arduino_build: Remove duplicate c-flags from asm/cppflags
Teensy cores have cflags included in the asmflag and cppflag recipes.
This causes gn to effectively duplicate cflags when building asm and
cpp files. This CL adds --s-only-flags and --cpp-only-flags options
which remove cflags from each respectively.

Add --ld-lib-names option.
If --ld-libs returns: -larm_cortexM7lfsp_math -lm -lstdc++
Then --ld-lib-names returns: arm_cortexM7lfsp_math m stdc++

Add a --flash-only option to arduino_unit_test_runner.

Change-Id: I1906d6f846f12ceb8ca42c498a7b216e0e3ba7e2
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23086
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
2020-11-03 21:37:54 +00:00
Wyatt Hepler
e0575f7256 pw_build: Facade and configuration tweaks and docs
- Add documentation for facades and the pw_facade template.
- Document the module config pattern.
- Remove the need for the facade_name argument to pw_facade.

Change-Id: I77529583967cfdb4f47ee87313982b1259ca036e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22045
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-10-21 23:38:58 +00:00
Anthony DiGirolamo
62de81b268 pw_arduino_build: Fix Windows related issues
- Launch teensy installer with admin rights.
  subprocess.open doesn't exec with admin rights on windows
  which causes the TeensyduinoInstaller.exe to fail.

- Fix include path directory separator using pathlib.

Change-Id: I3fac7915a640ef66c0c3bdb4729e69cb250d5444
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22004
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2020-10-21 17:02:13 +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
Anthony DiGirolamo
c36af656df Arduino: unit_test_runner
- New unit test scripts
  - arduino_unit_test_runner
  - arduino_test_server
  - arduino_test_client
  - teensy_detector

- arduino_builder changes
  - '--config-file' loading and '--save-config' options
  - '--set-variable' option to set arduino recipe vars. This is used
    for passing vars to the teensyloader flash recipe.

- GN changes
  - exec_script(arduino_builder) calls will save config files to:
    ./out/arduino_debug/gen/arduino_builder_config.json
  - 'pw_arduino_use_test_server' gn build arg

The test_runner and test_server both require a options to
run properly, see targets/arduino/target_docs.rst for usage.

Change-Id: I118498c291d2fbb034faa372b9250f6a0783a478
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19220
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
2020-10-12 19:02:19 +00:00
Anthony DiGirolamo
50a196f8db Arduino: python cleanup
- Move code in arduinobuilder.py to their own modules:
  - __main__.py
  - builder.py
  - core_installer.py
  - file_operations.py
- New log.py module
- os.system -> subprocess.run
- Move --run-* args in the 'show' subcommand under the 'run' subcommand.
  This allows running multiple steps in the same invocation. For
  example, this will execute 3 steps:

  arduino_builder run \
                  --run-objcopy \
                  --run-postbuild \
                  --run-upload-command teensyloader

Change-Id: Ibe5493689f39aa6e6aaeecf5bc7065929111499d
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19143
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
2020-10-06 19:50:35 +00:00
Carlos Chinchilla
32358e57af Arduino: Set empty config if core is missing
Create an empty object of the same type as arduino_build when the
arduiro core is not specified.

Change-Id: Ia4cf3d19622ad2297f5d3d4220cb8ca8e894a8c5
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19741
Commit-Queue: Carlos Chinchilla <cachinchilla@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
2020-10-06 00:43:19 +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
Anthony DiGirolamo
9147aa0128 Arduino: main function wrapper
- Remove simple_printing_main_arduino.cc which used loop() and setup()
- Rename main() in arduino core sources to ArduinoMain()
- Define setup() and loop() in arduino_main_wrapper.cc and call pigweed
  main() in setup() after pw_arduino_Init();
- Switch to pw_unit_test_MAIN = "$dir_pw_unit_test:simple_printing_main"
  in //targets/arduino/target_toolchains.gni
- Add pw_arduino_build/public/pw_arduino_build/init.h facade
- Documentation!
- Fix bug in arduinobuilder.py when using an arduino core which uses
  only one sub-core folder.

Change-Id: I94630b25f6c914ef46bdb9c32e6ddb5154690045
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/18640
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
2020-09-25 23:05:41 +00:00
Anthony DiGirolamo
eea0d771a7 Arduino Pigweed Target
- New arduino pigweed target that uses gn build args to set arduino
  target board and specific build options.
- Add arduinobuilder.py (includes core installer for Linux/Mac/Windows)
- Working builds for Teensy 4.1, 4.0, 3.6, 3.5, 3.2

Change-Id: Ib751b5f92352ac3ec7fa649f444dc13efd080d12
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/18001
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
2020-09-21 20:28:18 +00:00