How do i compile my code against Mbed 2 C/C++ SDK

In PlatformIO, build support for any framework / SDK is achieved by implement a “builder script”, which is a Python script using the underlying PlatformIO and SCons build system APIs to teach PlatformIO/SCons exactly what files to compile, how they’re compiled, and finally linked together and postprocessed.

That builder script is called from the platform (e.g., platform-ststm32, platform-nordicnrf52, …). For the mbed-os 5/6 framework, as is present at https://github.com/platformio/builder-framework-mbed, that’s currently about 800 lines of Python. That is quite a lot, something like the Arduino AVR builder script is only 190 lines. The mbed os build script does quite some work adapting it to PlatformIO, and that is with the help of importing the native mbed-os Python build packages.

Given that mbed 2 is so much older and 3 or 4 major versions behind the curent one, you will likely need a completely new builder script. Realistically, you can only write that if you have both superb knowledge of the PlatformIO / SCons internal (e.g., here) and the build system for mbed-os 2.

At which point one may also say, why do all this work and not directly use mbed-os’s native build system, or do the work and get it “up to date” on mbed os 6.

In any case, the mbed-os project was halted, killed by ARM almost a year ago.