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

Refactor "target_config.c" logic to avoid #include of data fragments #1170

Closed
jphickey opened this issue Feb 16, 2021 · 0 comments · Fixed by #1174
Closed

Refactor "target_config.c" logic to avoid #include of data fragments #1170

jphickey opened this issue Feb 16, 2021 · 0 comments · Fixed by #1174
Assignees
Milestone

Comments

@jphickey
Copy link
Contributor

jphickey commented Feb 16, 2021

Is your feature request related to a problem? Please describe.
The content of the various CONFIGDATA global data structures is dynamically generated from a combination of build scripts, some which run at prep/generation time and some which run at build time.

The pattern currently used here is that the scripts generate "fragment" data files that only contain the dynamic content, without any C declarations or any other syntax. This is then paired/combined with the target_config.c file which is a regular version-controlled file that has the basic structure and declarations (i.e. all the non-dynamic bits) and uses #include to pull in the data fragments where needed (i.e. a "fill-in-the-blank" approach).

This works well but there are some rules against using the #include directive with anything other than an normal/conventional fully formed C header file (i.e. it has .h extension, fully self contained, syntactically correct, standalone, include-able by any C source file at will). So a "dynamic data fragment" file which is implemented here doesn't meet the criteria.

Describe the solution you'd like
Have the build system generate fully-formed source files before passing to C compiler in some way.

Currently evaluating/considering several approaches or combination thereof.

  1. Put more of the non-dynamic "C" content (structure) into CMake configure_file templates, generating a separate but fully-resolved .c source for each object that has dynamic content.
  2. Pass the file through another explicit macro-processing step (such as C preprocessor or m4) before compiling (basically introduce another layer of indirection) to generate a final file.

Either way the result should be a fully formed .c/.h file without any #include in its body - as all data items should be "filled in" already - which is then built and linked as the current file is.

Requester Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey self-assigned this Feb 16, 2021
jphickey added a commit to jphickey/cFE that referenced this issue Feb 17, 2021
Rework the dynamic content so it is generated entirely via a
CMake "configure_file()" command into a C source file (.c) that
can be built as normal.

This removes the need for inline `#include` statements to pull
in data fragments to fill in the data.
jphickey added a commit to jphickey/cFE that referenced this issue Feb 18, 2021
jphickey added a commit to jphickey/cFE that referenced this issue Feb 26, 2021
Rework the dynamic content so it is generated entirely via a
CMake "configure_file()" command into a C source file (.c) that
can be built as normal.

This removes the need for inline `#include` statements to pull
in data fragments to fill in the data.
jphickey added a commit to jphickey/cFE that referenced this issue Mar 3, 2021
Rework the dynamic content so it is generated entirely via a
CMake "configure_file()" command into a C source file (.c) that
can be built as normal.

This removes the need for inline `#include` statements to pull
in data fragments to fill in the data.
@skliper skliper added this to the 7.0.0 milestone Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants