I dug around a little.
And this is how I got it to work.
- Create a new project in stm32cubeMX app.
I am choosing the STM32F030R8 for my demo and click on "start project"
2.Under Project > Settings
- Select Toolchain / IDE as "Other toolchain (GPDSC)" under the Project tab
- Under Code Generator tab, select the "Copy only the necessary library files" and "Generate peripheral initialization as a pair of .c / .h files per peripheral"
Apply the settings, customize the pinouts, peripherals as per your need. When you are done initializing the MCU, click on the "Generate Code" option.
This is how the project output looks like. A bunch of headers and C files under the "Inc" and "Src" folders.
Now copy the headers and source files under the "src" folder in the Platformio IDE and compile.
Thats all! It should compile without any errors or issues.
(Well, atleast it did so for me)
Hope this helps for anyone else looking for a guide.