Call target C preprocessor from a script

Correct. If you execute a command within the environment (PATH) that PlatformIO has created (env.Execute()) it should be fine.

Otherwise, duplicate of Change firmware name based on main.cpp - #2 by maxgerhardt.