-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Team 2 New Language Test Files #12
base: team2-homework1
Are you sure you want to change the base?
Team 2 New Language Test Files #12
Conversation
GitHub Actions: Prevent ctest invocation error on macOS
This adds `override` statements, and removes an un-necessary destructor declaration from status_printer.h in order to remove annoying compiler warnings when building Ninja tests with CMake with recent compilers. For example, clang 16.0 complains with: ``` /path/to/ninja/src/status_printer.h:29:16: warning: 'EdgeAddedToPlan' overrides a member function but is not marked 'override' [ -Winconsistent-missing-override] virtual void EdgeAddedToPlan(const Edge* edge); ^ ``` The root issue is that while libninja is compiled explicitly for C++11, which disable the warning, the tests themselves are not, since they rely on GTest which now requires C++14, and thus the standard being used is determined by the compiler's default configuration.
This field is unused. This patch removes compiler warnings when building with recent compilers (e.g. Clang 16.0)
It was declared in an anonymous namespace, and nothing uses it anymore, removes a compiler warning.
Technically, these are not required since Ninja is built with -std=c++11, but using these directives is good practice to clarify the code and avoid simple human errors.
Remove warnings
Add a new class to wrap the logic needed to implement the `inputs` tool correctly (see Issue ninja-build#2482 for details), and provide a unit-test for it.
This uses the InputsCollector class introduced in the previous patch to implement the tool properly. Results are still shell-escaped and sorted alphabetically. Fixed ninja-build#2482
Add new options to the `inputs` tool in order to change the format of its output: - `--no-shell-escape` to avoid shell-escaping the results. - `--dependency-order` to return results in dependency order, instead of sorting them alphabetically. - `--print0` to use \0 as the list separator in the list, useful to process the target paths with `xargs -0` and similar tools.
Use C string macros to hold ANSI escape sequences in order to make the test much easier to understand and follow. NOTE: This does not change the test in any way!
Move the function to its own source file since it is no longer trivial (and will get optimized in future patches). + Add a new ElideMiddleInPlace() function that doesn't do anything if no elision is required + use it in status.cc. + Add a new elide_middle_perftest program to benchmark the performance of the function. On my machine, the 'avg' result is 159.9ms.
Add a fast-path for the case where there is no escape sequence in the input, that avoids un-necessary string allocations. Properly handle ANSI color sequences that appear in the elided part of the input string. They *must* be preserved to ensure that the right span is printed with the right color. For example, consider the following input: |GREEN|aaaaaaaaaaaaa|RED|bbbbbbbbbbb|BLACK| With different levels of elision: max_width=0 -> |GREEN|RED|BLACK| instead of "" max_width=5 -> |GREEN|a..|RED|b|BLACK| (this was |GREEN|a..b|BLACK| before this fix) Moreoever, do not call std::regex_iterator::str() to avoid un-necessary string allocations and concatenations. With this patch, 'elide_middle_perftest' goes from 159.9ms to 87.1 ms on my machine (x1.8 faster)
Get rid of std::regex and std::vector usage in ElideMiddleInPlace() function. These are replaced with custom iterator classes that do not perform any memory allocation at runtime. Instead the input string will be parsed twice (once to determine the visible width, and another time to create the elided result string). With this patch, elide_middle_perftest goes from 87.1ms to 15.0ms on my machine (x5.8 faster!). This also removes 65 kiB from the stripped Linux binary for Ninja (!)
Just check for the ESC character in the `output` string, if none is present, or if the terminal supports color, avoid unnecessary busy work (string allocations and parsing).
…ddle Faster elide middle implementation
For most actions, the depfile will be in the same directory as one of its outputs, and their parent directory will be created by Ninja before running the command. However, this is not always the case. In particular, the GN build tool is changing its Ninja build plan generation logic, switching from using stamp files to phony targets, after issue ninja-build#478 was fixed in Ninja. For additionnal context see https://gn-review.googlesource.com/c/gn/+/11380. The newly generated build plans trigger this condition more frequently, which results in flaky build failures for large GN-based projects such as Fuchsia. This patch ensures the depfile's parent directory is always created before the command is launched to get rid of the issue entirely.
…directory Ensure depfile's parent directory is created before running an action.
Fix `inputs` tool logic and add new formatting options.
- build dependencies if they dont exist
For future commits, consider adopting the |
|
||
PHONY(clean, "clean_rule"); | ||
RULE(clean_rule, | ||
shadowdash::constant("rm", 2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to have a method that calculates the length of each string instead of manually counting and passing the length.
Correctness:
Readability:
Testing:
|
std::optional<bool> restat_{false}; | ||
std::optional<std::string_view> rspfile_; | ||
std::optional<std::string_view> rspfile_content_; | ||
std::optional<std::string_view> pool_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you further consider make 'pool' a separate rule, in parallel with RULE, BUILD, VAR, DEFAULT, etc.?
The overall functionality looks good, and thank you for the substantial work. I would like to make some additional comments based on Jasmine and Shihui's thorough review.
|
ec109b0
to
d497a69
Compare
…ild issues and handles creating driectories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please checkout https://docs.google.com/document/d/11e8zR3kcm7B-D6brAH_D4OgtYBEf94GZwQIXrnti5hM/edit?tab=t.0 and address the items that apply to you. not all of them necessarily do, but some do... the i will look again
Newest PR: PR23 |
@ Marwan AbdElhameed
@ Ricky Zhang