Skip to content
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

Implement common argument parsing with argparse #146

Merged
merged 5 commits into from
Feb 4, 2025

Conversation

Pennycook
Copy link
Contributor

@Pennycook Pennycook commented Dec 19, 2024

Related issues

Proposed changes

  • Replace extract_defines, extract_include_paths and extract_includes with a simpler argparse-based solution.
  • Renames args to argv to help distinguish between command-line arguments and the result of parse_args().
  • Add unit tests for _parse_compiler_args. The extract_* functions were never tested directly, only ever via other tests.

Aligned with convention used elsewhere, where "argv" is a list[str]
representing the command-line arguments, and "args" is the result of parsing
the contents of argv.

Signed-off-by: John Pennycook <[email protected]>
Instead of writing multiple functions to handle the parsing of -D, -I and
-include arguments, we can construct a simple ArgumentParser. In addition to
being more robust, it should be easier to extent with support for additional
arguments in the future.

Signed-off-by: John Pennycook <[email protected]>
Test handling of -D, -I, -isystem, and -include options.

Signed-off-by: John Pennycook <[email protected]>
@Pennycook Pennycook added the refactor Improvements to code structure label Dec 19, 2024
@Pennycook Pennycook added this to the 2.0.0 milestone Dec 19, 2024
_parse_compiler_args was configured to ignore the first argument, assuming that
it would be the name of the compiler binary.

Everything worked properly for options lists captured from real commands, but
the first argument was being incorrectly stripped from generated from
user-provided options strings.

Signed-off-by: John Pennycook <[email protected]>
@Pennycook Pennycook merged commit 4dfb0c6 into intel:main Feb 4, 2025
3 checks passed
@Pennycook Pennycook deleted the compiler-argparse branch February 4, 2025 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Improvements to code structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants