Custom OS and Toolchain definition for embedded application

So I have an embedded project where I’d like to utilize gradle to implement my build. The problem I’m running into is that there is no OS, per se. It’s a small embedded controller where there is no OS, so I want to define my own environment, executable extensions, library extensions, etc. What’s the mechanism to implement a new operatingSystem?