aboutsummaryrefslogtreecommitdiff
path: root/pw_string
AgeCommit message (Collapse)Author
2021-01-21pw_span: Provide <span> through pw_polyfillWyatt Hepler
- Have pw_polyfill:overrides depend on pw_span. - Remove explicit deps on pw_span. Change-Id: Ibdd996d2764e737e487de5038cc84bd0f825c882 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/30043 Reviewed-by: Ewout van Bekkum <ewout@google.com> Reviewed-by: Keir Mierle <keir@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2021-01-11pw_status: Replace Status::Ok() with OkStatus()Wyatt Hepler
- Mark Status::Ok() and StatusWithSize::Ok() as deprecated. - Replace Status::Ok() with OkStatus(). - Replace StatusWithSize::Ok() with StatusWithSize(). Change-Id: If7192282446bf6d7f90990bb0b4f1b1b89a9228a Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/29003 Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com> Reviewed-by: Keir Mierle <keir@google.com>
2021-01-08pw_kvs: Make kvs compile with C++14Rob Oliver
A series of small changes to ensure KVS compiles with C++14. Change-Id: Idd514c20583b9f3ed192baa38cc5824e3c1ac1a3 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/27141 Commit-Queue: Rob Oliver <rgoliver@google.com> Reviewed-by: Wyatt Hepler <hepler@google.com>
2020-11-04CMake: Revamp CMake buildWyatt Hepler
- Define CMake cache variables (similar to gn args) for facade backends. - Create simple initial toolchain files for GCC and Clang. - Misc updates to pigweed.cmake and pw_build/CMakeLists.txt. - Add or expand various CMakeLists.txt files. - Watch CMake files in watch.py to support using CMake in pw watch. Change-Id: I490d157485d02811a11f6a3589a0508ea1851f58 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22840 Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com> Reviewed-by: Keir Mierle <keir@google.com>
2020-10-15BUILD.gn files: Improve import formattingWyatt Hepler
The "# gn-format disable" comments are no longer necessary. Delete these comments and reformat with a Vim macro and gn format. Change-Id: Ia62c40ad73eef91187d0d443d6e3b0fa723e5aa9 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21380 Reviewed-by: Armando Montanez <amontanez@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-10-01docs: Make labels consistent; remove boilerplateWyatt Hepler
- Update labels so they use consistent naming. Instead of the copy-and-pasted `chapter` prefix, name labels with a prefix consistent with what they point to: - "module-" for module - "target-" for targets - "docs-" for general documentation - Remove the unnecessary highlight and default-domain directives. Neither is necessary since the Pigweed docs always specify the language in code snippets and other directives. Change-Id: I55c34e9ec919f6f4670e5d3d008e0edf5fecf05b Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19328 Commit-Queue: Wyatt Hepler <hepler@google.com> Reviewed-by: Keir Mierle <keir@google.com>
2020-09-30pw_status: Update Status::CODE to Status::Code()Wyatt Hepler
- Update Status::CODE style to Status::Code() using pw_status/update_style.py. - Make minor adjustments to the pw_assert tests to get them passing. Change-Id: Ie54c3c605178fd1e42c7cedbcff324115f3ed279 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19165 Commit-Queue: Wyatt Hepler <hepler@google.com> Reviewed-by: Ewout van Bekkum <ewout@google.com>
2020-08-08GN build: No longer add public to sourcesWyatt Hepler
Adding public to sources is unnecessary. Clean up the remaining places where this is done. Change-Id: I63f1df64054b319d0a3297f62227756a1e3847ed Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/15665 Reviewed-by: Alexei Frolov <frolv@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-08-05pw_string: Add ByteSpan StringBuilder constructorArmando Montanez
Adds a std::span<std::byte> constructor for StringBuilder to allow construction of a StringBuilder on a byte array. Change-Id: I1d665da4d72680dfe03eddf2554f22a9e51d57fa Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/15540 Reviewed-by: Wyatt Hepler <hepler@google.com> Commit-Queue: Armando Montanez <amontanez@google.com>
2020-07-20pw_hex_dump: Create moduleArmando Montanez
pw_hex_dump provides generalized tools to help dump data as hex for debugging purposes. This first commit adds a class to dump ByteSpans as hex. Example hex dump format: Offs. 0 1 2 3 4 5 6 7 8 9 A B C D E F Text 0000: A4 CC 32 62 9B 46 38 1A 23 1A 2A 7A BC E2 40 A0 ..2b.F8.#.*z..@. 0010: FF 33 E5 2B 9E 9F 6B 3C BE 9B 89 3C 7E 4A 7A 48 .3.+..k<...<~JzH 0020: 18 . Change-Id: I67e9e2a82395cca2bee6650e4a1f73c9f2d7858b Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13581 Reviewed-by: Wyatt Hepler <hepler@google.com> Reviewed-by: Keir Mierle <keir@google.com> Commit-Queue: Armando Montanez <amontanez@google.com>
2020-06-23pw_span: Move pw_string, pw_unit_test to std::spanWyatt Hepler
- Update pw_string and the test framework to std::span. - Have pw_string pass std::span by value, for consistency with other uses in Pigweed. - Recommend using template specializations instead of overloads for custom ToString implementations. Template specializations are preferred because the main ToString definition is a template. Change-Id: Ib67c6bce1752c4a90e2138bdb1f20c6671f55d50 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/12841 Reviewed-by: Keir Mierle <keir@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-06-16pw_string: Print pw_Status like pw::StatusWyatt Hepler
Print pw_Status as a string, like the pw::Status class. Change-Id: Ia18faa78b0c0a26354b978108841ec4d7191557b
2020-06-16Remove legacy_target.gniArmando Montanez
Transition to args is done, so this import is no longer needed. Change-Id: Id42e06ec9fcc16eace2cc7ef51a5dacaf012147a
2020-06-16Don't declare pigweed variables as globalsArmando Montanez
Require targets to explicitly import pigweed variable definitions. This moves out some necessary logic from the BUILDCONFIG.gn file. Change-Id: If9c9fe5a680cc9d897a0e8a55889873be618ed84
2020-06-16pw_build: Switch to pw_* target typesAlexei Frolov
This change replaces the implicit overrides of the default GN target types in BUILDCONFIG.gn with explicit pw_* versions. This is done to allow Pigweed to build within larger GN projects without modifying their BUILDCONFIG files. Change-Id: I1d1e41d5e9bde8fe076f7031f3c2b98b9630ff70
2020-05-31roll: clangRob Mohr
From: git_revision:65f58878e72a40d68ef3899c766846ee9ec7cf29 To: git_revision:dd484baffdf4a92e564c38a17d35a742e633b0e0 CQ-Do-Not-Cancel-Tryjobs: true Change-Id: Id143184f2eb6ca9bdd7f71d72bf03c57459e768c
2020-04-24Allow-list unsigned integer overflows.Aaron Green
This CL adds the 'no_sanitize("unsigned-integer-overflow")' Clang/LLVM attribute to several locations that intentionally rely on that behavior. From https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html: "this is not undefined behavior, but it is often unintentional." By using an explicit allow-list, we should still be able to detect the latter case. Change-Id: I7d7da40c73fd22b6b29196dc4788eb00fca61439 Bug: 190
2020-04-07Many changes to support stricter depsRob Mohr
* Split pw_assert targets as in pwrev/9000. * Add many missing dependencies (mostly on //pw_unit_test) * Added visibility and licenses to pw_minimal_cpp_stdlib/BUILD * Used explicit template params in pw_result/result_test.cc * Added missing #include of pw_kvs/pw_kvs_private/macros.h Change-Id: I9bdc875b585e47792ca926f7c75cfe055b02fa48 Bug: 101
2020-03-19pw_bloat: Remove .rst from generated size reportsAlexei Frolov
This change removes the .rst extension from the ReST size report files generated by pw_bloat to prevent Sphinx from checking that they've been added to a toctree. (Apparently including a file doesn't count as using it.) Change-Id: I4edc2db832bac0f370f563ac4f5c68692ad6f85e
2020-03-18pw_string: Fix ToString for scoped enumerationsWyatt Hepler
Scoped enumerations do not implicitly convert to their underlying type. Change-Id: Icdfeab047d857a16f4d9339d384fd206340015f4
2020-03-17Docs: Add missing RST docsArmando Montanez
Adds dcos.rst files for all modules lacking documentation. Change-Id: Ief5594831d31fcb876381a4a3886382fab7d595e
2020-03-05Add or expand docs.rstWyatt Hepler
Change-Id: I18d1529088beb41b37be00a77ba8999f6b6f810a
2020-03-02Add a few missing README.md filesWyatt Hepler
Change-Id: Idf9c70e5bf062150abfeae84c3fe0794062872bc
2020-02-28Roll GN to 239533dRob Mohr
This caused gn format to flag many things which were also fixed. Change-Id: Ie1d9081a1b08047bec52c60f54d2a94366be1ba6
2020-02-25pw_status: StatusWithSize constantsWyatt Hepler
- Provide StatusWithSize constants that can be used similarly to Status::Codes. For example, StatusWithSize::DATA_LOSS constructs a StatusWithSize with status DATA_LOSS and size 0. - Remove the default constructor argument for the size. Use the constants instead. - Update uses of StatusWithSize(Status::X) to use StatusWithSize::X. Change-Id: I901b7bb0bbbb4fde52f6b3acc3047f366b250515
2020-02-14Remove StatusWithSize implicit conversionsWyatt Hepler
- Disallow implicit conversions between Status and StatusWithSize, which can be problematic. - Add TRY_WITH_SIZE to pw_kvs to handle returning StatusWithSize from functions. - Make zero the default size argument for StatusWithSize. - Expand tests for StatusWithSize. Change-Id: Ia1c36e5a39402a50138d93e89afbaa5e772adb8a
2020-01-24pw_string: Remove problematic testWyatt Hepler
Remove a test that attempts to trigger a negative (error) return value for snprintf. The format strings that trigger these errors vary by platform, and a format that returns a negative result on one platform (Linux) may crash another (Windows). Change-Id: I7b60bc301cd534d0e78228829ea6288687e05c43
2020-01-24pw_string: Rename va_list Format to FormatVaListWyatt Hepler
On Windows, sometimes the va_list overload would be used when formatting with a single argument. To avoid potential conflicts like these, the va_list versions of string::Format and StringBuilder::Format are renamed to FormatVaList. Change-Id: Id29fae21b13ed420b13841a479e3748a1d3b91ce
2020-01-22Initial Windows GN buildAlexei Frolov
This change configures the Windows host target for GN. It should allow building unit tests for the host. Change-Id: Ib92c9a83b9b858a9b7ed55487199c63896580af1
2020-01-16GN build: Override built-in targetsWyatt Hepler
- Override built-in targets, which gives more flexibility than set_defaults. - Provide the default C++ in the toolchain, which can be overridden by explicitly specifying a config on a target. - Remove the C++17 default flags from public configs, since it is no longer needed. Change-Id: If211bada971c46cef83909bf15811a4f2c1eb7fd
2020-01-09pw_string: Add tests missing from test groupWyatt Hepler
Change-Id: Ifbe35c8e5c32014ffe30a7755482a7e3906414ce
2020-01-06pw_varint: use std::byte instead of uint8_tAlexei Frolov
This change switches pw_varint to using spans of std::byte instead of uint8_t for encoding and decoding. The pw_protobuf module, which uses pw_varint, is also updated. A ToString formatter for std::byte is also added to pw_string (required to use std::byte in unit test EXPECT statements). Change-Id: I198370eecdabde32a85987dda98aed84c85b9c91
2020-01-06Bazel: Move include paths to librariesWyatt Hepler
Instead of having a global list of -I include paths, have each library provide a -I for the public/ directory using the includes argument. Change-Id: I2e321752906920cd94beaaab97b8796af85078e4
2020-01-04Basic CMake buildWyatt Hepler
- Automatically add simple modules with pw_auto_add_simmple_module. - Define libraries in a module with pw_add_module_library. - Define tests and test groups with pw_add_test and pw_add_test_to_groups. - Tests execute with full Ninja dependency resolution, as in the GN build. - Add CMakeLists.txt for existing modules. - Currently there is no support for targets, but these libraries would be trivial to integrate with an existing CMake build. Change-Id: If73d8b61bce88f91141737eb773f1ebce3a7676e
2019-12-18string: main is already defined in pw_test templatePaul Mathieu
Change-Id: Ib86055620aef1679cb81a3189159b5c9667aedad
2019-12-17Add a few files that were missing from the buildWyatt Hepler
Change-Id: I102758ecf16ecda1b28f331fc307e72bdb2b1eef
2019-12-09Expand docs for a few modulesWyatt Hepler
- Add missing README.md for a few modules. - Start or expand docs.rst. Change-Id: Ic13c5f71f02259205ba990c93e0403d43f7b44b1
2019-12-05Apply pw format to the repositoryWyatt Hepler
Change-Id: I3c8e4f956dfe6c9e81d3069f72c30c5950852074
2019-12-04Config bazel for pw_bloaty and size_report.Rob Mohr
Fill out pw_bloaty/BUILD and add pw_string/size_report/BUILD. Change-Id: I5ff98de0a452491cdff595ad56ee7365f40590dd
2019-12-03pw_string: Fix test for limited snprintfsWyatt Hepler
snprintf should return a negative number if there is a formatting error. Limited snprintf implementations may not detect these errors. This caused the test to fail on the STM32 Discovery F429i. Change-Id: I1da8593c258508c0d3e2fa6c440a58493ce15597
2019-12-02Fix bazel build.Rob Mohr
pw_string/util_test.cc was not tested and pw_varint had no BUILD file. Change-Id: Ibaf5c05d3876b6cef5eb1fc70f644f03468bca2b
2019-11-27Fix copyright noticesWyatt Hepler
- Add missing copright header in conf.py. - Fix inconsistent copyright notice line breaking. Change-Id: Ib78f7768643069c49ff986a48a176df9fd06e891
2019-11-27Bazel build fixes.Rob Mohr
Clang-tidy complains about operator=() not returning *this, even though that's what it was doing anyway. Then add a direct dependency, add a header to a library, and sync up argument names in a method declaration with the definition. Change-Id: Ib64f050ae74309640a4ae1346e617a932377f63e
2019-11-26pw_string: start docs; StringBuilder size reportWyatt Hepler
Change-Id: Id1dbc070b14a85aeb782606e85d566ed0347fcd4
2019-11-25pw_string: StringBuilder utility classWyatt Hepler
StringBuilder can be used to flexibly and safely build strings in fixed-size buffers. Change-Id: Ie4453e1bcd11ef522bb0211304e9cf758ac17827
2019-11-22pw_string: Handle nullptr C stringsWyatt Hepler
Change-Id: Ifa4c3076b4a6b7f4f1016611601df236bbfb3e26
2019-11-21unit_test: allow targets to specify their own test mainPaul Mathieu
This allows having test-specific, per-target init logic. Kept the existing test main as default. Change-Id: I418dc4f9eefe0bc9d66fcb24d6c4573757f37144
2019-11-19Size report for pw::string::FormatWyatt Hepler
Add size report comparing pw::string::Format to std::snprintf. Report with arm-none-eabi-gcc at -Os: Using pw::string::Format instead of snprintf ──────────────────────────────────────────── ┌────────────────────────────┬───────────┬────────┬───────┬────────┐ │ Label │ Segment │ Before │ Delta │ After │ ├════════════════════════════┼═══════════┼════════┼═══════┼════════┤ │ One string, return size │ SEG FLASH │ 2,840 │ +80 │ 2,920 │ ├────────────────────────────┼───────────┼────────┼───────┼────────┤ │ Ten strings, handle errors │ (all) │ (same) │ 0 │ (same) │ ├────────────────────────────┼───────────┼────────┼───────┼────────┤ │ Fifty calls, same buffer │ SEG FLASH │ 3,816 │ -72 │ 3,744 │ └────────────────────────────┴───────────┴────────┴───────┴────────┘ Change-Id: Id484530320b0334cddf676a49ad79444fbbbde9b
2019-11-19Define pw_test_group templateAlexei Frolov
This change adds a GN template to the pw_unit_test module which defines a group of unit tests. The template creates a generated_file target with JSON metadata for the unit tests and dependencies within the test group. These metadata files are intended to be parsed by the test runner script to run unit tests outside of GN. A pw_test_group target is added to each of the existing modules which have unit tests. Change-Id: I363b937da365d0a3482a979feace18ecba1807a9
2019-11-19Move loads to beginning of BUILD files.Rob Mohr
Change-Id: Idb918a48cfe6149f624295f6712fbf0a3a36a7ff