My build system has two targets: "perception" (my OS) and "local" (the host OS, where it calls the system's C++ compiler) - a secondary goal is to one day be able to build hobby C++ programs and be able to compile it both for my OS and locally! There are three configurations: "optimized" (which does whole program optimization), the default (fast build), and "debug" (symbols and stack traces.)PeterX wrote:Only thing: How do you know which object file should end where? I mean: If you have several cpp/c/asm files and want to link the resulting object files to a complete program, you have to tell it explicitely, or not?
By build system creates a temp directory called "build/" which has some interesting things in it:
- <target-configuration>/ - A mirror of the "source/" tree where the object files go. e.g. "source/abc/def.cc" turns into "build/perception-optimized/abc/def.cc.o".
- <target-configuration>/dependencies.json - A map of source file => dependent files (headers). GCC can output all the header files that a source file depends on. I read it, store it in here, and use it to determine if to rebuild a source file if any of the dependent timestamps are newer than the object file.
- <target-configuration>.lib - (For libraries) The object files linked together into a single object.
- <target-configuration>/.app/.exe - (For programs) The final executable.
Usage is:
Code: Select all
# Builds application "Hello World" for the local host with all optimizations and runs it locally.
./build run --opt --local Hello World
# Fast builds everything for Perception, turns it into an OS image.
./build all
# Builds everything with optimizations, turns it into an OS image, and starts QEMU.
./build run --opt
# Builds the "musl" library
./build library musl
# Builds the application "Hello World"
./build application Hello World