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

makedep: Include support for CPP condition blocks #533

Merged
merged 2 commits into from
Dec 15, 2023

Conversation

marshallward
Copy link
Member

@marshallward marshallward commented Dec 13, 2023

This patch adds support to makedep for handling most #ifdef-like condition blocks. The following preprocessing commands are handled:

  • #define / #undef
  • #ifdef / #else / #endif

A new flag is added to provide defined macros (-D), and is chosen to match the cpp flag, so that flags can be shared across programs.

Macros are tracked in a new internal variable and are used for #ifdef testing. Nested condition blocks are supported by using an internal stack of the exclusion state.

Certain cases are still not handled.

  • #if blocks containing logical expressions are not parsed.
  • CPP content inside of #include is ignored.

No doubt many other cases are still unconsidered, such as exotic macro names.

The autoconf builds use this feature by passing the generated $(DEFS) argument to makedep. This is suitable for now, but we may need to consider two cases in the future:

  • Macros defined in $CPPFLAGS are currently ignored, and perhaps they should be included here. The risk is that it may contain non-macro flags.

  • At some point, DEFS could be moved to a config.h file, and DEFS would no longer contain these macros. (Note that this is very unlikely at the moment, since this feature only works with C.)

@marshallward
Copy link
Member Author

Oh, I also removed the script_path argument from create_deps since it didn't seem to be used for anything.

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7877292) 37.45% compared to head (42ab2ed) 37.45%.

Additional details and impacted files
@@            Coverage Diff            @@
##           dev/gfdl     #533   +/-   ##
=========================================
  Coverage     37.45%   37.45%           
=========================================
  Files           270      270           
  Lines         79625    79625           
  Branches      14824    14824           
=========================================
  Hits          29826    29826           
  Misses        44251    44251           
  Partials       5548     5548           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marshallward marshallward changed the title Include support for CPP condition blocks makedep: Include support for CPP condition blocks Dec 14, 2023
This patch adds support to makedep for handling most #ifdef-like
condition blocks.  The following preprocessing commands are handled:

* #define / #undef
* #ifdef / #else / #endif

A new flag is added to provide defined macros (-D), and is chosen to
match the `cpp` flag, so that flags can be shared across programs.

Macros are tracked in a new internal variable and are used for #ifdef
testing.  Nested condition blocks are supported by using an internal
stack of the exclusion state.

Certain cases are still not handled.

* #if blocks containing logical expressions are not parsed.
* CPP content inside of #include is ignored.

No doubt many other cases are still unconsidered, such as exotic macro
names.

The autoconf builds use this feature by passing the generated $(DEFS)
argument to makedep.  This is suitable for now, but we may need to
consider two cases in the future:

* Macros defined in $CPPFLAGS are currently ignored, and perhaps they
  should be included here.  The risk is that it may contain non-macro
  flags.

* At some point, DEFS could be moved to a config.h file, and DEFS would
  no longer contain these macros.  (Note that this is very unlikely at
  the moment, since this feature only works with C.)
@adcroft
Copy link
Member

adcroft commented Dec 14, 2023

@adcroft adcroft merged commit 7d334f8 into NOAA-GFDL:dev/gfdl Dec 15, 2023
14 checks passed
@marshallward marshallward deleted the makedep_cpp_ifdef branch May 8, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants