Custom board variant - pin mapping in ESP32

I’m porting code to custom board not matching any existing board. I have created custom board using Custom Embedded Boards — PlatformIO latest documentation but run problem in espressif32 core with missing pins_arduino.h during compilation (.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-gpio.h:29:10: fatal error: pins_arduino.h: No such file or directory)

Since it is custom board I can not use any existing variant. I have found this topic: Custom nRF52832 board pinout - #8 by maxgerhardt and it looks like espresif32 platform does not accept variants dir change via build.variants_dir.

Is there way to point Platformio to correct variant defininition or the only way would be to copy my custom variant to ~/.platformio/packages/framework-arduinoespressif32/variants? This works, but will fail when framework will be updated/reinstalled…

The post you reference is valid for the Nordic nRF5 Arduino builder script. The Arduino-ESP32 builder script does accept board_build.variants_dir = ....

Make sure you’ve correctly prefixed the option with board_ in the platformio.ini and the variant folder name is as expected (the board definition you’re using → build.variant).