Three years later... built-in variables time again!
I've reviewed the code again and it looks like where I'm stuck with built-ins is applying the macro replacement, more precisely with understanding where those replacements may and may not occur.
In C::B sources everything is built around MacrosManager and it's doing a lot of different things inside for different purposes so it's hard to figure out what interactions with MacrosManager are related to built-in variables and probably user variables too.
Here's a quote from C::B wiki
Code::Blocks treats the following functionally identical character sequences
inside pre-build, post-build, or build steps as variables:
$VARIABLE
$(VARIABLE)
${VARIABLE}
%VARIABLE%
Variable names must consist of alphanumeric characters and are not case-sensitive.
Variables starting with a single hash sign (#) are interpreted as global compiler
variables. The names listed below are interpreted as builtin types.
Variables which are neither global user variables nor builtin types are replaced
with a value provided in the project file, or with an environment variable if the
latter should fail.
Per-target definitions have precedence over per-project definitions.
It's pretty clear how to process with pre-build and post-build steps as these are just user provided scripts.
However it is not clear to me what should I do about build steps.
The main question is where built-in and user variables may and may not appear?
I'm already setting up all variables I know how to define but I can't decide where exactly should I apply macro expansion.
Should it be every GNU Make macro value and every build instruction in every rule?