-
Notifications
You must be signed in to change notification settings - Fork 113
feat: cpp
preprocessor macros: simple file parsing
#1179
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
feat: cpp
preprocessor macros: simple file parsing
#1179
Conversation
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.
Pull Request Overview
This PR introduces support for parsing C preprocessor (CPP) conditional compilation directives in Fortran source files. This enables proper handling of macro-guarded module dependencies when features and profiles are used, preventing build failures when optional modules are conditionally included.
Key changes include:
- Addition of conditional compilation parsing logic to handle nested
#ifdef
,#ifndef
,#if defined()
, and related directives - Integration of preprocessor configuration into source parsing routines throughout the codebase
- Comprehensive test coverage for various conditional compilation scenarios
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
test/fpm_test/test_source_parsing.f90 |
Adds comprehensive test cases for conditional compilation parsing with both simple and complex macro scenarios |
src/fpm_source_parsing.f90 |
Implements core CPP conditional parsing logic with nested block tracking and macro evaluation |
src/fpm_sources.f90 |
Updates source discovery functions to accept and pass through preprocessor configuration |
src/fpm.f90 |
Integrates preprocessor configuration into all source parsing calls throughout the build system |
example_packages/program_with_cpp_guarded_module/ |
Provides example package demonstrating CPP conditional compilation usage |
ci/run_tests.sh |
Adds testing of the new example package to the CI pipeline |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
With the introduction of features and profiles, it will be nearly impossible to avoid parsing preprocessor macro-guarded
module inclusions. This PR introduces the conditional block detection logic to properly handle nested simple conditional blocks and (case-sensitive) macro matching with the cpp preprocessor.
Tests and example packages added. Closes #469.