Add preprocessor based project content defintition techique
Open, Needs TriagePublic

Description

Andrey Butok requested to implement the following "project content definition" method which is already used by the mbedtls project.

Use-case
This is a compile time configuration technique which enables the definition of what source files affect the build output based on what features are needed to be supported.

Implementation

  1. The content of each source file need to be enclosed by a conditional compilation block. The condition is the defined state of a C macro.
  2. A configuration header captures all configuration macros for the software which are menat to be manually edited. Using the macros mentioned in 1. and further optional pre-processor conditions the system can define which files affect the build output and which do not.

Benefits

  1. Uses standard tools available in any C build environment, and thus it is IDE antagonistic.

Drawbacks

  1. The techniques is not really controlling the build content, just renders the excluded files act like emtpy files. As a result:
    1. Build tool will build files not affecting the build output, which will make the build process longer.
    2. The build system will have no access to this metadata.
      1. It is hard to extract statistics how the build output is affected by some configuration values.
      2. It makes the task of defining the build content split by multiple tools, which makes maintenance harder.
    3. This does not integrates well with GUI tools, i.e. IDEs will not be able to correctly show the status of the file.
  2. Code is harder to read due to ifdef block.
  3. The conditional block renders the file content to be dead code, which is does not play well safety and security related standards (i.e. MISRA)

Thanks, hope it will be implemented.