First, we need to write a manifest file.
All we need to do is declare the properties for our main window, and how to build the program.
hello_world/hello_world.manifest
1 2 3 4 5 6 | [build] output = "Hello World.esx"; source = "hello_world/main.cpp"; [window mainWindow] title = "Hello, world!"; |
Then, we write the program itself.
hello_world/main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // Include the API header. #include "../api/os.h" // Include the automatically-generated manifest header. #define OS_MANIFEST_DEFINITIONS #include "../bin/OS/hello_world.manifest.h" void ProgramEntry() { // Create a window using the mainWindow template from the manifest. OSObject window = OSCreateWindow(mainWindow); // Create a container grid, and make it the window's root grid. OSObject grid = OSCreateGrid(1, 1, OS_GRID_STYLE_CONTAINER); OSSetRootGrid(window, grid); // Create a label, and add it to the grid. OSAddControl(grid, 0, 0, OSCreateLabel(OSLiteral("Hello, world!")), OS_CELL_FILL); // Finally, process messages from the window manager until the program exits. OSProcessMessages(); } |
Finally, we add a line to compile.sh to build the program.
1 | ./manifest_parser hello_world/hello_world.manifest bin/OS/hello_world.manifest.h |
...and we have a program!