├── .clang-format ├── .gitignore ├── .gn ├── .pylintrc ├── AUTHORS ├── BUILD ├── BUILD.gn ├── BUILDCONFIG.gn ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── WORKSPACE ├── activate.bat ├── activate.sh ├── bootstrap.bat ├── bootstrap.sh ├── docs ├── BUILD ├── BUILD.gn ├── conf.py ├── embedded_cpp_guide.rst ├── getting_started.md ├── images │ ├── pw_env_setup_demo.gif │ ├── pw_presubmit_demo.gif │ ├── pw_status_test.png │ ├── pw_watch_build_demo.gif │ ├── pw_watch_on_device_demo.gif │ ├── pw_watch_test_demo.gif │ └── stm32f429i-disc1_connected.jpg ├── index.rst ├── module_guides.rst ├── module_structure.rst ├── style_guide.rst └── targets.rst ├── modules.gni ├── pw_assert ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── assert_test.c ├── assert_test.cc ├── docs.rst └── public │ └── pw_assert │ └── assert.h ├── pw_assert_basic ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── assert_basic.cc ├── docs.rst ├── public │ └── pw_assert_basic │ │ └── assert_basic.h └── public_overrides │ └── pw_assert_backend │ └── assert_backend.h ├── pw_base64 ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── base64.cc ├── base64_test.c ├── base64_test.cc ├── docs.rst └── public │ └── pw_base64 │ └── base64.h ├── pw_bloat ├── BUILD ├── BUILD.gn ├── base_main.cc ├── bloat.gni ├── bloat_this_binary.cc ├── docs.rst ├── examples │ ├── BUILD │ ├── BUILD.gn │ ├── simple_base.cc │ ├── simple_function.cc │ └── simple_loop.cc ├── public │ └── pw_bloat │ │ └── bloat_this_binary.h └── py │ ├── binary_diff.py │ ├── bloat.py │ ├── bloat_output.py │ ├── no_bloaty.py │ ├── no_toolchains.py │ └── setup.py ├── pw_boot_armv7m ├── BUILD ├── BUILD.gn ├── basic_armv7m.ld ├── bloaty_config.bloaty ├── core_init.c ├── docs.rst └── public │ └── pw_boot_armv7m │ └── boot.h ├── pw_build ├── BUILD ├── BUILD.gn ├── README.md ├── docs.rst ├── exec.gni ├── facade.gni ├── go.gni ├── host_tool.gni ├── input_group.gni ├── linker_script.gni ├── pigweed.bzl ├── pigweed.cmake ├── pw_executable.gni ├── py │ ├── exec.py │ ├── host_tool.py │ ├── nop.py │ ├── null_backend.py │ └── python_runner.py └── python_script.gni ├── pw_checksum ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── ccitt_crc16.cc ├── ccitt_crc16_test.c ├── ccitt_crc16_test.cc ├── docs.rst └── public │ └── pw_checksum │ └── ccitt_crc16.h ├── pw_cli ├── BUILD.gn ├── README.md ├── docs.rst └── py │ ├── pw_cli │ ├── __init__.py │ ├── __main__.py │ ├── color.py │ ├── env.py │ ├── envparse.py │ ├── envparse_test.py │ ├── log.py │ ├── plugins.py │ └── process.py │ └── setup.py ├── pw_containers ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── docs.rst ├── public │ └── pw_containers │ │ └── vector.h └── vector_test.cc ├── pw_cpu_exception ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── docs.rst └── public │ └── pw_cpu_exception │ └── cpu_exception.h ├── pw_cpu_exception_armv7m ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── cpu_exception_entry.cc ├── cpu_state.cc ├── docs.rst ├── exception_entry_test.cc └── public │ └── pw_cpu_exception_armv7m │ └── cpu_state.h ├── pw_docgen ├── BUILD ├── BUILD.gn ├── docs.gni ├── docs.rst └── py │ └── docgen.py ├── pw_doctor ├── BUILD ├── BUILD.gn ├── README.md ├── docs.rst └── py │ ├── pw_doctor │ ├── __init__.py │ ├── doctor.py │ └── pw_plugin.py │ └── setup.py ├── pw_env_setup ├── BUILD.gn ├── docs.rst └── py │ ├── pw_env_setup │ ├── __init__.py │ ├── cargo_setup │ │ ├── __init__.py │ │ └── packages.txt │ ├── cipd_setup │ │ ├── .cipd_version │ │ ├── .cipd_version.digests │ │ ├── __init__.py │ │ ├── luci.json │ │ ├── pigweed.json │ │ ├── update.py │ │ └── wrapper.py │ ├── colors.py │ ├── env_setup.py │ ├── environment.py │ ├── environment_test.py │ ├── spinner.py │ ├── virtualenv_setup │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── install.py │ │ ├── requirements.in │ │ └── requirements.txt │ └── windows_env_start.py │ └── setup.py ├── pw_kvs ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── alignment.cc ├── alignment_test.cc ├── checksum.cc ├── checksum_test.cc ├── debug_cli.cc ├── docs.rst ├── entry.cc ├── entry_cache.cc ├── entry_cache_test.cc ├── entry_test.cc ├── flash_memory.cc ├── format.cc ├── in_memory_fake_flash.cc ├── key_value_store.cc ├── key_value_store_binary_format_test.cc ├── key_value_store_fuzz_test.cc ├── key_value_store_map_test.cc ├── key_value_store_test.cc ├── public │ └── pw_kvs │ │ ├── alignment.h │ │ ├── checksum.h │ │ ├── crc16_checksum.h │ │ ├── flash_memory.h │ │ ├── format.h │ │ ├── in_memory_fake_flash.h │ │ ├── internal │ │ ├── entry.h │ │ ├── entry_cache.h │ │ ├── hash.h │ │ ├── key_descriptor.h │ │ ├── sector_descriptor.h │ │ └── span_traits.h │ │ ├── io.h │ │ └── key_value_store.h └── pw_kvs_private │ ├── byte_utils.h │ └── macros.h ├── pw_log ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── basic_log_test.cc ├── basic_log_test_plain_c.c ├── docs.rst └── public │ └── pw_log │ ├── levels.h │ └── log.h ├── pw_log_basic ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── docs.rst ├── log_basic.cc ├── public │ └── pw_log_basic │ │ └── log_basic.h └── public_overrides │ └── pw_log_backend │ └── log_backend.h ├── pw_minimal_cpp_stdlib ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── docs.rst ├── public │ ├── algorithm │ ├── array │ ├── cinttypes │ ├── cmath │ ├── cstdarg │ ├── cstddef │ ├── cstdint │ ├── cstdio │ ├── cstring │ ├── initializer_list │ ├── internal │ │ ├── algorithm.h │ │ ├── array.h │ │ ├── cinttypes.h │ │ ├── cmath.h │ │ ├── cstdarg.h │ │ ├── cstddef.h │ │ ├── cstdint.h │ │ ├── cstdio.h │ │ ├── cstring.h │ │ ├── initializer_list.h │ │ ├── iterator.h │ │ ├── limits.h │ │ ├── new.h │ │ ├── string_view.h │ │ ├── type_traits.h │ │ └── utility.h │ ├── iterator │ ├── limits │ ├── new │ ├── string_view │ ├── type_traits │ └── utility └── test.cc ├── pw_module ├── BUILD.gn ├── README.md ├── docs.rst └── py │ ├── check_test.py │ ├── pw_module │ ├── __init__.py │ └── check.py │ └── setup.py ├── pw_polyfill ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── docs.rst ├── public │ └── pw_polyfill │ │ ├── language_features.h │ │ └── standard.h ├── public_overrides │ ├── assert.h │ ├── cstddef │ ├── iterator │ └── type_traits ├── standard_library_public │ └── pw_polyfill │ │ └── standard_library │ │ ├── assert.h │ │ ├── cstddef.h │ │ ├── iterator.h │ │ └── type_traits.h └── test.cc ├── pw_preprocessor ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── boolean_test.cc ├── concat_test.cc ├── docs.rst ├── macro_arg_count_test.cc ├── public │ └── pw_preprocessor │ │ ├── boolean.h │ │ ├── compiler.h │ │ ├── concat.h │ │ ├── macro_arg_count.h │ │ └── util.h └── util_test.cc ├── pw_presubmit ├── BUILD.gn ├── README.md ├── docs.rst └── py │ ├── pw_presubmit │ ├── __init__.py │ ├── format_code.py │ ├── install_hook.py │ ├── pigweed_presubmit.py │ ├── pw_plugin.py │ ├── python_checks.py │ └── tools.py │ └── setup.py ├── pw_protobuf ├── BUILD ├── BUILD.gn ├── README.md ├── codegen_test.cc ├── decoder.cc ├── decoder_test.cc ├── decoding.rst ├── docs.rst ├── encoder.cc ├── encoder_test.cc ├── public │ └── pw_protobuf │ │ ├── codegen.h │ │ ├── decoder.h │ │ ├── encoder.h │ │ └── wire_format.h ├── pw_protobuf_protos │ └── test_protos │ │ ├── full_test.proto │ │ ├── proto2.proto │ │ └── repeated.proto ├── py │ ├── pw_protobuf │ │ ├── codegen.py │ │ ├── methods.py │ │ └── proto_structures.py │ └── setup.py └── size_report │ ├── BUILD.gn │ ├── decoder_full.cc │ └── decoder_incremental.cc ├── pw_protobuf_compiler ├── BUILD.gn ├── README.md ├── docs.rst ├── proto.gni └── py │ ├── pw_protobuf_compiler │ ├── generate_protos.py │ └── proto_target_invalid.py │ └── setup.py ├── pw_span ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── docs.rst ├── public │ └── pw_span │ │ └── span.h └── span_test.cc ├── pw_status ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── docs.rst ├── public │ └── pw_status │ │ ├── status.h │ │ └── status_with_size.h ├── status.cc ├── status_test.c ├── status_test.cc └── status_with_size_test.cc ├── pw_string ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── docs.rst ├── format.cc ├── format_test.cc ├── public │ └── pw_string │ │ ├── format.h │ │ ├── string_builder.h │ │ ├── to_string.h │ │ ├── type_to_string.h │ │ └── util.h ├── size_report │ ├── BUILD │ ├── BUILD.gn │ ├── format_many_without_error_handling.cc │ ├── format_multiple.cc │ ├── format_single.cc │ ├── string_builder_size_report.cc │ └── string_builder_size_report_incremental.cc ├── string_builder.cc ├── string_builder_test.cc ├── to_string_test.cc ├── type_to_string.cc ├── type_to_string_test.cc └── util_test.cc ├── pw_sys_io ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── docs.rst ├── public │ └── pw_sys_io │ │ └── sys_io.h └── sys_io.cc ├── pw_sys_io_baremetal_stm32f429 ├── BUILD ├── BUILD.gn ├── docs.rst └── sys_io_baremetal.cc ├── pw_sys_io_stdio ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── docs.rst └── sys_io.cc ├── pw_target_runner ├── BUILD.gn ├── docs.rst ├── go │ ├── BUILD.gn │ ├── docs.rst │ └── src │ │ └── pigweed.dev │ │ ├── pw_target_runner │ │ ├── BUILD.gn │ │ ├── exec_runner.go │ │ ├── server.go │ │ └── worker_pool.go │ │ ├── pw_target_runner_client │ │ ├── BUILD.gn │ │ └── main.go │ │ └── pw_target_runner_server │ │ ├── BUILD.gn │ │ ├── example_config.txt │ │ └── main.go └── pw_target_runner_protos │ ├── exec_server_config.proto │ └── target_runner.proto ├── pw_tokenizer ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── argument_types_test.c ├── argument_types_test.cc ├── base64.cc ├── base64_test.cc ├── decode.cc ├── decode_test.cc ├── detokenize.cc ├── detokenize_test.cc ├── docs.rst ├── generate_decoding_test_data.cc ├── hash_test.cc ├── java │ └── dev │ │ └── pigweed │ │ └── tokenizer │ │ ├── Detokenizer.java │ │ └── detokenizer.cc ├── public │ └── pw_tokenizer │ │ ├── base64.h │ │ ├── config.h │ │ ├── detokenize.h │ │ ├── internal │ │ ├── argument_types.h │ │ ├── argument_types_macro_4_byte.h │ │ ├── argument_types_macro_8_byte.h │ │ ├── decode.h │ │ ├── pw_tokenizer_65599_fixed_length_128_hash_macro.h │ │ ├── pw_tokenizer_65599_fixed_length_80_hash_macro.h │ │ ├── pw_tokenizer_65599_fixed_length_96_hash_macro.h │ │ └── tokenize_string.h │ │ ├── pw_tokenizer_65599_fixed_length_hash.h │ │ ├── token_database.h │ │ └── tokenize.h ├── pw_tokenizer_private │ ├── argument_types_test.h │ ├── generated_hash_test_cases.h │ ├── tokenize_test.h │ ├── tokenized_string_decoding_test_data.h │ └── varint_decoding_test_data.h ├── py │ ├── decoder_test.py │ ├── detokenize_test.py │ ├── elf_reader_test.py │ ├── elf_reader_test_binary.c │ ├── elf_reader_test_binary.elf │ ├── generate_argument_types_macro.py │ ├── generate_hash_macro.py │ ├── generate_hash_test_data.py │ ├── pw_tokenizer │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── database.py │ │ ├── decoder.py │ │ ├── detokenize.py │ │ ├── elf_reader.py │ │ └── tokens.py │ ├── setup.py │ ├── tokenized_string_decoding_test_data.py │ ├── tokens_test.py │ └── varint_decoding_test_data.py ├── simple_tokenize_test.cc ├── token_database.cc ├── token_database_test.cc ├── tokenize.cc ├── tokenize_test.c ├── tokenize_test.cc └── tokenizer_linker_sections.ld ├── pw_toolchain ├── BUILD ├── BUILD.gn ├── README.md ├── arm_gcc.gni ├── docs.rst ├── host_clang.gni └── host_gcc.gni ├── pw_unit_test ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── docs.rst ├── framework.cc ├── framework_test.cc ├── logging_event_handler.cc ├── logging_main.cc ├── public │ └── pw_unit_test │ │ ├── event_handler.h │ │ ├── framework.h │ │ ├── logging_event_handler.h │ │ └── simple_printing_event_handler.h ├── public_overrides │ └── gtest │ │ └── gtest.h ├── py │ ├── pw_unit_test │ │ ├── __init__.py │ │ └── test_runner.py │ └── setup.py ├── simple_printing_event_handler.cc ├── simple_printing_main.cc └── test.gni ├── pw_varint ├── BUILD ├── BUILD.gn ├── CMakeLists.txt ├── README.md ├── docs.rst ├── public │ └── pw_varint │ │ └── varint.h ├── varint.cc ├── varint_test.c └── varint_test.cc ├── pw_vars_default.gni ├── pw_watch ├── BUILD.gn ├── README.md ├── doc_resources │ └── pw_watch_on_device_demo.gif ├── docs.rst └── py │ ├── pw_watch │ ├── __init__.py │ ├── debounce.py │ └── watch.py │ └── setup.py └── targets ├── docs ├── BUILD.gn ├── empty.bloaty ├── target_config.gni └── target_docs.rst ├── host ├── BUILD.gn ├── host_common.gni ├── linux.bloaty ├── linux.gni ├── macos.bloaty ├── macos.gni ├── run_test ├── run_test.bat ├── target_config.gni ├── target_docs.rst └── windows.gni └── stm32f429i-disc1 ├── BUILD.gn ├── py ├── setup.py └── stm32f429i_disc1_utils │ ├── __init__.py │ ├── openocd_stm32f4xx.cfg │ ├── stm32f429i_detector.py │ ├── unit_test_client.py │ ├── unit_test_runner.py │ └── unit_test_server.py ├── target_config.gni └── target_docs.rst /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | BinPackArguments: false 3 | BinPackParameters: false 4 | DerivePointerAlignment: false 5 | PointerAlignment: Left 6 | AllowShortIfStatementsOnASingleLine: false 7 | AllowShortLoopsOnASingleLine: false 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build 2 | compile_commands.json 3 | out/ 4 | bazel-* 5 | .presubmit/ 6 | 7 | # Editors 8 | .idea/ 9 | .project 10 | .cproject 11 | .vscode 12 | .clangd/ 13 | *.swp 14 | *.swo 15 | 16 | # Python 17 | python*-env/ 18 | .python*-env/ 19 | venv/ 20 | *.pyc 21 | *.egg/ 22 | *.eggs/ 23 | *.egg-info/ 24 | .cache/ 25 | .mypy_cache/ 26 | __pycache__/ 27 | 28 | # Mac 29 | .DS_Store 30 | 31 | # GDB 32 | .gdb_history 33 | 34 | # Git 35 | *.orig 36 | *.BACKUP.* 37 | *.BASE.* 38 | *.LOCAL.* 39 | *.REMOTE.* 40 | *_BACKUP_*.txt 41 | *_BASE_*.txt 42 | *_LOCAL_*.txt 43 | *_REMOTE_*.txt 44 | 45 | # Env Setup 46 | pw_env_setup/.env_setup.sh 47 | pw_env_setup/.env_setup.bat 48 | .cipd 49 | .cargo 50 | -------------------------------------------------------------------------------- /.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | buildconfig = "//BUILDCONFIG.gn" 16 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the list of Pigweed authors for copyright purposes. 2 | # 3 | # This does not necessarily list everyone who has contributed code, since in 4 | # some cases, their employer may be the copyright holder. To see the full list 5 | # of contributors, see the revision history in source control. 6 | 7 | Google LLC 8 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | licenses(["notice"]) # Apache License 2.0 16 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | project(Pigweed) 16 | 17 | cmake_minimum_required(VERSION 3.14) 18 | 19 | include(pw_build/pigweed.cmake) 20 | 21 | add_subdirectory(pw_assert) 22 | add_subdirectory(pw_assert_basic) 23 | add_subdirectory(pw_base64) 24 | add_subdirectory(pw_checksum) 25 | add_subdirectory(pw_containers) 26 | add_subdirectory(pw_cpu_exception) 27 | add_subdirectory(pw_cpu_exception_armv7m) 28 | add_subdirectory(pw_kvs) 29 | add_subdirectory(pw_log) 30 | add_subdirectory(pw_log_basic) 31 | add_subdirectory(pw_minimal_cpp_stdlib) 32 | add_subdirectory(pw_polyfill) 33 | add_subdirectory(pw_preprocessor) 34 | add_subdirectory(pw_span) 35 | add_subdirectory(pw_status) 36 | add_subdirectory(pw_string) 37 | add_subdirectory(pw_sys_io) 38 | add_subdirectory(pw_sys_io_stdio) 39 | add_subdirectory(pw_tokenizer) 40 | add_subdirectory(pw_unit_test) 41 | add_subdirectory(pw_varint) 42 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | -------------------------------------------------------------------------------- /activate.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: Copyright 2020 The Pigweed Authors 3 | :: 4 | :: Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | :: use this file except in compliance with the License. You may obtain a copy of 6 | :: the License at 7 | :: 8 | :: https://www.apache.org/licenses/LICENSE-2.0 9 | :: 10 | :: Unless required by applicable law or agreed to in writing, software 11 | :: distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | :: WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | :: License for the specific language governing permissions and limitations under 14 | :: the License. 15 | 16 | :: Activates a Pigweed development environment by setting the appropriate 17 | :: environment variables. bootstrap.bat must be run initially to install all 18 | :: required programs; after that, activate.bat can be used to enter the 19 | :: environment in a shell. 20 | 21 | set PW_SKIP_BOOTSTRAP=1 22 | call "%~dp0\bootstrap.bat" 23 | set PW_SKIP_BOOTSTRAP= 24 | -------------------------------------------------------------------------------- /activate.sh: -------------------------------------------------------------------------------- 1 | bootstrap.sh -------------------------------------------------------------------------------- /docs/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | # TODO(mohrr) figure out how to do this in bazel 16 | -------------------------------------------------------------------------------- /docs/images/pw_env_setup_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/izzimat/pigweed/0294627ff75924f627aee849eb021917f48b7628/docs/images/pw_env_setup_demo.gif -------------------------------------------------------------------------------- /docs/images/pw_presubmit_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/izzimat/pigweed/0294627ff75924f627aee849eb021917f48b7628/docs/images/pw_presubmit_demo.gif -------------------------------------------------------------------------------- /docs/images/pw_status_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/izzimat/pigweed/0294627ff75924f627aee849eb021917f48b7628/docs/images/pw_status_test.png -------------------------------------------------------------------------------- /docs/images/pw_watch_build_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/izzimat/pigweed/0294627ff75924f627aee849eb021917f48b7628/docs/images/pw_watch_build_demo.gif -------------------------------------------------------------------------------- /docs/images/pw_watch_on_device_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/izzimat/pigweed/0294627ff75924f627aee849eb021917f48b7628/docs/images/pw_watch_on_device_demo.gif -------------------------------------------------------------------------------- /docs/images/pw_watch_test_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/izzimat/pigweed/0294627ff75924f627aee849eb021917f48b7628/docs/images/pw_watch_test_demo.gif -------------------------------------------------------------------------------- /docs/images/stm32f429i-disc1_connected.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/izzimat/pigweed/0294627ff75924f627aee849eb021917f48b7628/docs/images/stm32f429i-disc1_connected.jpg -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-home: 2 | 3 | .. highlight:: sh 4 | 5 | .. mdinclude:: README.md 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | :hidden: 10 | 11 | Home 12 | docs/getting_started.md 13 | CODE_OF_CONDUCT.md 14 | CONTRIBUTING.md 15 | docs/embedded_cpp_guide 16 | docs/style_guide 17 | targets 18 | docs/module_structure 19 | module_guides 20 | -------------------------------------------------------------------------------- /docs/module_guides.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Module Guides 3 | ============= 4 | Pigweed is a collection of embedded-focused and embedded-related modules. 5 | Modules may contain code from multiple languages, including C, C++, Go, Rust, 6 | Shell, Batch and Python. 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | :glob: 11 | 12 | */docs 13 | -------------------------------------------------------------------------------- /docs/targets.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-targets: 2 | 3 | ======= 4 | Targets 5 | ======= 6 | Pigweed is designed to support many 32-bit targets. This section contains 7 | documentation for the targets used for upstream Pigweed development, 8 | though more may exist outside the main Pigweed repository. 9 | 10 | .. toctree:: 11 | :maxdepth: 1 12 | :glob: 13 | 14 | targets/*/target_docs 15 | -------------------------------------------------------------------------------- /pw_assert/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | "pw_cc_test", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | # TODO(pwbug/101): Need to add support for facades/backends to Bazel. 26 | PW_ASSERT_BACKEND = "//pw_assert_basic" 27 | 28 | pw_cc_library( 29 | name = "facade", 30 | hdrs = [ 31 | "public/pw_assert/assert.h", 32 | ], 33 | includes = ["public"], 34 | deps = [ 35 | "//pw_preprocessor", 36 | ], 37 | ) 38 | 39 | pw_cc_library( 40 | name = "pw_assert", 41 | deps = [ 42 | ":facade", 43 | PW_ASSERT_BACKEND, 44 | ], 45 | ) 46 | 47 | pw_cc_test( 48 | name = "test", 49 | srcs = [ 50 | "assert_test.cc", 51 | "assert_test.c", 52 | ], 53 | deps = [":pw_assert"], 54 | ) 55 | -------------------------------------------------------------------------------- /pw_assert/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/facade.gni") 16 | import("$dir_pw_docgen/docs.gni") 17 | import("$dir_pw_unit_test/test.gni") 18 | 19 | config("default_config") { 20 | include_dirs = [ "public" ] 21 | } 22 | 23 | pw_facade("pw_assert") { 24 | backend = dir_pw_assert_backend 25 | public_configs = [ ":default_config" ] 26 | public = [ "public/pw_assert/assert.h" ] 27 | public_deps = [ dir_pw_preprocessor ] 28 | } 29 | 30 | pw_test_group("tests") { 31 | tests = [] 32 | if (dir_pw_assert_backend != "") { 33 | tests += [ ":assert_test" ] 34 | } 35 | } 36 | 37 | if (dir_pw_assert_backend != "") { 38 | pw_test("assert_test") { 39 | deps = [ 40 | ":pw_assert", 41 | dir_pw_assert_backend, 42 | ] 43 | 44 | sources = [ 45 | "assert_test.c", 46 | "assert_test.cc", 47 | ] 48 | } 49 | } 50 | 51 | pw_doc_group("docs") { 52 | sources = [ "docs.rst" ] 53 | } 54 | -------------------------------------------------------------------------------- /pw_assert/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_add_facade(pw_assert 16 | PUBLIC_DEPS 17 | pw_preprocessor 18 | ) 19 | -------------------------------------------------------------------------------- /pw_assert_basic/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | ) 19 | 20 | package(default_visibility = ["//visibility:public"]) 21 | 22 | licenses(["notice"]) # Apache License 2.0 23 | 24 | pw_cc_library( 25 | name = "pw_assert_basic", 26 | srcs = [ 27 | "assert_basic.cc", 28 | ], 29 | hdrs = [ 30 | "public/pw_assert_basic/assert_basic.h", 31 | "public_overrides/pw_assert_backend/assert_backend.h", 32 | ], 33 | includes = [ 34 | "public", 35 | "public_overrides", 36 | ], 37 | deps = [ 38 | "//pw_assert:facade", 39 | "//pw_string", 40 | "//pw_sys_io", 41 | ], 42 | ) 43 | -------------------------------------------------------------------------------- /pw_assert_basic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_assert_basic 16 | IMPLEMENTS_FACADE 17 | pw_assert 18 | PRIVATE_DEPS 19 | pw_preprocessor 20 | pw_string 21 | pw_sys_io 22 | ) 23 | 24 | target_include_directories(pw_assert_basic PUBLIC public_overrides) 25 | 26 | # TODO(hepler): Declare pw_assert_basic as the pw_assert backend for now. 27 | add_library(pw_assert.backend INTERFACE) 28 | target_link_libraries(pw_assert.backend INTERFACE pw_assert_basic) 29 | -------------------------------------------------------------------------------- /pw_assert_basic/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-assert-basic: 2 | 3 | .. default-domain:: cpp 4 | 5 | .. highlight:: cpp 6 | 7 | =============== 8 | pw_assert_basic 9 | =============== 10 | 11 | -------- 12 | Overview 13 | -------- 14 | This is a simple assert backend to complement the ``pw_assert`` facade. 15 | 16 | -------------------------------------------------------------------------------- /pw_assert_basic/public_overrides/pw_assert_backend/assert_backend.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | // This override header merely points to the true backend, in this case the 16 | // basic one. The reason to redirect is to permit the use of multiple backends 17 | // (though only pw_assert/assert.h can only point to 1 backend). 18 | #pragma once 19 | 20 | #include "pw_assert_basic/assert_basic.h" 21 | -------------------------------------------------------------------------------- /pw_base64/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | "pw_cc_test", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | pw_cc_library( 26 | name = "pw_base64", 27 | srcs = [ 28 | "base64.cc", 29 | ], 30 | hdrs = [ 31 | "public/pw_base64/base64.h", 32 | ], 33 | includes = ["public"], 34 | deps = [ 35 | "//pw_span", 36 | ], 37 | ) 38 | 39 | pw_cc_test( 40 | name = "base64_test", 41 | srcs = [ 42 | "base64_test.c", 43 | "base64_test.cc", 44 | ], 45 | deps = [ 46 | ":pw_base64", 47 | ], 48 | ) 49 | -------------------------------------------------------------------------------- /pw_base64/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | import("$dir_pw_unit_test/test.gni") 17 | 18 | config("default_config") { 19 | include_dirs = [ "public" ] 20 | } 21 | 22 | source_set("pw_base64") { 23 | public_configs = [ ":default_config" ] 24 | public = [ "public/pw_base64/base64.h" ] 25 | sources = [ "base64.cc" ] 26 | sources += public 27 | public_deps = [ "$dir_pw_span" ] 28 | } 29 | 30 | pw_test_group("tests") { 31 | tests = [ ":base64_test" ] 32 | group_deps = [ "$dir_pw_span:tests" ] 33 | } 34 | 35 | pw_test("base64_test") { 36 | deps = [ ":pw_base64" ] 37 | sources = [ 38 | "base64_test.c", 39 | "base64_test.cc", 40 | ] 41 | } 42 | 43 | pw_doc_group("docs") { 44 | sources = [ "docs.rst" ] 45 | } 46 | -------------------------------------------------------------------------------- /pw_base64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_base64 16 | PUBLIC_DEPS 17 | pw_span 18 | ) 19 | -------------------------------------------------------------------------------- /pw_base64/base64_test.c: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | // These tests call the pw_base64 module API from C. The return values are 16 | // checked in the main C++ tests. 17 | // 18 | // The encoded / decoded size macros are tested in the main C++ tests. 19 | 20 | #include "pw_base64/base64.h" 21 | 22 | #include 23 | 24 | void pw_Base64CallEncode(const void* binary_data, 25 | const size_t binary_size_bytes, 26 | char* output) { 27 | return pw_Base64Encode(binary_data, binary_size_bytes, output); 28 | } 29 | 30 | size_t pw_Base64CallDecode(const char* base64, 31 | size_t base64_size_bytes, 32 | void* output) { 33 | return pw_Base64Decode(base64, base64_size_bytes, output); 34 | } 35 | 36 | bool pw_Base64CallIsValid(const char* base64_data, size_t base64_size) { 37 | return pw_Base64IsValid(base64_data, base64_size); 38 | } 39 | -------------------------------------------------------------------------------- /pw_base64/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-base64: 2 | 3 | .. default-domain:: cpp 4 | 5 | .. highlight:: sh 6 | 7 | --------- 8 | pw_base64 9 | --------- 10 | This module provides functions for encoding, decoding, and validating Base64 11 | data as specified by `RFC 3548 `_ and 12 | `RFC 4648 `_. 13 | 14 | .. note:: 15 | The documentation for this module is currently incomplete. 16 | -------------------------------------------------------------------------------- /pw_bloat/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_binary", 18 | "pw_cc_library", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | # Library which uses standard C/C++ functions such as memcpy to prevent them 26 | # from showing up within bloat diff reports. 27 | pw_cc_library( 28 | name = "bloat_this_binary", 29 | srcs = ["bloat_this_binary.cc"], 30 | hdrs = ["public/pw_bloat/bloat_this_binary.h"], 31 | includes = ["public"], 32 | ) 33 | 34 | # Standard minimal base binary for bloat reports. 35 | pw_cc_binary( 36 | name = "bloat_base", 37 | srcs = ["base_main.cc"], 38 | deps = [":bloat_this_binary"], 39 | ) 40 | -------------------------------------------------------------------------------- /pw_bloat/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/pw_executable.gni") 16 | import("$dir_pw_docgen/docs.gni") 17 | import("bloat.gni") 18 | 19 | config("default_config") { 20 | include_dirs = [ "public" ] 21 | } 22 | 23 | # Library which uses standard C/C++ functions such as memcpy to prevent them 24 | # from showing up within bloat diff reports. 25 | source_set("bloat_this_binary") { 26 | public_configs = [ ":default_config" ] 27 | public = [ "public/pw_bloat/bloat_this_binary.h" ] 28 | sources = [ "bloat_this_binary.cc" ] + public 29 | } 30 | 31 | # Standard minimal base binary for bloat reports. 32 | pw_executable("bloat_base") { 33 | forward_variables_from(pw_bloat_empty_base, "*") 34 | } 35 | 36 | pw_doc_group("docs") { 37 | sources = [ "docs.rst" ] 38 | report_deps = [ 39 | "examples:simple_bloat_function", 40 | "examples:simple_bloat_loop", 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /pw_bloat/base_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #include "pw_bloat/bloat_this_binary.h" 16 | 17 | int main() { 18 | pw::bloat::BloatThisBinary(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /pw_bloat/examples/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load("//pw_build:pigweed.bzl", "pw_cc_binary") 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | licenses(["notice"]) # Apache License 2.0 20 | 21 | pw_cc_binary( 22 | name = "simple_base", 23 | srcs = ["simple_base.cc"], 24 | ) 25 | 26 | pw_cc_binary( 27 | name = "simple_loop", 28 | srcs = ["simple_loop.cc"], 29 | ) 30 | 31 | pw_cc_binary( 32 | name = "simple_function", 33 | srcs = ["simple_function.cc"], 34 | ) 35 | -------------------------------------------------------------------------------- /pw_bloat/examples/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("../bloat.gni") 16 | 17 | pw_toolchain_size_report("simple_bloat_loop") { 18 | base_executable = { 19 | sources = [ "simple_base.cc" ] 20 | } 21 | diff_executable = { 22 | sources = [ "simple_loop.cc" ] 23 | } 24 | } 25 | 26 | pw_toolchain_size_report("simple_bloat_function") { 27 | base_executable = { 28 | sources = [ "simple_base.cc" ] 29 | } 30 | diff_executable = { 31 | sources = [ "simple_function.cc" ] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /pw_bloat/examples/simple_base.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | // This is an overly-simplified main to serve as a base executable for the 16 | // example. Note that using a main like this directly as a base is not a good 17 | // idea because of over-reporting size increases due to standard functionality 18 | // like memmove; this is just to illustrate the most basic setup. 19 | int main(int argc, char** argv) { 20 | (void)argc; 21 | (void)argv; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /pw_bloat/examples/simple_function.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | char* volatile non_optimizable_pointer; 16 | 17 | int SimpleFunction() { return *non_optimizable_pointer; } 18 | 19 | int main(int argc, char** argv) { 20 | (void)argc; 21 | (void)argv; 22 | 23 | // Add function and call to this binary. 24 | *non_optimizable_pointer = SimpleFunction(); 25 | return SimpleFunction(); 26 | } 27 | -------------------------------------------------------------------------------- /pw_bloat/examples/simple_loop.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | char* volatile non_optimizable_pointer; 16 | 17 | int main(int argc, char** argv) { 18 | // Add a loop in this binary; see how much it adds. 19 | for (int i = 0; i < argc; ++i) { 20 | *non_optimizable_pointer += **argv; 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /pw_bloat/public/pw_bloat/bloat_this_binary.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #pragma once 16 | 17 | namespace pw::bloat { 18 | 19 | // Function providing fundamental C/C++ functions to prevent them from appearing 20 | // in size reports. Must be called in binaries which are compared to the bloat 21 | // base in order to get accurate reports. 22 | void BloatThisBinary(); 23 | 24 | } // namespace pw::bloat 25 | -------------------------------------------------------------------------------- /pw_bloat/py/no_bloaty.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Outputs a ReST message indicating that size reports don't work on Windows.""" 15 | 16 | import os 17 | import sys 18 | 19 | _NO_BLOATY_ERROR: str = ''' 20 | .. note:: 21 | 22 | The size reporting tool is not yet available on Windows systems. 23 | ''' 24 | 25 | 26 | def main() -> int: 27 | os.makedirs(os.path.dirname(sys.argv[1]), exist_ok=True) 28 | with open(sys.argv[1], 'w') as fd: 29 | fd.write(_NO_BLOATY_ERROR) 30 | return 0 31 | 32 | 33 | if __name__ == '__main__': 34 | sys.exit(main()) 35 | -------------------------------------------------------------------------------- /pw_bloat/py/no_toolchains.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Outputs a ReST warning about the size toolchains variable being empty.""" 15 | 16 | import os 17 | import sys 18 | 19 | _NO_TOOLCHAIN_ERROR: str = ''' 20 | .. warning:: 21 | 22 | The ``pw_size_report_toolchains`` build variable is empty for this target. 23 | Size reports will not be generated. 24 | 25 | See :ref:`bloat-howto` for details on how to set up size reports. 26 | ''' 27 | 28 | 29 | def main() -> int: 30 | os.makedirs(os.path.dirname(sys.argv[1]), exist_ok=True) 31 | with open(sys.argv[1], 'w') as fd: 32 | fd.write(_NO_TOOLCHAIN_ERROR) 33 | return 0 34 | 35 | 36 | if __name__ == '__main__': 37 | sys.exit(main()) 38 | -------------------------------------------------------------------------------- /pw_bloat/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """pw_bloat""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | """Test suite for pw_bloat module.""" 22 | return unittest.TestLoader().discover('./', pattern='*_test.py') 23 | 24 | 25 | setuptools.setup( 26 | name='pw_bloat', 27 | version='0.0.1', 28 | author='Pigweed Authors', 29 | author_email='pigweed-developers@googlegroups.com', 30 | description='Tools for generating binary size report cards', 31 | packages=setuptools.find_packages(), 32 | test_suite='setup.test_suite', 33 | ) 34 | -------------------------------------------------------------------------------- /pw_boot_armv7m/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) # Apache License 2.0 18 | 19 | filegroup( 20 | name = "pw_boot_armv7m", 21 | srcs = [ 22 | "core_init.c", 23 | "public/pw_boot_armv7m/boot.h", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /pw_boot_armv7m/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/linker_script.gni") 16 | import("$dir_pw_docgen/docs.gni") 17 | 18 | if (dir_pw_boot_backend == dir_pw_boot_armv7m) { 19 | config("default_config") { 20 | include_dirs = [ "public" ] 21 | } 22 | 23 | pw_linker_script("armv7m_linker_script") { 24 | # pw_boot_armv7m_config is a scope provided by the target. 25 | assert(defined(pw_boot_armv7m_config), 26 | "pw_boot_armv7m depends on pw_boot_armv7m_config being defined!") 27 | defines = pw_boot_armv7m_config.defines 28 | linker_script = "basic_armv7m.ld" 29 | } 30 | 31 | source_set("pw_boot_armv7m") { 32 | public_configs = [ ":default_config" ] 33 | deps = [ 34 | ":armv7m_linker_script", 35 | "$dir_pw_preprocessor", 36 | ] 37 | public = [ "public/pw_boot_armv7m/boot.h" ] 38 | sources = [ "core_init.c" ] + public 39 | } 40 | } 41 | 42 | pw_doc_group("docs") { 43 | sources = [ "docs.rst" ] 44 | } 45 | -------------------------------------------------------------------------------- /pw_boot_armv7m/bloaty_config.bloaty: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | source_filter: "^(FLASH|RAM)$" 16 | 17 | custom_data_source: { 18 | name: "segment_names" 19 | base_data_source: "segments" 20 | 21 | rewrite: { 22 | pattern: "LOAD #1" 23 | replacement: "FLASH" 24 | } 25 | rewrite: { 26 | pattern: "LOAD #2" 27 | replacement: "RAM" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pw_build/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) # Apache License 2.0 18 | -------------------------------------------------------------------------------- /pw_build/README.md: -------------------------------------------------------------------------------- 1 | # pw\_build: Definitions for Pigweed's build system 2 | -------------------------------------------------------------------------------- /pw_build/input_group.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("python_script.gni") 16 | 17 | # Creates an action that doesn't do anything that depends on a list of input 18 | # files. This allows modifications to these files to trigger targets depending 19 | # on this group to rebuild. 20 | # 21 | # This is typically used for targets that don't output any artifacts (e.g. 22 | # metadata-only targets) which list input files relevant to the build. 23 | template("pw_input_group") { 24 | assert(defined(invoker.inputs), "pw_input_group requires some inputs") 25 | 26 | pw_python_script(target_name) { 27 | ignore_vars = [ 28 | "args", 29 | "script", 30 | "stamp", 31 | ] 32 | forward_variables_from(invoker, "*", ignore_vars) 33 | script = "$dir_pw_build/py/nop.py" 34 | stamp = true 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /pw_build/pw_executable.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | # Wrapper for Pigweed executable build targets which uses a globally-defined, 16 | # configurable target type. 17 | template("pw_executable") { 18 | target(pw_executable_config.target_type, target_name) { 19 | forward_variables_from(invoker, "*") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pw_build/py/nop.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Does nothing. 15 | 16 | The purpose of this script is to allow for source file dependencies within GN 17 | to be attached to targets that do not typically support them, such as groups. 18 | 19 | For example, instead of creating a group target, a pw_python_script target to 20 | run this script can be created. The script can be given a list of input files, 21 | causing GN to rebuild the target and everything that depends on it whenever any 22 | input file is modified. 23 | 24 | This is useful in the case where metadata is attached to a group of files but 25 | not collected into a generated_file until a later target. 26 | """ 27 | -------------------------------------------------------------------------------- /pw_build/py/null_backend.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Script that emits a helpful error when a facade is used without a backend.""" 15 | 16 | import argparse 17 | import sys 18 | 19 | 20 | def parse_args(): 21 | """Parses command-line arguments.""" 22 | 23 | parser = argparse.ArgumentParser( 24 | description='Emits an error when a facade has a null backend') 25 | parser.add_argument('facade_name', help='The facade with a null backend') 26 | return parser.parse_args() 27 | 28 | 29 | def main(): 30 | args = parse_args() 31 | print(f'ERROR: {args.facade_name} tried to build without a backend.') 32 | print('If you are using this module, ensure you have configured a backend ' 33 | 'properly. If you are NOT using this module, this error may have ' 34 | 'been triggered by trying to build all targets.') 35 | sys.exit(1) 36 | 37 | 38 | if __name__ == '__main__': 39 | main() 40 | -------------------------------------------------------------------------------- /pw_checksum/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | "pw_cc_test", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | pw_cc_library( 26 | name = "pw_checksum", 27 | srcs = [ 28 | "ccitt_crc16.cc", 29 | ], 30 | hdrs = [ 31 | "public/pw_checksum/ccitt_crc16.h", 32 | ], 33 | includes = ["public"], 34 | deps = ["//pw_span"], 35 | ) 36 | 37 | pw_cc_test( 38 | name = "ccitt_crc16_test", 39 | srcs = [ 40 | "ccitt_crc16_test.c", 41 | "ccitt_crc16_test.cc", 42 | ], 43 | deps = [":pw_checksum"], 44 | ) 45 | -------------------------------------------------------------------------------- /pw_checksum/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | import("$dir_pw_unit_test/test.gni") 17 | 18 | config("default_config") { 19 | include_dirs = [ "public" ] 20 | } 21 | 22 | source_set("pw_checksum") { 23 | public_configs = [ ":default_config" ] 24 | public = [ "public/pw_checksum/ccitt_crc16.h" ] 25 | sources = [ "ccitt_crc16.cc" ] + public 26 | public_deps = [ dir_pw_span ] 27 | } 28 | 29 | pw_test_group("tests") { 30 | tests = [ ":ccitt_crc16_test" ] 31 | } 32 | 33 | pw_test("ccitt_crc16_test") { 34 | deps = [ ":pw_checksum" ] 35 | sources = [ 36 | "ccitt_crc16_test.c", 37 | "ccitt_crc16_test.cc", 38 | ] 39 | } 40 | 41 | pw_doc_group("docs") { 42 | sources = [ "docs.rst" ] 43 | } 44 | -------------------------------------------------------------------------------- /pw_checksum/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_checksum PUBLIC_DEPS pw_span) 16 | -------------------------------------------------------------------------------- /pw_checksum/README.md: -------------------------------------------------------------------------------- 1 | # pw\_checksum: Checksum algorithms 2 | -------------------------------------------------------------------------------- /pw_checksum/ccitt_crc16_test.c: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #include "pw_checksum/ccitt_crc16.h" 16 | 17 | uint16_t CallChecksumCcittCrc16(const void* data, size_t size_bytes) { 18 | return pw_ChecksumCcittCrc16(data, size_bytes, 0xFFFF); 19 | } 20 | -------------------------------------------------------------------------------- /pw_checksum/docs.rst: -------------------------------------------------------------------------------- 1 | .. default-domain:: cpp 2 | 3 | .. highlight:: sh 4 | 5 | ----------- 6 | pw_checksum 7 | ----------- 8 | The ``pw_checksum`` module provides functions for calculating checksums. 9 | 10 | pw_checksum/ccitt_crc16.h 11 | ========================= 12 | 13 | .. cpp:namespace:: pw::checksum 14 | 15 | .. cpp:var:: constexpr uint16_t kCcittCrc16DefaultInitialValue = 0xFFFF 16 | 17 | The default initial value for the CRC16. 18 | 19 | .. cpp:function:: uint16_t CcittCrc16(span data, uint16_t initial_value = kCcittCrc16DefaultInitialValue) 20 | 21 | Calculates the CRC16 of the provided data using polynomial 0x1021, with a 22 | default initial value of :cpp:expr:`0xFFFF`. 23 | 24 | To incrementally calculate a CRC16, use the previous value as the initial 25 | value. 26 | 27 | .. code-block:: cpp 28 | 29 | uint16_t crc = CcittCrc16(my_data); 30 | 31 | crc = CcittCrc16(more_data, crc); 32 | 33 | Compatibility 34 | ============= 35 | * C 36 | * C++17 37 | 38 | Dependencies 39 | ============ 40 | * ``pw_span`` 41 | -------------------------------------------------------------------------------- /pw_cli/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("docs") { 18 | sources = [ "docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /pw_cli/README.md: -------------------------------------------------------------------------------- 1 | This directory contains the `pw` command line interface (CLI) that facilitates 2 | working with Pigweed. One example tool exposed by pw_cli is pw_watch, a file 3 | system watcher that triggers builds on source file changes. 4 | 5 | This code is experimental and unfinished. 6 | -------------------------------------------------------------------------------- /pw_cli/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-cli: 2 | 3 | .. default-domain:: python 4 | 5 | .. highlight:: sh 6 | 7 | ------ 8 | pw_cli 9 | ------ 10 | This directory contains the `pw` command line interface (CLI) that facilitates 11 | working with Pigweed. The CLI module adds several subcommands prefixed with 12 | `pw`, and provides a mechanism for other Pigweed modules to behave as "plugins" 13 | and register themselves as `pw` commands as well. After activating the Pigweed 14 | environment, these commands will be available for use. 15 | 16 | Some examples: 17 | 18 | .. code:: sh 19 | 20 | $ pw doctor 21 | $ pw format 22 | $ pw logdemo 23 | $ pw module-check 24 | $ pw presubmit 25 | $ pw test 26 | $ pw watch 27 | 28 | To see an up-to-date list of `pw` subcommands, run ``pw --help``. 29 | 30 | .. note:: 31 | The documentation for this module is currently incomplete. 32 | -------------------------------------------------------------------------------- /pw_cli/py/pw_cli/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Auto-load default plugins for pw_cli.""" 15 | 16 | # Note that these imports will trigger plugin registrations. 17 | import pw_cli.log 18 | 19 | import pw_cli.process 20 | -------------------------------------------------------------------------------- /pw_cli/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """pw_cli""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | """Test suite for pw_cli module.""" 22 | return unittest.TestLoader().discover('./', pattern='*_test.py') 23 | 24 | 25 | setuptools.setup( 26 | name='pw_cli', 27 | version='0.0.1', 28 | author='Pigweed Authors', 29 | author_email='pigweed-developers@googlegroups.com', 30 | description='Pigweed swiss-army knife', 31 | packages=setuptools.find_packages(), 32 | test_suite='setup.test_suite', 33 | entry_points={'console_scripts': ['pw = pw_cli.__main__:main']}, 34 | ) 35 | -------------------------------------------------------------------------------- /pw_containers/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | "pw_cc_test", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | pw_cc_library( 26 | name = "pw_containers", 27 | hdrs = [ 28 | "public/pw_containers/vector.h", 29 | ], 30 | includes = ["public"], 31 | ) 32 | 33 | pw_cc_test( 34 | name = "vector_test", 35 | srcs = [ 36 | "vector_test.cc", 37 | ], 38 | deps = ["//pw_containers"], 39 | ) 40 | -------------------------------------------------------------------------------- /pw_containers/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | import("$dir_pw_unit_test/test.gni") 17 | 18 | config("default_config") { 19 | include_dirs = [ "public" ] 20 | } 21 | 22 | source_set("pw_containers") { 23 | public_configs = [ ":default_config" ] 24 | public = [ "public/pw_containers/vector.h" ] 25 | sources = public 26 | } 27 | 28 | pw_test_group("tests") { 29 | tests = [ ":vector_test" ] 30 | } 31 | 32 | pw_test("vector_test") { 33 | deps = [ ":pw_containers" ] 34 | sources = [ "vector_test.cc" ] 35 | } 36 | 37 | pw_doc_group("docs") { 38 | sources = [ "docs.rst" ] 39 | } 40 | -------------------------------------------------------------------------------- /pw_containers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_containers) 16 | -------------------------------------------------------------------------------- /pw_containers/README.md: -------------------------------------------------------------------------------- 1 | # pw\_containers: Embedded-friendly container classes 2 | -------------------------------------------------------------------------------- /pw_containers/docs.rst: -------------------------------------------------------------------------------- 1 | .. default-domain:: cpp 2 | 3 | .. highlight:: sh 4 | 5 | ------------- 6 | pw_containers 7 | ------------- 8 | The ``pw_containers`` module provides embedded-friendly container classes. 9 | 10 | pw_vector 11 | ========= 12 | The Vector class is similar to std::vector, except it is backed by a 13 | fixed-size buffer. Vectors must be declared with an explicit maximum size 14 | (e.g. ``Vector``) but vectors can be used and referred to without the 15 | max size template parameter (e.g. ``Vector``). 16 | 17 | To allow referring to a ``pw::Vector`` without an explicit maximum size, all 18 | Vector classes inherit from the generic ``Vector``, which stores the maximum 19 | size in a variable. This allows Vectors to be used without having to know 20 | their maximum size at compile time. It also keeps code size small since 21 | function implementations are shared for all maximum sizes. 22 | 23 | Compatibility 24 | ============= 25 | * C 26 | * C++17 27 | 28 | Dependencies 29 | ============ 30 | * ``pw_span`` 31 | -------------------------------------------------------------------------------- /pw_cpu_exception/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) # Apache License 2.0 18 | 19 | filegroup( 20 | name = "pw_cpu_exception", 21 | srcs = [ 22 | "public/pw_cpu_exception/cpu_exception.h", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /pw_cpu_exception/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/facade.gni") 16 | import("$dir_pw_docgen/docs.gni") 17 | 18 | config("default_config") { 19 | include_dirs = [ "public" ] 20 | } 21 | 22 | pw_facade("pw_cpu_exception") { 23 | backend = dir_pw_cpu_exception_backend 24 | public_configs = [ ":default_config" ] 25 | public_deps = [ 26 | "$dir_pw_preprocessor", 27 | "$dir_pw_span", 28 | "$dir_pw_string", 29 | ] 30 | public = [ "public/pw_cpu_exception/cpu_exception.h" ] 31 | } 32 | 33 | pw_doc_group("docs") { 34 | sources = [ "docs.rst" ] 35 | } 36 | -------------------------------------------------------------------------------- /pw_cpu_exception/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_add_facade(pw_cpu_exception 16 | PUBLIC_DEPS 17 | pw_preprocessor 18 | pw_span 19 | pw_string 20 | ) 21 | -------------------------------------------------------------------------------- /pw_cpu_exception_armv7m/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) # Apache License 2.0 18 | 19 | filegroup( 20 | name = "pw_cpu_exception_armv7m", 21 | srcs = [ 22 | "cpu_exception_entry.cc", 23 | "cpu_state.cc", 24 | "public/pw_cpu_exception_armv7m/cpu_state.h", 25 | ], 26 | ) 27 | 28 | filegroup( 29 | name = "pw_cpu_exception_armv7m_test", 30 | srcs = ["exception_entry_test.cc"], 31 | ) 32 | -------------------------------------------------------------------------------- /pw_cpu_exception_armv7m/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_cpu_exception_armv7m 16 | IMPLEMENTS_FACADE 17 | pw_cpu_exception 18 | ) 19 | -------------------------------------------------------------------------------- /pw_docgen/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) # Apache License 2.0 18 | -------------------------------------------------------------------------------- /pw_docgen/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("docs.gni") 16 | 17 | pw_doc_group("docs") { 18 | sources = [ "docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /pw_doctor/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) # Apache License 2.0 18 | -------------------------------------------------------------------------------- /pw_doctor/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("docs") { 18 | sources = [ "docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /pw_doctor/README.md: -------------------------------------------------------------------------------- 1 | Check the environment for compatibility with Pigweed. 2 | -------------------------------------------------------------------------------- /pw_doctor/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-doctor: 2 | 3 | --------- 4 | pw_doctor 5 | --------- 6 | ``pw doctor`` confirms the environment is set up correctly. With ``--strict`` 7 | it checks that things exactly match what is expected and it checks that things 8 | look compatible without. 9 | -------------------------------------------------------------------------------- /pw_doctor/py/pw_doctor/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Pigweed doctor module.""" 15 | 16 | # Import pw_plugin to register the pw_cli plugin. 17 | import pw_doctor.pw_plugin 18 | -------------------------------------------------------------------------------- /pw_doctor/py/pw_doctor/pw_plugin.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Registers the check plugin for Pigweed.""" 15 | 16 | try: 17 | import pw_cli.plugins 18 | from pw_doctor import doctor 19 | 20 | pw_cli.plugins.register( 21 | 'doctor', 22 | doctor.main, 23 | doctor.__doc__.splitlines()[0].rstrip('.'), 24 | doctor.argument_parser, 25 | ) 26 | 27 | except ImportError: 28 | pass 29 | -------------------------------------------------------------------------------- /pw_doctor/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """The pw_doctor package.""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | """Test suite for pw_doctor module.""" 22 | return unittest.TestLoader().discover('./', pattern='*_test.py') 23 | 24 | 25 | setuptools.setup( 26 | name='pw_doctor', 27 | version='0.0.1', 28 | author='Pigweed Authors', 29 | author_email='pigweed-developers@googlegroups.com', 30 | description='Environment check script for Pigweed', 31 | packages=setuptools.find_packages(), 32 | test_suite='setup.test_suite', 33 | ) 34 | -------------------------------------------------------------------------------- /pw_env_setup/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("docs") { 18 | sources = [ "docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /pw_env_setup/py/pw_env_setup/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Pigweed environment setup.""" 15 | -------------------------------------------------------------------------------- /pw_env_setup/py/pw_env_setup/cargo_setup/packages.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | # Rust packages to install via cargo. 16 | # Format: "package version" 17 | 18 | pyoxidizer 0.6.0 19 | -------------------------------------------------------------------------------- /pw_env_setup/py/pw_env_setup/cipd_setup/.cipd_version: -------------------------------------------------------------------------------- 1 | git_revision:9c0e59fda0464ba15824ffa82a1095dcccef19ea 2 | -------------------------------------------------------------------------------- /pw_env_setup/py/pw_env_setup/cipd_setup/.cipd_version.digests: -------------------------------------------------------------------------------- 1 | # This file was generated by 2 | # 3 | # cipd selfupdate-roll -version-file .cipd_version \ 4 | # -version git_revision:9c0e59fda0464ba15824ffa82a1095dcccef19ea 5 | # 6 | # Do not modify manually. All changes will be overwritten. 7 | # Use 'cipd selfupdate-roll ...' to modify. 8 | 9 | linux-386 sha256 8a2ef5b3169f01f92537feb5217d45799d55ff6380fd39378139edce5ee5ee2f 10 | linux-amd64 sha256 7b78ed0cb5842cb03462f9446db54074a2b8137a88ab1b94e204f589d2f6b123 11 | linux-arm64 sha256 bd5068a692ec1a56c46e42fe1273069cbe0e36c207d9c258da835fe91dbbf3e6 12 | linux-armv6l sha256 8b7f1087d0309d3cbbeef266176f55feb6f7ff8857ca867353b80a3f60d92123 13 | linux-mips64 sha256 4a2a45517b0ce161b65a8f411eb9144d5c5f4370f8490c03b4cdf063e05011cf 14 | linux-mips64le sha256 c4db0affbd2e0099de43619f348abc58d440731d952d93a9f5c7f4fb64cb6db5 15 | linux-mipsle sha256 75da3575ffc5358a7eee35d07db5f616162cf16f67bad7ffca5ed39d175c2f1c 16 | linux-ppc64 sha256 64d532f4f6a6d0954f9da21843d9a31fcf6432b748059a5221743eed9dbedea9 17 | linux-ppc64le sha256 23c3530b83b13298c08a2706d9fbe1bbf45eb30fd1405783f891f6417d990d63 18 | linux-s390x sha256 edbdb85ac9e4a8e64286239e1555fe82b9aee120f6a0bcc6b0d341ddcfeab759 19 | mac-amd64 sha256 e6faaa614205f223887b3d48fb4d151e9b2f79d81649625433220c14d77dbe52 20 | windows-386 sha256 cbc17abd503919c3676664813c7922df09a9c33dff9e27aa13dec5c084a1314a 21 | windows-amd64 sha256 1d96c2ee8183fde8ae786d1215d0ecaff437a35c818d8b8979eae0491d8f6d5c 22 | -------------------------------------------------------------------------------- /pw_env_setup/py/pw_env_setup/cipd_setup/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | -------------------------------------------------------------------------------- /pw_env_setup/py/pw_env_setup/colors.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Defines ANSI color codes.""" 15 | 16 | import ctypes 17 | import os 18 | 19 | 20 | def _make_color(*codes): 21 | # Apply all the requested ANSI color codes. Note that this is unbalanced 22 | # with respect to the reset, which only requires a '0' to erase all codes. 23 | start = ''.join('\033[{}m'.format(code) for code in codes) 24 | reset = '\033[0m' 25 | 26 | return staticmethod(lambda msg: u'{}{}{}'.format(start, msg, reset)) 27 | 28 | 29 | class Color: # pylint: disable=too-few-public-methods 30 | """Helpers to surround text with ASCII color escapes""" 31 | bold = _make_color(1) 32 | red = _make_color(31) 33 | bold_red = _make_color(31, 1) 34 | green = _make_color(32) 35 | magenta = _make_color(35, 1) 36 | 37 | 38 | def enable_colors(): 39 | if os.name == 'nt': 40 | kernel32 = ctypes.windll.kernel32 41 | kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) 42 | -------------------------------------------------------------------------------- /pw_env_setup/py/pw_env_setup/virtualenv_setup/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Sets up a Python 3 virtualenv for Pigweed.""" 15 | 16 | # TODO(pwbug/67) move install.py contents to this file. 17 | from .install import * 18 | -------------------------------------------------------------------------------- /pw_env_setup/py/pw_env_setup/virtualenv_setup/requirements.in: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | # This is the list of packages we want installed. When we want to update them 16 | # or install additional packages update this file and run 17 | # `pip-compile requirements.in` and it will update requirements.txt. 18 | 19 | # To help manage these files. 20 | pip-tools 21 | 22 | # For documentation generation. 23 | # TODO(frolv): Create a setup.py for pw_docgen and remove these. 24 | sphinx 25 | sphinx-rtd-theme 26 | m2r 27 | -------------------------------------------------------------------------------- /pw_env_setup/py/pw_env_setup/virtualenv_setup/requirements.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile 3 | # To update, run: 4 | # 5 | # pip-compile requirements.in 6 | # 7 | alabaster==0.7.12 # via sphinx 8 | babel==2.7.0 # via sphinx 9 | certifi==2019.9.11 # via requests 10 | chardet==3.0.4 # via requests 11 | click==7.0 # via pip-tools 12 | docutils==0.15.2 # via m2r, sphinx 13 | idna==2.8 # via requests 14 | imagesize==1.1.0 # via sphinx 15 | jinja2==2.10.3 # via sphinx 16 | m2r==0.2.1 17 | markupsafe==1.1.1 # via jinja2 18 | mistune==0.8.4 # via m2r 19 | packaging==19.2 # via sphinx 20 | pip-tools==4.2.0 21 | pygments==2.4.2 # via sphinx 22 | pyparsing==2.4.5 # via packaging 23 | pytz==2019.3 # via babel 24 | requests==2.22.0 # via sphinx 25 | six==1.13.0 # via packaging, pip-tools 26 | snowballstemmer==2.0.0 # via sphinx 27 | sphinx-rtd-theme==0.4.3 28 | sphinx==2.2.1 29 | sphinxcontrib-applehelp==1.0.1 # via sphinx 30 | sphinxcontrib-devhelp==1.0.1 # via sphinx 31 | sphinxcontrib-htmlhelp==1.0.2 # via sphinx 32 | sphinxcontrib-jsmath==1.0.1 # via sphinx 33 | sphinxcontrib-qthelp==1.0.2 # via sphinx 34 | sphinxcontrib-serializinghtml==1.1.3 # via sphinx 35 | urllib3==1.25.7 # via requests 36 | 37 | # The following packages are considered to be unsafe in a requirements file: 38 | # setuptools==44.0.0 # via sphinx 39 | -------------------------------------------------------------------------------- /pw_kvs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_kvs 16 | PUBLIC_DEPS 17 | pw_containers 18 | pw_status 19 | PRIVATE_DEPS 20 | pw_checksum 21 | pw_log 22 | pw_string 23 | ) 24 | -------------------------------------------------------------------------------- /pw_kvs/checksum.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #include "pw_kvs/checksum.h" 16 | 17 | #include 18 | 19 | namespace pw::kvs { 20 | 21 | using std::byte; 22 | 23 | Status ChecksumAlgorithm::Verify(span checksum) const { 24 | if (checksum.size() < size_bytes()) { 25 | return Status::INVALID_ARGUMENT; 26 | } 27 | if (std::memcmp(state_.data(), checksum.data(), size_bytes()) != 0) { 28 | return Status::DATA_LOSS; 29 | } 30 | return Status::OK; 31 | } 32 | 33 | } // namespace pw::kvs 34 | -------------------------------------------------------------------------------- /pw_kvs/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-kvs: 2 | 3 | .. default-domain:: cpp 4 | 5 | .. highlight:: cpp 6 | 7 | ------ 8 | pw_kvs 9 | ------ 10 | ``pw_kvs`` is Pigweed's Key Value Store (KVS) library. KVS is a flash-backed 11 | persistent storage system with integrated wear-leveling that serves as a 12 | relatively lightweight alternative to a file system. 13 | 14 | .. note:: 15 | The documentation for this module is currently incomplete. 16 | -------------------------------------------------------------------------------- /pw_kvs/format.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #include "pw_kvs/format.h" 16 | 17 | namespace pw::kvs::internal { 18 | 19 | const EntryFormat* EntryFormats::Find(const uint32_t magic) const { 20 | for (const EntryFormat& format : formats_) { 21 | if (format.magic == magic) { 22 | return &format; 23 | } 24 | } 25 | return nullptr; 26 | } 27 | 28 | } // namespace pw::kvs::internal 29 | -------------------------------------------------------------------------------- /pw_kvs/public/pw_kvs/crc16_checksum.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include "pw_checksum/ccitt_crc16.h" 17 | #include "pw_kvs/checksum.h" 18 | #include "pw_span/span.h" 19 | 20 | namespace pw::kvs { 21 | 22 | class ChecksumCrc16 final : public ChecksumAlgorithm { 23 | public: 24 | ChecksumCrc16() : ChecksumAlgorithm(as_bytes(span(&crc_, 1))) {} 25 | 26 | void Reset() override { crc_ = checksum::kCcittCrc16DefaultInitialValue; } 27 | 28 | void Update(span data) override { 29 | crc_ = checksum::CcittCrc16(data, crc_); 30 | } 31 | 32 | private: 33 | uint16_t crc_ = checksum::kCcittCrc16DefaultInitialValue; 34 | }; 35 | 36 | } // namespace pw::kvs 37 | -------------------------------------------------------------------------------- /pw_kvs/public/pw_kvs/internal/hash.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | #include 18 | 19 | namespace pw::kvs::internal { 20 | 21 | // The hash function used to hash keys. 22 | constexpr uint32_t Hash(std::string_view string) { 23 | uint32_t hash = 0; 24 | uint32_t coefficient = 65599u; 25 | 26 | for (char ch : string) { 27 | hash += coefficient * uint32_t(ch); 28 | coefficient *= 65599u; 29 | } 30 | 31 | return hash; 32 | } 33 | 34 | } // namespace pw::kvs::internal 35 | -------------------------------------------------------------------------------- /pw_kvs/public/pw_kvs/internal/key_descriptor.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace pw::kvs::internal { 19 | 20 | // Whether an entry is present or deleted. 21 | enum class EntryState : bool { kValid, kDeleted }; 22 | 23 | // Essential metadata for an entry that is stored in memory. 24 | struct KeyDescriptor { 25 | uint32_t key_hash; 26 | uint32_t transaction_id; 27 | 28 | EntryState state; // TODO: Pack into transaction ID? or something? 29 | }; 30 | 31 | } // namespace pw::kvs::internal 32 | -------------------------------------------------------------------------------- /pw_kvs/public/pw_kvs/internal/span_traits.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace pw::kvs { 19 | 20 | namespace internal { 21 | template ()))> 22 | constexpr bool ConvertsToSpan(int) { 23 | return true; 24 | } 25 | 26 | // If the expression span(T) fails, then the type can't be converted to a span. 27 | template 28 | constexpr bool ConvertsToSpan(...) { 29 | return false; 30 | } 31 | 32 | } // namespace internal 33 | 34 | // Traits class to detect if the type converts to a span. 35 | template 36 | struct ConvertsToSpan 37 | : public std::bool_constant< 38 | internal::ConvertsToSpan>(0)> {}; 39 | 40 | } // namespace pw::kvs 41 | -------------------------------------------------------------------------------- /pw_log/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | "pw_cc_test", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | # TODO(pwbug/101): Need to add support for facades/backends to Bazel. 26 | PW_LOG_BACKEND = "//pw_log_basic" 27 | 28 | pw_cc_library( 29 | name = "facade", 30 | hdrs = [ 31 | "public/pw_log/levels.h", 32 | "public/pw_log/log.h", 33 | ], 34 | includes = ["public"], 35 | deps = [ 36 | "//pw_preprocessor", 37 | ], 38 | ) 39 | 40 | pw_cc_library( 41 | name = "pw_log", 42 | deps = [ 43 | ":facade", 44 | PW_LOG_BACKEND, 45 | ], 46 | ) 47 | 48 | pw_cc_test( 49 | name = "test", 50 | srcs = [ 51 | "basic_log_test.cc", 52 | "basic_log_test_plain_c.c", 53 | ], 54 | deps = [":pw_log"], 55 | ) 56 | -------------------------------------------------------------------------------- /pw_log/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/facade.gni") 16 | import("$dir_pw_docgen/docs.gni") 17 | import("$dir_pw_unit_test/test.gni") 18 | 19 | config("default_config") { 20 | include_dirs = [ "public" ] 21 | } 22 | 23 | pw_facade("pw_log") { 24 | backend = dir_pw_log_backend 25 | public_configs = [ ":default_config" ] 26 | public = [ 27 | "public/pw_log/levels.h", 28 | "public/pw_log/log.h", 29 | ] 30 | public_deps = [ dir_pw_preprocessor ] 31 | } 32 | 33 | pw_test_group("tests") { 34 | tests = [] 35 | if (dir_pw_log_backend != "") { 36 | tests += [ ":basic_log_test" ] 37 | } 38 | } 39 | 40 | if (dir_pw_log_backend != "") { 41 | pw_test("basic_log_test") { 42 | deps = [ 43 | ":pw_log", 44 | dir_pw_log_backend, 45 | ] 46 | 47 | sources = [ 48 | "basic_log_test.cc", 49 | "basic_log_test_plain_c.c", 50 | ] 51 | } 52 | } 53 | 54 | pw_doc_group("docs") { 55 | sources = [ "docs.rst" ] 56 | } 57 | -------------------------------------------------------------------------------- /pw_log/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_add_facade(pw_log 16 | PUBLIC_DEPS 17 | pw_preprocessor 18 | ) 19 | -------------------------------------------------------------------------------- /pw_log/public/pw_log/levels.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | // Standard log levels. These are compatible with the log levels from Python's 17 | // logging library, but this could be customized if desired by the backend. 18 | // 19 | // clang-format off 20 | #define PW_LOG_LEVEL_DEBUG 10 21 | #define PW_LOG_LEVEL_INFO 20 22 | #define PW_LOG_LEVEL_WARN 30 23 | #define PW_LOG_LEVEL_ERROR 40 24 | #define PW_LOG_LEVEL_CRITICAL 50 25 | // clang-format on 26 | -------------------------------------------------------------------------------- /pw_log_basic/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | ) 19 | 20 | package(default_visibility = ["//visibility:public"]) 21 | 22 | licenses(["notice"]) # Apache License 2.0 23 | 24 | pw_cc_library( 25 | name = "pw_log_basic", 26 | srcs = [ 27 | "log_basic.cc", 28 | ], 29 | hdrs = [ 30 | "public/pw_log_basic/log_basic.h", 31 | "public_overrides/pw_log_backend/log_backend.h", 32 | ], 33 | includes = [ 34 | "public", 35 | "public_overrides", 36 | ], 37 | deps = [ 38 | "//pw_log:facade", 39 | "//pw_string", 40 | "//pw_sys_io", 41 | ], 42 | ) 43 | -------------------------------------------------------------------------------- /pw_log_basic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_log_basic 16 | IMPLEMENTS_FACADE 17 | pw_log 18 | PRIVATE_DEPS 19 | pw_string 20 | pw_sys_io 21 | ) 22 | 23 | target_include_directories(pw_log_basic PUBLIC public_overrides) 24 | 25 | # TODO(hepler): Declare pw_log_basic as the pw_log backend for now. 26 | add_library(pw_log.backend INTERFACE) 27 | target_link_libraries(pw_log.backend INTERFACE pw_log_basic) 28 | -------------------------------------------------------------------------------- /pw_log_basic/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-log-basic: 2 | 3 | .. default-domain:: cpp 4 | 5 | .. highlight:: sh 6 | 7 | ------------ 8 | pw_log_basic 9 | ------------ 10 | ``pw_log_basic`` is a ``pw_log backend`` that sends logs over ``pw_sys_io``. The 11 | destination of ``pw_sys_io`` depends on the ``pw_sys_io`` backend in use. This 12 | is controlled by the ``dir_pw_sys_io_backend`` variable in a target's 13 | ``target_config.gni``. 14 | information. 15 | 16 | This module employs an internal buffer for formatting log strings, and currently 17 | has a fixed size of 150 bytes. Any final log statements that are larger than 18 | 149 bytes (one byte used for a null terminator) will be truncated. 19 | 20 | .. note:: 21 | The documentation for this module is currently incomplete. 22 | -------------------------------------------------------------------------------- /pw_log_basic/public_overrides/pw_log_backend/log_backend.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | // This override header merely points to the true backend, in this case the 16 | // basic one. The reason to redirect is to permit the use of multiple backends 17 | // (though only pw_log/log.h can only point to 1 backend). 18 | #pragma once 19 | 20 | #include "pw_log_basic/log_basic.h" 21 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_minimal_cpp_stdlib) 16 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-minimal-cpp-stdlib: 2 | 3 | .. default-domain:: cpp 4 | 5 | --------------------- 6 | pw_minimal_cpp_stdlib 7 | --------------------- 8 | The ``pw_minimal_cpp_stdlib`` module provides an extremely limited 9 | implementation of the C++ Standard Library. This module falls far, far short of 10 | providing a complete C++ Standard Library and should only be used in dire 11 | situations where you happen to be compiling with C++17 but don't have a C++ 12 | Standard Library available to you. 13 | 14 | The C++ Standard Library headers (e.g. ```` and ````) are 15 | defined in ``public/``. These files are symlinks to their implementations in 16 | ``public/internal/``. 17 | 18 | .. tip:: 19 | 20 | You can automatically recreate the symlinks in ``public/`` by executing the 21 | following Bash code from ``pw_minimal_cpp_stdlib/public/``. 22 | 23 | .. code-block:: bash 24 | 25 | for f in $(ls internal/); do ln -s internal/$f ${f%.h}; done 26 | 27 | Requirments 28 | =========== 29 | - C++17 30 | - gcc or clang 31 | - The C Standard Library 32 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/algorithm: -------------------------------------------------------------------------------- 1 | internal/algorithm.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/array: -------------------------------------------------------------------------------- 1 | internal/array.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/cinttypes: -------------------------------------------------------------------------------- 1 | internal/cinttypes.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/cmath: -------------------------------------------------------------------------------- 1 | internal/cmath.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/cstdarg: -------------------------------------------------------------------------------- 1 | internal/cstdarg.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/cstddef: -------------------------------------------------------------------------------- 1 | internal/cstddef.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/cstdint: -------------------------------------------------------------------------------- 1 | internal/cstdint.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/cstdio: -------------------------------------------------------------------------------- 1 | internal/cstdio.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/cstring: -------------------------------------------------------------------------------- 1 | internal/cstring.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/initializer_list: -------------------------------------------------------------------------------- 1 | internal/initializer_list.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/internal/cinttypes.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include "inttypes.h" 17 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/internal/cstdarg.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace std { 19 | 20 | using ::va_list; 21 | 22 | } // namespace std 23 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/internal/cstdint.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include "stdint.h" 17 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/internal/cstdio.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace std { 19 | 20 | using ::size_t; 21 | 22 | // Only a small subset of functions are exposed here. 23 | 24 | using ::putchar; 25 | using ::puts; 26 | using ::snprintf; 27 | using ::vsnprintf; 28 | 29 | using ::getchar; 30 | using ::sscanf; 31 | 32 | } // namespace std 33 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/internal/cstring.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace std { 19 | 20 | using ::size_t; 21 | 22 | // Only a small subset of functions are exposed here. 23 | 24 | using ::memchr; 25 | using ::memcmp; 26 | using ::memcpy; 27 | using ::memmove; 28 | using ::memset; 29 | 30 | using ::strcat; 31 | using ::strcpy; 32 | using ::strncpy; 33 | 34 | using ::strcmp; 35 | using ::strlen; 36 | using ::strncmp; 37 | 38 | } // namespace std 39 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/internal/initializer_list.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | namespace std { 17 | 18 | template 19 | class initializer_list { 20 | public: 21 | using value_type = T; 22 | using reference = const T&; 23 | using const_reference = const T&; 24 | using size_type = decltype(sizeof(0)); 25 | using iterator = const T*; 26 | using const_iterator = const T*; 27 | 28 | constexpr initializer_list() : begin_(nullptr), size_(0) {} 29 | 30 | size_type size() const { return size_; } 31 | 32 | iterator begin() const { return begin_; } 33 | iterator end() const { return begin_ + size_; } 34 | 35 | private: 36 | // The order of these members must stay the same. The compiler makes 37 | // assumptions about this class, and reordering these breaks things. 38 | const T* begin_; 39 | size_type size_; 40 | }; 41 | 42 | } // namespace std 43 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/internal/new.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | // Placement new 17 | inline void* operator new(decltype(sizeof(0)), void* ptr) { return ptr; } 18 | 19 | #define __cpp_lib_launder 201606L 20 | 21 | namespace std { 22 | 23 | template 24 | [[nodiscard]] constexpr T* launder(T* pointer) noexcept { 25 | return __builtin_launder(pointer); 26 | } 27 | 28 | } // namespace std 29 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/internal/utility.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace std { 19 | 20 | template 21 | constexpr remove_reference_t&& move(T&& object) { 22 | return (remove_reference_t &&) object; 23 | } 24 | 25 | // Forward declare these classes, which are specialized in other headers. 26 | template 27 | struct tuple_element; 28 | 29 | template 30 | struct tuple_size; 31 | 32 | } // namespace std 33 | -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/iterator: -------------------------------------------------------------------------------- 1 | internal/iterator.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/limits: -------------------------------------------------------------------------------- 1 | internal/limits.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/new: -------------------------------------------------------------------------------- 1 | internal/new.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/string_view: -------------------------------------------------------------------------------- 1 | internal/string_view.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/type_traits: -------------------------------------------------------------------------------- 1 | internal/type_traits.h -------------------------------------------------------------------------------- /pw_minimal_cpp_stdlib/public/utility: -------------------------------------------------------------------------------- 1 | internal/utility.h -------------------------------------------------------------------------------- /pw_module/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("docs") { 18 | sources = [ "docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /pw_module/README.md: -------------------------------------------------------------------------------- 1 | This is the Pigweed meta-module tooling: 2 | 3 | * Documentation about the Pigweed module stucture 4 | * Tooling to create modules and verify that they conform to the Pigweed module 5 | structure 6 | -------------------------------------------------------------------------------- /pw_module/docs.rst: -------------------------------------------------------------------------------- 1 | .. default-domain:: cpp 2 | 3 | .. highlight:: sh 4 | 5 | .. _chapter-module: 6 | 7 | --------- 8 | pw_module 9 | --------- 10 | The ``pw_module`` module contains tools for managing Pigweed modules. 11 | For information on the structure of a Pigweed module, refer to 12 | :ref:`chapter-module-guide` 13 | 14 | Commands 15 | -------- 16 | 17 | .. _chapter-module-module-check: 18 | 19 | ``pw module-check`` 20 | ^^^^^^^^^^^^^^^^^^^ 21 | The ``pw module-check`` command exists to ensure that your module conforms to 22 | the Pigweed module norms. 23 | 24 | For example, at time of writing ``pw module-check pw_module`` is not passing 25 | its own lint: 26 | 27 | .. code-block:: none 28 | 29 | $ pw module-check pw_module 30 | 31 | ▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄ 32 | ▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌ 33 | ▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌ 34 | ▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌ 35 | ▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀ 36 | 37 | 20191205 17:05:19 INF Checking module: pw_module 38 | 20191205 17:05:19 ERR PWCK005: Missing ReST documentation; need at least e.g. "docs.rst" 39 | 20191205 17:05:19 ERR FAIL: Found errors when checking module pw_module 40 | 41 | 42 | -------------------------------------------------------------------------------- /pw_module/py/pw_module/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """The Pigweed meta-module, with documentation about modules themselves.""" 15 | 16 | # Note that these imports will trigger plugin registrations. 17 | import pw_module.check 18 | -------------------------------------------------------------------------------- /pw_module/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """pw_module""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | """Test suite for pw_module module.""" 22 | return unittest.TestLoader().discover('./', pattern='*_test.py') 23 | 24 | 25 | setuptools.setup( 26 | name='pw_module', 27 | version='0.0.1', 28 | author='Pigweed Authors', 29 | author_email='pigweed-developers@googlegroups.com', 30 | description='Meta-module for Pigweed', 31 | packages=setuptools.find_packages(), 32 | test_suite='setup.test_suite', 33 | ) 34 | -------------------------------------------------------------------------------- /pw_polyfill/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | add_library(pw_polyfill INTERFACE) 16 | target_include_directories(pw_polyfill INTERFACE public standard_library_public) 17 | 18 | add_library(pw_polyfill.overrides INTERFACE) 19 | target_link_libraries(pw_polyfill.overrides INTERFACE pw_polyfill) 20 | target_include_directories(pw_polyfill.overrides 21 | INTERFACE 22 | public_overrides 23 | standard_library_public 24 | ) 25 | -------------------------------------------------------------------------------- /pw_polyfill/README.md: -------------------------------------------------------------------------------- 1 | # pw\_polyfill: Backports C++17 features to C++11 and C++14 2 | -------------------------------------------------------------------------------- /pw_polyfill/public/pw_polyfill/standard.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #define PW_CXX_STANDARD_IS_SUPPORTED(std) \ 17 | (__cplusplus >= _PW_CXX_STANDARD_##std()) 18 | 19 | #define _PW_CXX_STANDARD_98() 199711L 20 | #define _PW_CXX_STANDARD_11() 201103L 21 | #define _PW_CXX_STANDARD_14() 201402L 22 | #define _PW_CXX_STANDARD_17() 201703L 23 | -------------------------------------------------------------------------------- /pw_polyfill/public_overrides/assert.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include_next 17 | 18 | #include "pw_polyfill/standard_library/assert.h" 19 | -------------------------------------------------------------------------------- /pw_polyfill/public_overrides/cstddef: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include_next 17 | 18 | #include "pw_polyfill/standard_library/cstddef.h" 19 | -------------------------------------------------------------------------------- /pw_polyfill/public_overrides/iterator: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include_next 17 | 18 | #include "pw_polyfill/standard_library/iterator.h" 19 | -------------------------------------------------------------------------------- /pw_polyfill/public_overrides/type_traits: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include_next 17 | 18 | #include "pw_polyfill/standard_library/type_traits.h" 19 | -------------------------------------------------------------------------------- /pw_polyfill/standard_library_public/pw_polyfill/standard_library/assert.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | // In C11, assert.h should define static_assert as _Static_assert. 19 | #if !defined(__cplusplus) && !defined(static_assert) 20 | 21 | #if __STDC_VERSION__ >= 201112L 22 | #define static_assert _Static_assert 23 | #else // _Static_assert requires C11. 24 | #define static_assert(...) 25 | #endif // __STDC_VERSION__ >= 201112L 26 | 27 | #endif // !defined(__cplusplus) && !defined(static_assert) 28 | -------------------------------------------------------------------------------- /pw_preprocessor/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | "pw_cc_test", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | pw_cc_library( 26 | name = "pw_preprocessor", 27 | hdrs = glob(["public/pw_preprocessor/*.h"]), 28 | includes = ["public"], 29 | ) 30 | 31 | TESTS = [ 32 | "boolean_test", 33 | "concat_test", 34 | "macro_arg_count_test", 35 | "util_test", 36 | ] 37 | 38 | [ 39 | pw_cc_test( 40 | name = t, 41 | srcs = [t + ".cc"], 42 | deps = ["//pw_preprocessor"], 43 | ) 44 | for t in TESTS 45 | ] 46 | -------------------------------------------------------------------------------- /pw_preprocessor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_preprocessor) 16 | -------------------------------------------------------------------------------- /pw_preprocessor/README.md: -------------------------------------------------------------------------------- 1 | # pw\_preprocessor: Useful C preprocessor macros 2 | 3 | The pw\_preprocessor module provides several helpful preprocessor macros for use 4 | in C and C++ code. 5 | -------------------------------------------------------------------------------- /pw_presubmit/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("docs") { 18 | sources = [ "docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /pw_presubmit/README.md: -------------------------------------------------------------------------------- 1 | # pw\_presubmit: Tools for running presubmit checks 2 | -------------------------------------------------------------------------------- /pw_presubmit/py/pw_presubmit/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """The pw_presubmit package provides tools for running presubmit checks.""" 15 | 16 | from pw_presubmit.tools import * 17 | 18 | # Import pw_plugin to register the pw_cli plugin. 19 | import pw_presubmit.pw_plugin 20 | -------------------------------------------------------------------------------- /pw_presubmit/py/pw_presubmit/pw_plugin.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Registers the presubmit plugin for Pigweed.""" 15 | 16 | try: 17 | import pw_cli.plugins 18 | from pw_presubmit import format_code, pigweed_presubmit 19 | 20 | pw_cli.plugins.register( 21 | 'presubmit', 22 | pigweed_presubmit.main, 23 | pigweed_presubmit.__doc__.splitlines()[0].rstrip('.'), 24 | pigweed_presubmit.argument_parser, 25 | ) 26 | 27 | pw_cli.plugins.register( 28 | 'format', 29 | format_code.main, 30 | format_code.__doc__.splitlines()[0].rstrip('.'), 31 | format_code.argument_parser, 32 | ) 33 | except ImportError: 34 | pass 35 | -------------------------------------------------------------------------------- /pw_presubmit/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """The pw_presubmit package.""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | """Test suite for pw_module module.""" 22 | return unittest.TestLoader().discover('./', pattern='*_test.py') 23 | 24 | 25 | setuptools.setup( 26 | name='pw_presubmit', 27 | version='0.0.1', 28 | author='Pigweed Authors', 29 | author_email='pigweed-developers@googlegroups.com', 30 | description='Presubmit tools and a presubmit script for Pigweed', 31 | install_requires=[ 32 | 'mypy', 33 | 'pylint', 34 | 'yapf', 35 | ], 36 | packages=setuptools.find_packages(), 37 | test_suite='setup.test_suite', 38 | ) 39 | -------------------------------------------------------------------------------- /pw_protobuf/README.md: -------------------------------------------------------------------------------- 1 | # pw\_protobuf: A tiny Protocol Buffers implementation 2 | -------------------------------------------------------------------------------- /pw_protobuf/decoding.rst: -------------------------------------------------------------------------------- 1 | .. default-domain:: cpp 2 | 3 | .. highlight:: sh 4 | 5 | .. _chapter-protobuf-decoder: 6 | 7 | -------- 8 | Decoding 9 | -------- 10 | 11 | Size report 12 | =========== 13 | 14 | Full size report 15 | ^^^^^^^^^^^^^^^^ 16 | 17 | This report demonstrates the size of using the entire decoder with all of its 18 | decode methods and a decode callback for a proto message containing each of the 19 | protobuf field types. 20 | 21 | .. include:: size_report/decoder_full 22 | 23 | 24 | Incremental size report 25 | ^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | This report is generated using the full report as a base and adding some int32 28 | fields to the decode callback to demonstrate the incremental cost of decoding 29 | fields in a message. 30 | 31 | .. include:: size_report/decoder_incremental 32 | -------------------------------------------------------------------------------- /pw_protobuf/public/pw_protobuf/codegen.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include "pw_protobuf/encoder.h" 17 | 18 | namespace pw::protobuf { 19 | 20 | // Base class for generated encoders. Stores a reference to a low-level proto 21 | // encoder. If representing a nested message, knows the field number of the 22 | // message in its parent and and automatically calls Push and Pop when on the 23 | // encoder when created/destroyed. 24 | class ProtoMessageEncoder { 25 | public: 26 | ProtoMessageEncoder(Encoder* encoder, uint32_t parent_field = 0) 27 | : encoder_(encoder), parent_field_(parent_field) { 28 | if (parent_field_ != 0) { 29 | encoder_->Push(parent_field_); 30 | } 31 | } 32 | 33 | ~ProtoMessageEncoder() { 34 | if (parent_field_ != 0) { 35 | encoder_->Pop(); 36 | } 37 | } 38 | 39 | protected: 40 | Encoder* encoder_; 41 | uint32_t parent_field_; 42 | }; 43 | 44 | } // namespace pw::protobuf 45 | -------------------------------------------------------------------------------- /pw_protobuf/public/pw_protobuf/wire_format.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace pw::protobuf { 19 | 20 | enum class WireType { 21 | kVarint = 0, 22 | kFixed64 = 1, 23 | kDelimited = 2, 24 | // Wire types 3 and 4 are deprecated per the protobuf specification. 25 | kFixed32 = 5, 26 | }; 27 | 28 | inline constexpr unsigned int kFieldNumberShift = 3u; 29 | inline constexpr unsigned int kWireTypeMask = (1u << kFieldNumberShift) - 1u; 30 | 31 | constexpr uint32_t MakeKey(uint32_t field_number, WireType wire_type) { 32 | return (field_number << kFieldNumberShift | static_cast(wire_type)); 33 | } 34 | 35 | } // namespace pw::protobuf 36 | -------------------------------------------------------------------------------- /pw_protobuf/pw_protobuf_protos/test_protos/proto2.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | syntax = "proto2"; 15 | 16 | package pw.protobuf.test; 17 | 18 | message Foo { 19 | required uint32 int = 1; 20 | optional string str = 2; 21 | repeated Bar bar = 3; 22 | optional pb pb = 4; 23 | }; 24 | 25 | message Bar { 26 | optional bytes data = 1; 27 | }; 28 | 29 | // This message's name starts with a character which is in the package path, 30 | // which exposes a bug in the original implementation of the pw_protobuf 31 | // compiler plugin. 32 | message pb { 33 | optional Foo foo = 1; 34 | }; 35 | -------------------------------------------------------------------------------- /pw_protobuf/pw_protobuf_protos/test_protos/repeated.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | syntax = "proto3"; 15 | 16 | package pw.protobuf.test; 17 | 18 | message RepeatedTest { 19 | repeated uint32 uint32s = 1; 20 | repeated sint32 sint32s = 2; 21 | repeated string strings = 3; 22 | repeated double doubles = 4; 23 | repeated Struct structs = 5; 24 | }; 25 | 26 | message Struct { 27 | uint32 one = 1; 28 | uint32 two = 2; 29 | } 30 | -------------------------------------------------------------------------------- /pw_protobuf/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """pw_protobuf""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | """Test suite for pw_protobuf module.""" 22 | return unittest.TestLoader().discover('./', pattern='*_test.py') 23 | 24 | 25 | setuptools.setup( 26 | name='pw_protobuf', 27 | version='0.0.1', 28 | author='Pigweed Authors', 29 | author_email='pigweed-developers@googlegroups.com', 30 | description='Lightweight streaming protobuf implementation', 31 | packages=setuptools.find_packages(), 32 | test_suite='setup.test_suite', 33 | entry_points={ 34 | 'console_scripts': ['pw_protobuf_codegen = pw_protobuf.codegen:main'] 35 | }, 36 | install_requires=[ 37 | 'protobuf', 38 | ], 39 | ) 40 | -------------------------------------------------------------------------------- /pw_protobuf/size_report/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_bloat/bloat.gni") 16 | 17 | _decoder_full = { 18 | deps = [ 19 | "$dir_pw_bloat:bloat_this_binary", 20 | "$dir_pw_preprocessor", 21 | "$dir_pw_protobuf:pw_protobuf", 22 | ] 23 | sources = [ "decoder_full.cc" ] 24 | } 25 | 26 | pw_toolchain_size_report("decoder_full") { 27 | base_executable = pw_bloat_empty_base 28 | diff_executable = _decoder_full 29 | title = "Size of all decoder methods" 30 | } 31 | 32 | pw_toolchain_size_report("decoder_incremental") { 33 | base_executable = _decoder_full 34 | diff_executable = { 35 | deps = [ 36 | "$dir_pw_bloat:bloat_this_binary", 37 | "$dir_pw_preprocessor", 38 | "$dir_pw_protobuf:pw_protobuf", 39 | ] 40 | sources = [ "decoder_incremental.cc" ] 41 | } 42 | title = "Adding more fields to decode callback" 43 | } 44 | -------------------------------------------------------------------------------- /pw_protobuf_compiler/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("docs") { 18 | sources = [ "docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /pw_protobuf_compiler/README.md: -------------------------------------------------------------------------------- 1 | # pw\_protobuf\_compiler: Build system support for protobufs 2 | -------------------------------------------------------------------------------- /pw_protobuf_compiler/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """pw_protobuf_compiler""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | """Test suite for pw_protobuf_compiler module.""" 22 | return unittest.TestLoader().discover('./', pattern='*_test.py') 23 | 24 | 25 | setuptools.setup( 26 | name='pw_protobuf_compiler', 27 | version='0.0.1', 28 | author='Pigweed Authors', 29 | author_email='pigweed-developers@googlegroups.com', 30 | description='Pigweed protoc wrapper', 31 | packages=setuptools.find_packages(), 32 | test_suite='setup.test_suite', 33 | entry_points={ 34 | 'console_scripts': 35 | ['generate_protos = pw_protobuf_compiler.generate_protos:main'] 36 | }, 37 | install_requires=[ 38 | 'pw_cli', 39 | ], 40 | ) 41 | -------------------------------------------------------------------------------- /pw_span/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | "pw_cc_test", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | pw_cc_library( 26 | name = "pw_span", 27 | hdrs = ["public/pw_span/span.h"], 28 | includes = ["public"], 29 | deps = ["//pw_polyfill"], 30 | ) 31 | 32 | pw_cc_test( 33 | name = "span_test", 34 | srcs = ["span_test.cc"], 35 | deps = ["//pw_span"], 36 | ) 37 | -------------------------------------------------------------------------------- /pw_span/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | import("$dir_pw_unit_test/test.gni") 17 | 18 | config("default_config") { 19 | include_dirs = [ "public" ] 20 | } 21 | 22 | source_set("pw_span") { 23 | public_configs = [ ":default_config" ] 24 | public_deps = [ "$dir_pw_polyfill" ] 25 | public = [ "public/pw_span/span.h" ] 26 | sources = public 27 | } 28 | 29 | pw_test_group("tests") { 30 | tests = [ ":test" ] 31 | } 32 | 33 | pw_test("test") { 34 | deps = [ ":pw_span" ] 35 | sources = [ "span_test.cc" ] 36 | } 37 | 38 | pw_doc_group("docs") { 39 | sources = [ "docs.rst" ] 40 | } 41 | -------------------------------------------------------------------------------- /pw_span/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_span PUBLIC_DEPS pw_polyfill) 16 | -------------------------------------------------------------------------------- /pw_span/README.md: -------------------------------------------------------------------------------- 1 | # pw\_span: Stand-in for C++20's std::span 2 | -------------------------------------------------------------------------------- /pw_status/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | "pw_cc_test", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | pw_cc_library( 26 | name = "pw_status", 27 | srcs = ["status.cc"], 28 | hdrs = [ 29 | "public/pw_status/status.h", 30 | "public/pw_status/status_with_size.h", 31 | ], 32 | includes = ["public"], 33 | ) 34 | 35 | pw_cc_test( 36 | name = "status_test", 37 | srcs = [ 38 | "status_test.c", 39 | "status_test.cc", 40 | ], 41 | deps = ["//pw_status"], 42 | ) 43 | 44 | pw_cc_test( 45 | name = "status_with_size_test", 46 | srcs = ["status_with_size_test.cc"], 47 | deps = ["//pw_status"], 48 | ) 49 | -------------------------------------------------------------------------------- /pw_status/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | import("$dir_pw_unit_test/test.gni") 17 | 18 | config("default_config") { 19 | include_dirs = [ "public" ] 20 | } 21 | 22 | source_set("pw_status") { 23 | public_configs = [ ":default_config" ] 24 | public = [ 25 | "public/pw_status/status.h", 26 | "public/pw_status/status_with_size.h", 27 | ] 28 | sources = [ "status.cc" ] + public 29 | } 30 | 31 | pw_test_group("tests") { 32 | tests = [ 33 | ":status_test", 34 | ":status_with_size_test", 35 | ] 36 | } 37 | 38 | pw_test("status_test") { 39 | deps = [ ":pw_status" ] 40 | sources = [ 41 | "status_test.c", 42 | "status_test.cc", 43 | ] 44 | } 45 | 46 | pw_test("status_with_size_test") { 47 | deps = [ ":pw_status" ] 48 | sources = [ "status_with_size_test.cc" ] 49 | } 50 | 51 | pw_doc_group("docs") { 52 | sources = [ "docs.rst" ] 53 | } 54 | -------------------------------------------------------------------------------- /pw_status/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_status) 16 | -------------------------------------------------------------------------------- /pw_status/README.md: -------------------------------------------------------------------------------- 1 | # pw\_status: Pigweed status codes 2 | -------------------------------------------------------------------------------- /pw_status/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-status: 2 | 3 | .. default-domain:: cpp 4 | 5 | .. highlight:: sh 6 | 7 | --------- 8 | pw_status 9 | --------- 10 | ``pw::Status`` (``pw_status/status.h``) is a simple, zero-overhead status 11 | object. It uses Google's standard status codes, which are also used by projects 12 | such as `gRPC `_. 13 | 14 | ``pw::StatusWithSize`` (``pw_status/status_with_size.h``) is a convenient, 15 | efficent class for reporting a status along with an unsigned integer value. 16 | 17 | The classes in pw_status are used extensively by other Pigweed modules. 18 | 19 | Compatibility 20 | ============= 21 | C++11 22 | -------------------------------------------------------------------------------- /pw_string/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_string 16 | PUBLIC_DEPS 17 | pw_preprocessor 18 | pw_span 19 | pw_status 20 | ) 21 | -------------------------------------------------------------------------------- /pw_string/README.md: -------------------------------------------------------------------------------- 1 | # pw\_string: Embedded-friendly C++ string manipulation primitives 2 | -------------------------------------------------------------------------------- /pw_string/public/pw_string/util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace pw::string { 19 | 20 | // Calculates the length of a null-terminated string up to the specified maximum 21 | // length. If str is nullptr, returns 0. 22 | // 23 | // This function is a constexpr version of C11's strnlen_s. 24 | constexpr size_t Length(const char* str, size_t max_len) { 25 | size_t length = 0; 26 | 27 | if (str != nullptr) { 28 | for (; length < max_len; ++length) { 29 | if (str[length] == '\0') { 30 | break; 31 | } 32 | } 33 | } 34 | 35 | return length; 36 | } 37 | 38 | } // namespace pw::string 39 | -------------------------------------------------------------------------------- /pw_string/util_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #include "pw_string/util.h" 16 | 17 | #include "gtest/gtest.h" 18 | 19 | namespace pw::string { 20 | namespace { 21 | 22 | TEST(Length, Nullptr_Returns0) { EXPECT_EQ(0u, Length(nullptr, 100)); } 23 | 24 | TEST(Length, EmptyString_Returns0) { 25 | EXPECT_EQ(0u, Length("", 0)); 26 | EXPECT_EQ(0u, Length("", 100)); 27 | } 28 | 29 | TEST(Length, MaxLongerThanString_ReturnsStrlen) { 30 | EXPECT_EQ(5u, Length("12345", 100)); 31 | } 32 | 33 | TEST(Length, StringMaxLongerThanMax_ReturnsMax) { 34 | EXPECT_EQ(0u, Length("12345", 0)); 35 | EXPECT_EQ(4u, Length("12345", 4)); 36 | } 37 | 38 | TEST(Length, LengthEqualsMax) { EXPECT_EQ(5u, Length("12345", 5)); } 39 | 40 | } // namespace 41 | } // namespace pw::string 42 | -------------------------------------------------------------------------------- /pw_sys_io/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/facade.gni") 16 | import("$dir_pw_docgen/docs.gni") 17 | 18 | config("default_config") { 19 | include_dirs = [ "public" ] 20 | } 21 | 22 | pw_facade("pw_sys_io") { 23 | backend = dir_pw_sys_io_backend 24 | public_configs = [ ":default_config" ] 25 | public_deps = [ 26 | "$dir_pw_span", 27 | "$dir_pw_status", 28 | ] 29 | public = [ "public/pw_sys_io/sys_io.h" ] 30 | } 31 | 32 | source_set("default_putget_bytes") { 33 | deps = [ ":facade" ] 34 | sources = [ "sys_io.cc" ] 35 | } 36 | 37 | pw_doc_group("docs") { 38 | sources = [ "docs.rst" ] 39 | } 40 | -------------------------------------------------------------------------------- /pw_sys_io/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_add_facade(pw_sys_io 16 | SOURCES 17 | sys_io.cc 18 | PUBLIC_DEPS 19 | pw_span 20 | pw_status 21 | ) 22 | -------------------------------------------------------------------------------- /pw_sys_io/sys_io.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #include "pw_sys_io/sys_io.h" 16 | 17 | namespace pw::sys_io { 18 | 19 | StatusWithSize ReadBytes(span dest) { 20 | for (size_t i = 0; i < dest.size_bytes(); ++i) { 21 | Status result = ReadByte(&dest[i]); 22 | if (!result.ok()) { 23 | return StatusWithSize(result, i); 24 | } 25 | } 26 | return StatusWithSize(dest.size_bytes()); 27 | } 28 | 29 | StatusWithSize WriteBytes(span src) { 30 | for (size_t i = 0; i < src.size_bytes(); ++i) { 31 | Status result = WriteByte(src[i]); 32 | if (!result.ok()) { 33 | return StatusWithSize(result, i); 34 | } 35 | } 36 | return StatusWithSize(src.size_bytes()); 37 | } 38 | 39 | } // namespace pw::sys_io 40 | -------------------------------------------------------------------------------- /pw_sys_io_baremetal_stm32f429/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) # Apache License 2.0 18 | 19 | filegroup( 20 | name = "pw_sys_io_baremetal_stm32f429", 21 | srcs = [ 22 | "sys_io_baremetal.cc", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /pw_sys_io_baremetal_stm32f429/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | # This if statement allows docs to always build even if the target isn't 18 | # compatible with this backend. 19 | if (dir_pw_sys_io_backend == dir_pw_sys_io_baremetal_stm32f429) { 20 | source_set("pw_sys_io_baremetal_stm32f429") { 21 | public_deps = [ "$dir_pw_boot_armv7m" ] 22 | deps = [ 23 | "$dir_pw_preprocessor", 24 | "$dir_pw_sys_io:default_putget_bytes", 25 | "$dir_pw_sys_io:facade", 26 | ] 27 | sources = [ "sys_io_baremetal.cc" ] 28 | } 29 | } 30 | 31 | pw_doc_group("docs") { 32 | sources = [ "docs.rst" ] 33 | } 34 | -------------------------------------------------------------------------------- /pw_sys_io_stdio/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | ) 19 | 20 | package(default_visibility = ["//visibility:public"]) 21 | 22 | licenses(["notice"]) # Apache License 2.0 23 | 24 | pw_cc_library( 25 | name = "pw_sys_io_stdio", 26 | srcs = ["sys_io.cc"], 27 | deps = [ 28 | "//pw_sys_io:default_putget_bytes", 29 | "//pw_sys_io:facade", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /pw_sys_io_stdio/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | # This if statement allows docs to always build even if the target isn't 18 | # compatible with this backend. 19 | if (dir_pw_sys_io_backend == dir_pw_sys_io_stdio) { 20 | source_set("pw_sys_io_stdio") { 21 | deps = [ 22 | "$dir_pw_sys_io:default_putget_bytes", 23 | "$dir_pw_sys_io:facade", 24 | ] 25 | sources = [ "sys_io.cc" ] 26 | } 27 | } 28 | 29 | pw_doc_group("docs") { 30 | sources = [ "docs.rst" ] 31 | } 32 | -------------------------------------------------------------------------------- /pw_sys_io_stdio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_sys_io_stdio 16 | IMPLEMENTS_FACADE 17 | pw_sys_io 18 | ) 19 | 20 | # TODO(hepler): Declare pw_sys_io_stdio as the pw_sys_io backend for now. 21 | add_library(pw_sys_io.backend INTERFACE) 22 | target_link_libraries(pw_sys_io.backend INTERFACE pw_sys_io_stdio) 23 | -------------------------------------------------------------------------------- /pw_sys_io_stdio/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-sys-io-stdio: 2 | 3 | .. default-domain:: cpp 4 | 5 | .. highlight:: sh 6 | 7 | --------------- 8 | pw_sys_io_stdio 9 | --------------- 10 | The ``pw_sys_io_stdio`` backend implements the ``pw_sys_io`` facade using 11 | stdio. 12 | 13 | Why not just use stdio directly? 14 | -------------------------------- 15 | 16 | The nice thing about using ``pw_sys_io`` is that it's rather easy to get a 17 | board up and running with a target-specific backend. This means when drafting 18 | out a quick application you can write it against ``pw_sys_io`` and, with some 19 | care, the application will be able to run on both host and target devices. 20 | 21 | While it's not recommended to use ``pw_sys_io`` for any production 22 | applications, it can be rather helpful for early prototyping. 23 | 24 | Setup 25 | ===== 26 | This module requires relatively minimal setup: 27 | 28 | 1. Write code against the ``pw_sys_io`` facade. 29 | 2. Specify the ``dir_pw_sys_io_backend`` GN global variable to point to this 30 | backend. 31 | 32 | Module usage 33 | ============ 34 | For the most part, applications built with this backend will behave similarly 35 | to an application built directly against stdio. 36 | 37 | Dependencies 38 | ============ 39 | * ``pw_sys_io`` facade 40 | -------------------------------------------------------------------------------- /pw_target_runner/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | import("$dir_pw_protobuf_compiler/proto.gni") 17 | 18 | pw_doc_group("docs") { 19 | sources = [ "docs.rst" ] 20 | group_deps = [ "go:docs" ] 21 | } 22 | 23 | pw_proto_library("target_runner_proto") { 24 | sources = [ "pw_target_runner_protos/target_runner.proto" ] 25 | } 26 | 27 | pw_proto_library("exec_server_config_proto") { 28 | sources = [ "pw_target_runner_protos/exec_server_config.proto" ] 29 | } 30 | -------------------------------------------------------------------------------- /pw_target_runner/go/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/go.gni") 16 | import("$dir_pw_build/host_tool.gni") 17 | import("$dir_pw_docgen/docs.gni") 18 | 19 | pw_doc_group("docs") { 20 | sources = [ "docs.rst" ] 21 | } 22 | 23 | pw_go_executable("pw_target_runner_client") { 24 | deps = [ "src/pigweed.dev/pw_target_runner_client" ] 25 | package = "pigweed.dev/pw_target_runner_client" 26 | } 27 | 28 | pw_go_executable("pw_target_runner_server") { 29 | deps = [ "src/pigweed.dev/pw_target_runner_server" ] 30 | package = "pigweed.dev/pw_target_runner_server" 31 | } 32 | 33 | pw_host_tool("simple_client") { 34 | deps = [ ":pw_target_runner_client" ] 35 | } 36 | 37 | pw_host_tool("simple_server") { 38 | deps = [ ":pw_target_runner_server" ] 39 | } 40 | -------------------------------------------------------------------------------- /pw_target_runner/go/src/pigweed.dev/pw_target_runner/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/go.gni") 16 | 17 | pw_go_package("pw_target_runner") { 18 | sources = [ 19 | "exec_runner.go", 20 | "server.go", 21 | "worker_pool.go", 22 | ] 23 | deps = [ "$dir_pw_target_runner:target_runner_proto_go" ] 24 | external_deps = [ "google.golang.org/grpc" ] 25 | gopath = "$dir_pw_target_runner/go" 26 | } 27 | -------------------------------------------------------------------------------- /pw_target_runner/go/src/pigweed.dev/pw_target_runner_client/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/go.gni") 16 | 17 | pw_go_package("pw_target_runner_client") { 18 | sources = [ "main.go" ] 19 | deps = [ "$dir_pw_target_runner:target_runner_proto_go" ] 20 | gopath = "$dir_pw_target_runner/go" 21 | } 22 | -------------------------------------------------------------------------------- /pw_target_runner/go/src/pigweed.dev/pw_target_runner_server/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_build/go.gni") 16 | 17 | pw_go_package("pw_target_runner_server") { 18 | sources = [ "main.go" ] 19 | deps = [ 20 | "$dir_pw_target_runner:exec_server_config_proto_go", 21 | "$dir_pw_target_runner/go/src/pigweed.dev/pw_target_runner", 22 | ] 23 | external_deps = [ "github.com/golang/protobuf/proto" ] 24 | gopath = "$dir_pw_target_runner/go" 25 | } 26 | -------------------------------------------------------------------------------- /pw_target_runner/pw_target_runner_protos/exec_server_config.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | syntax = "proto3"; 15 | 16 | package pw.target_runner; 17 | 18 | option go_package = "pigweed.dev/proto/pw_target_runner/exec_server_config_pb"; 19 | 20 | // Configuration options for running a test server. 21 | message ServerConfig { 22 | // All runner programs that can be launched concurrently. 23 | repeated TestRunner runner = 1; 24 | } 25 | 26 | // A program that can run a unit test binary. Must take the path to a test 27 | // executable as a single positional argument. 28 | message TestRunner { 29 | // The program to run. 30 | string command = 1; 31 | 32 | // Other option arguments to the program. 33 | repeated string args = 2; 34 | } 35 | -------------------------------------------------------------------------------- /pw_tokenizer/README.md: -------------------------------------------------------------------------------- 1 | # pw\_tokenizer: Tools for replacing string literals with binary tokens 2 | pw\_tokenizer is a portable, general purpose module for replacing printf-style 3 | string literals with compact binary tokens. 4 | -------------------------------------------------------------------------------- /pw_tokenizer/py/elf_reader_test_binary.c: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | // This file is used to build an ELF for elf_reader_test.py. It places data into 16 | // sections for the tool to read. 17 | // 18 | // To generate this test ELF, build the target 19 | // //pw_tokenizer:elf_reader_test_binary. This produces the test binary 20 | // elf_reader_test_binary.elf. 21 | const char message[] __attribute__((section(".test_section_1"), used)) = 22 | "You cannot pass"; 23 | 24 | const unsigned number __attribute__((section(".test_section_2"), used)) = 25 | 0xfeedbeef; 26 | -------------------------------------------------------------------------------- /pw_tokenizer/py/elf_reader_test_binary.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/izzimat/pigweed/0294627ff75924f627aee849eb021917f48b7628/pw_tokenizer/py/elf_reader_test_binary.elf -------------------------------------------------------------------------------- /pw_tokenizer/py/pw_tokenizer/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Package that supports decoding and detokenizing strings.""" 15 | 16 | from pw_tokenizer.detokenize import AutoUpdatingDetokenizer, Detokenizer 17 | -------------------------------------------------------------------------------- /pw_tokenizer/py/pw_tokenizer/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Runs the main function in detokenize.py.""" 15 | 16 | from pw_tokenizer import detokenize 17 | 18 | detokenize._main(detokenize._parse_args()) # pylint: disable=protected-access 19 | -------------------------------------------------------------------------------- /pw_tokenizer/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """The pw_tokenizer package.""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | return unittest.TestLoader().discover('./', pattern='*_test.py') 22 | 23 | 24 | setuptools.setup( 25 | name='pw_tokenizer', 26 | version='0.0.1', 27 | author='Pigweed Authors', 28 | author_email='pigweed-developers@googlegroups.com', 29 | description='Tools for decoding tokenized strings', 30 | packages=setuptools.find_packages(), 31 | test_suite='setup.test_suite', 32 | ) 33 | -------------------------------------------------------------------------------- /pw_tokenizer/token_database.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #include "pw_tokenizer/token_database.h" 16 | 17 | namespace pw::tokenizer { 18 | 19 | TokenDatabase::Entry TokenDatabase::Entries::operator[](size_t index) const { 20 | Iterator it = begin(); 21 | for (size_t i = 0; i < index; ++i) { 22 | ++it; 23 | } 24 | return it.entry(); 25 | } 26 | 27 | TokenDatabase::Entries TokenDatabase::Find(const uint32_t token) const { 28 | Iterator first = begin(); 29 | while (first != end() && token > first->token) { 30 | ++first; 31 | } 32 | 33 | Iterator last = first; 34 | while (last != end() && token == last->token) { 35 | ++last; 36 | } 37 | 38 | return Entries(first, last); 39 | } 40 | 41 | } // namespace pw::tokenizer 42 | -------------------------------------------------------------------------------- /pw_toolchain/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | package(default_visibility = ["//visibility:public"]) 16 | 17 | licenses(["notice"]) # Apache License 2.0 18 | -------------------------------------------------------------------------------- /pw_toolchain/README.md: -------------------------------------------------------------------------------- 1 | # pw\_toolchain: Pigweed's standard build toolchains 2 | -------------------------------------------------------------------------------- /pw_toolchain/docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-pw-toolchain: 2 | 3 | .. default-domain:: cpp 4 | 5 | .. highlight:: cpp 6 | 7 | ------------ 8 | pw_toolchain 9 | ------------ 10 | The ``pw_toolchain`` module enumerates GN toolchain definitions that may be used 11 | to build pigweed. 12 | 13 | ``pw_toolchain`` defines the following toolchains: 14 | 15 | - arm_gcc_cortex_m4_og 16 | - arm_gcc_cortex_m4_o1 17 | - arm_gcc_cortex_m4_o2 18 | - arm_gcc_cortex_m4_os 19 | - arm_gcc_cortex_m4f_og 20 | - arm_gcc_cortex_m4f_o1 21 | - arm_gcc_cortex_m4f_o2 22 | - arm_gcc_cortex_m4f_os 23 | - host_clang_og 24 | - host_clang_o2 25 | - host_clang_os 26 | - host_gcc_og 27 | - host_gcc_o2 28 | - host_gcc_os 29 | 30 | .. note:: 31 | The documentation for this module is currently incomplete. 32 | -------------------------------------------------------------------------------- /pw_unit_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_add_module_library(pw_unit_test 16 | SOURCES 17 | framework.cc 18 | PUBLIC_DEPS 19 | pw_polyfill 20 | pw_preprocessor 21 | pw_string 22 | ) 23 | 24 | # pw_unit_test overrides the gtest/gtest.h header. 25 | target_include_directories(pw_unit_test PUBLIC public_overrides) 26 | 27 | pw_add_module_library(pw_unit_test.main 28 | SOURCES 29 | simple_printing_main.cc 30 | simple_printing_event_handler.cc 31 | PUBLIC_DEPS 32 | pw_unit_test 33 | PRIVATE_DEPS 34 | pw_preprocessor 35 | pw_string 36 | pw_sys_io 37 | ) 38 | -------------------------------------------------------------------------------- /pw_unit_test/README.md: -------------------------------------------------------------------------------- 1 | # pw\_unit\_test: Lightweight C++ unit testing framework 2 | 3 | The pw\_unit\_test module contains the code for *Pigweed Test*, a 4 | [Googletest](https://github.com/google/googletest/blob/master/googletest/docs/primer.md)-compatible 5 | unit testing framework that runs on anything from bare-metal microcontrollers 6 | to large desktop operating systems. 7 | -------------------------------------------------------------------------------- /pw_unit_test/logging_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #include "pw_unit_test/framework.h" 16 | #include "pw_unit_test/logging_event_handler.h" 17 | 18 | int main() { 19 | pw::unit_test::LoggingEventHandler handler; 20 | pw::unit_test::RegisterEventHandler(&handler); 21 | return RUN_ALL_TESTS(); 22 | } 23 | -------------------------------------------------------------------------------- /pw_unit_test/public_overrides/gtest/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | // 15 | // pw_unit_test exposes a gTest-compatible interface. This file is provided for 16 | // existing projects which #include "gtest/gtest.h" to allow them to compile 17 | // using pw_unit_test as a backend. 18 | #pragma once 19 | 20 | #include "pw_unit_test/framework.h" 21 | -------------------------------------------------------------------------------- /pw_unit_test/py/pw_unit_test/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Pigweed's unit test runner infrastructure""" 15 | 16 | # Import to register the plugin. 17 | import pw_unit_test.test_runner 18 | -------------------------------------------------------------------------------- /pw_unit_test/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """pw_unit_test""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | """Test suite for pw_unit_test module.""" 22 | return unittest.TestLoader().discover('./', pattern='*_test.py') 23 | 24 | 25 | setuptools.setup( 26 | name='pw_unit_test', 27 | version='0.1.0', 28 | author='Pigweed Authors', 29 | author_email='pigweed-developers@googlegroups.com', 30 | description='Unit tests for Pigweed projects', 31 | packages=setuptools.find_packages(), 32 | test_suite='setup.test_suite', 33 | install_requires=[ 34 | 'pw_cli', 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /pw_unit_test/simple_printing_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Pigweed Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | // use this file except in compliance with the License. You may obtain a copy of 5 | // the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations under 13 | // the License. 14 | 15 | #include 16 | 17 | #include "pw_span/span.h" 18 | #include "pw_sys_io/sys_io.h" 19 | #include "pw_unit_test/framework.h" 20 | #include "pw_unit_test/simple_printing_event_handler.h" 21 | 22 | int main() { 23 | pw::unit_test::SimplePrintingEventHandler handler( 24 | [](const std::string_view& s, bool append_newline) { 25 | if (append_newline) { 26 | pw::sys_io::WriteLine(s); 27 | } else { 28 | pw::sys_io::WriteBytes(pw::as_bytes(pw::span(s))); 29 | } 30 | }); 31 | 32 | pw::unit_test::RegisterEventHandler(&handler); 33 | return RUN_ALL_TESTS(); 34 | } 35 | -------------------------------------------------------------------------------- /pw_varint/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | load( 16 | "//pw_build:pigweed.bzl", 17 | "pw_cc_library", 18 | "pw_cc_test", 19 | ) 20 | 21 | package(default_visibility = ["//visibility:public"]) 22 | 23 | licenses(["notice"]) # Apache License 2.0 24 | 25 | pw_cc_library( 26 | name = "pw_varint", 27 | srcs = [ 28 | "varint.cc", 29 | ], 30 | hdrs = [ 31 | "public/pw_varint/varint.h", 32 | ], 33 | includes = ["public"], 34 | deps = [ 35 | "//pw_span", 36 | ], 37 | ) 38 | 39 | pw_cc_test( 40 | name = "varint_test", 41 | srcs = [ 42 | "varint_test.c", 43 | "varint_test.cc", 44 | ], 45 | deps = ["//pw_varint"], 46 | ) 47 | -------------------------------------------------------------------------------- /pw_varint/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | import("$dir_pw_unit_test/test.gni") 17 | 18 | config("default_config") { 19 | include_dirs = [ "public" ] 20 | } 21 | 22 | source_set("pw_varint") { 23 | public_configs = [ ":default_config" ] 24 | public_deps = [ "$dir_pw_span" ] 25 | sources = [ 26 | "public/pw_varint/varint.h", 27 | "varint.cc", 28 | ] 29 | public = [ "public/pw_varint/varint.h" ] 30 | } 31 | 32 | pw_test_group("tests") { 33 | tests = [ ":varint_test" ] 34 | } 35 | 36 | pw_test("varint_test") { 37 | deps = [ ":pw_varint" ] 38 | sources = [ 39 | "varint_test.c", 40 | "varint_test.cc", 41 | ] 42 | } 43 | 44 | pw_doc_group("docs") { 45 | sources = [ "docs.rst" ] 46 | } 47 | -------------------------------------------------------------------------------- /pw_varint/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | pw_auto_add_simple_module(pw_varint PUBLIC_DEPS pw_span) 16 | -------------------------------------------------------------------------------- /pw_varint/README.md: -------------------------------------------------------------------------------- 1 | # pw\_varint: Variable-length integer encoding 2 | -------------------------------------------------------------------------------- /pw_varint/docs.rst: -------------------------------------------------------------------------------- 1 | .. default-domain:: cpp 2 | 3 | .. highlight:: sh 4 | 5 | --------- 6 | pw_varint 7 | --------- 8 | The ``pw_varint`` module provides functions for encoding and decoding variable 9 | length integers, or varints. For smaller values, varints require less memory 10 | than a fixed-size encoding. For example, a 32-bit (4-byte) integer requires 1--5 11 | bytes when varint-encoded. 12 | 13 | `Protocol Buffers `_ 14 | use a variable-length encoding for integers. 15 | 16 | Compatibility 17 | ============= 18 | * C 19 | * C++11 (with :doc:`../pw_polyfill/docs`) 20 | 21 | Dependencies 22 | ============ 23 | * ``pw_span`` 24 | -------------------------------------------------------------------------------- /pw_watch/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("docs") { 18 | inputs = [ "doc_resources/pw_watch_on_device_demo.gif" ] 19 | sources = [ "docs.rst" ] 20 | } 21 | -------------------------------------------------------------------------------- /pw_watch/README.md: -------------------------------------------------------------------------------- 1 | This directory contains the `pw watch` subcommand, which watches the Pigweed 2 | source for changes and re-runs tests. 3 | -------------------------------------------------------------------------------- /pw_watch/doc_resources/pw_watch_on_device_demo.gif: -------------------------------------------------------------------------------- 1 | ../../docs/images/pw_watch_on_device_demo.gif -------------------------------------------------------------------------------- /pw_watch/py/pw_watch/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """Auto-load default plugins for pw_watch.""" 15 | 16 | # Note that these imports will trigger plugin registrations. 17 | import pw_watch.watch 18 | -------------------------------------------------------------------------------- /pw_watch/py/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """pw_watch""" 15 | 16 | import unittest 17 | import setuptools 18 | 19 | 20 | def test_suite(): 21 | """Test suite for pw_watch module.""" 22 | return unittest.TestLoader().discover('./', pattern='*_test.py') 23 | 24 | 25 | setuptools.setup( 26 | name='pw_watch', 27 | version='0.0.1', 28 | author='Pigweed Authors', 29 | author_email='pigweed-developers@googlegroups.com', 30 | description='Pigweed automatic builder', 31 | packages=setuptools.find_packages(), 32 | test_suite='setup.test_suite', 33 | install_requires=[ 34 | 'watchdog', 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /targets/docs/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("target_docs") { 18 | sources = [ "target_docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /targets/docs/empty.bloaty: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | # Empty Bloaty configuration used as the default for the docs target. 16 | 17 | # segment_names must be defined for pw_bloat. Map it directly to segments. 18 | custom_data_source: { 19 | name: "segment_names" 20 | base_data_source: "segments" 21 | } 22 | -------------------------------------------------------------------------------- /targets/docs/target_docs.rst: -------------------------------------------------------------------------------- 1 | .. _chapter-docs: 2 | 3 | .. default-domain:: cpp 4 | 5 | .. highlight:: sh 6 | 7 | ---- 8 | docs 9 | ---- 10 | The Pigweed docs target assembles Pigweed's reStructuredText and markdown 11 | documentation into a collection of HTML pages. 12 | 13 | Building 14 | ======== 15 | To build for this target, change the ``pw_target_config`` GN build arg to point 16 | to this target's configuration file. 17 | 18 | .. code:: sh 19 | 20 | $ gn gen --args='pw_target_config = "//targets/docs/target_config.gni"' out/docs 21 | $ ninja -C out/docs 22 | 23 | or 24 | 25 | .. code:: sh 26 | 27 | $ gn gen out/docs 28 | $ gn args 29 | # Modify and save the args file to update the pw_target_config. 30 | pw_target_config = "//targets/docs/target_config.gni" 31 | $ ninja -C out/docs 32 | 33 | Output 34 | ====== 35 | Final HTML documentation will be placed in the ``gen/docs/html`` directory of 36 | the build. 37 | -------------------------------------------------------------------------------- /targets/host/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("target_docs") { 18 | sources = [ "target_docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /targets/host/host_common.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pigweed/pw_vars_default.gni") 16 | 17 | declare_args() { 18 | pw_build_host_tools = false 19 | } 20 | 21 | # Use logging-based test output on host. 22 | pw_unit_test_main = "$dir_pw_unit_test:logging_main" 23 | 24 | # Configure backend for assert facade. 25 | dir_pw_assert_backend = "$dir_pw_assert_basic" 26 | 27 | # Configure backend for logging facade. 28 | dir_pw_log_backend = "$dir_pw_log_basic" 29 | 30 | # Configure backend for pw_sys_io facade. 31 | dir_pw_sys_io_backend = "$dir_pw_sys_io_stdio" 32 | -------------------------------------------------------------------------------- /targets/host/linux.bloaty: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | custom_data_source: { 16 | name: "segment_names" 17 | base_data_source: "segments" 18 | 19 | rewrite: { 20 | pattern: "LOAD #3" 21 | replacement: "CODE" 22 | } 23 | rewrite: { 24 | pattern: "LOAD #5" 25 | replacement: "RAM" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /targets/host/linux.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("host_common.gni") 16 | 17 | declare_args() { 18 | # Specifies the toolchain to use for this build. 19 | pw_target_toolchain = "$dir_pw_toolchain:host_gcc_og" 20 | } 21 | 22 | pw_executable_config.bloaty_config_file = 23 | get_path_info("linux.bloaty", "abspath") 24 | 25 | pw_automatic_test_runner = get_path_info("run_test", "abspath") 26 | -------------------------------------------------------------------------------- /targets/host/macos.bloaty: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | custom_data_source: { 16 | name: "segment_names" 17 | base_data_source: "segments" 18 | 19 | # TODO(keir): This isn't quite right; in some cases the change from a binary 20 | # diff report shows up in the __LINKEDIT segment. It's not totally clear what 21 | # the right thing to show is for Mach-O. 22 | rewrite: { 23 | pattern: "__DATA" 24 | replacement: "RAM" 25 | } 26 | rewrite: { 27 | pattern: "__LINKEDIT" 28 | replacement: "SYMBOL & STRING TABLES" 29 | } 30 | rewrite: { 31 | pattern: "__TEXT" 32 | replacement: "CODE & READ-ONLY DATA" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /targets/host/macos.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("host_common.gni") 16 | 17 | declare_args() { 18 | # Specifies the toolchain to use for this build. 19 | pw_target_toolchain = "$dir_pw_toolchain:host_clang_og" 20 | } 21 | 22 | pw_executable_config.bloaty_config_file = 23 | get_path_info("macos.bloaty", "abspath") 24 | 25 | pw_automatic_test_runner = get_path_info("run_test", "abspath") 26 | -------------------------------------------------------------------------------- /targets/host/run_test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2019 The Pigweed Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | # use this file except in compliance with the License. You may obtain a copy of 6 | # the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | # License for the specific language governing permissions and limitations under 14 | # the License. 15 | 16 | # Test runner for host Linux/macOS systems. 17 | # Called with the path to a test binary and directly executes it. 18 | "$@" 19 | -------------------------------------------------------------------------------- /targets/host/run_test.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: Copyright 2020 The Pigweed Authors 3 | :: 4 | :: Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | :: use this file except in compliance with the License. You may obtain a copy of 6 | :: the License at 7 | :: 8 | :: https://www.apache.org/licenses/LICENSE-2.0 9 | :: 10 | :: Unless required by applicable law or agreed to in writing, software 11 | :: distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | :: WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | :: License for the specific language governing permissions and limitations under 14 | :: the License. 15 | 16 | :: Test runner for host Windows systems. 17 | :: Called with the path to a test binary and directly executes it. 18 | %* 19 | -------------------------------------------------------------------------------- /targets/host/target_config.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | # This is the target config to import when building for host. All this does is 16 | # import the appropriate target configuration for the current host OS. 17 | # 18 | # Due to GN-isms, lowest-precedence target variable definitions must be imported 19 | # at the deepest point. This causes the following structure: 20 | # 21 | # target_system.gni (e.g. Linux) 22 | # └ host_common.gni 23 | # └ pw_vars_default.gni 24 | # 25 | # This allows host_common to override variables defined in pw_vars_default, 26 | # and target_system to override defaults in host_common. 27 | 28 | # Load target-specific config file for a host desktop system. 29 | if (host_os == "linux") { 30 | import("linux.gni") 31 | } else if (host_os == "mac") { 32 | import("macos.gni") 33 | } else if (host_os == "win") { 34 | import("windows.gni") 35 | } else { 36 | assert(false, "Please define a host config for your system: $host_os") 37 | } 38 | -------------------------------------------------------------------------------- /targets/host/windows.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("host_common.gni") 16 | 17 | pw_automatic_test_runner = get_path_info("run_test.bat", "abspath") 18 | 19 | declare_args() { 20 | pw_target_toolchain = "$dir_pw_toolchain:host_gcc_og" 21 | } 22 | 23 | # This is here as bloaty_config_file cannot be an empty string or GN fails. 24 | # TODO(frolv): Add this file and enable size reports on Windows. 25 | pw_executable_config.bloaty_config_file = 26 | get_path_info("windows.bloaty", "abspath") 27 | -------------------------------------------------------------------------------- /targets/stm32f429i-disc1/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | import("$dir_pw_docgen/docs.gni") 16 | 17 | pw_doc_group("target_docs") { 18 | sources = [ "target_docs.rst" ] 19 | } 20 | -------------------------------------------------------------------------------- /targets/stm32f429i-disc1/py/stm32f429i_disc1_utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | """This package provides tooling specific to the stm32f429i-disc1 target.""" 15 | 16 | from stm32f429i_disc1_utils.unit_test_runner import TestingFailure 17 | from stm32f429i_disc1_utils.unit_test_runner import flash_device 18 | from stm32f429i_disc1_utils.unit_test_runner import run_device_test 19 | from stm32f429i_disc1_utils.stm32f429i_detector import detect_boards 20 | -------------------------------------------------------------------------------- /targets/stm32f429i-disc1/py/stm32f429i_disc1_utils/openocd_stm32f4xx.cfg: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Pigweed Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | 15 | # This openocd configuration is compatible with all STM32F4xx cores. 16 | 17 | interface hla 18 | hla_layout stlink 19 | hla_device_desc "ST-LINK/V2-1" 20 | hla_vid_pid 0x0483 0x374b 21 | 22 | # If PW_STLINK_SERIAL is specified, use that device. 23 | if { [info exists ::env(PW_STLINK_SERIAL)] } { 24 | hla_serial $::env(PW_STLINK_SERIAL) 25 | } 26 | 27 | # If PW_GDB_PORT is specified, use that port. 28 | if { [info exists ::env(PW_GDB_PORT)] } { 29 | gdb_port $::env(PW_GDB_PORT) 30 | } 31 | 32 | transport select hla_swd 33 | 34 | source [find target/stm32f4x.cfg] 35 | 36 | # Use hardware reset. 37 | reset_config srst_only srst_nogate 38 | --------------------------------------------------------------------------------