I figured it out after inpecting the STM8 architecture examples, and I have implemented similar for mcs51 as shown below. It seems to take the value from the platformio.ini [env:BoardName] section headings but it capitalizes them before injecting them into the environment.
#if defined(N76E003)
#include "n76e003.h"
#define ledPin P14
#define INIT_PIN P1M1 &= 0xFE; P1M2 &= 0xFE;
#elif defined(STC15F104W)
#include "STC15xWES.h"
#define ledPin P33
#define INIT_PIN //No pin init needed
#elif defined(STC15W408AS)
#include "STC15xA.h"
#define ledPin P10
#define INIT_PIN //No pin init needed
#else // GenericMCS51
#include <mcs51/8051.h>
#include <mcs51/8052.h>
#define ledPin P1_0
#define INIT_PIN //No pin init needed
#endif