#define BOB_IMPLEMENTATION
#include "bob.hpp"
using namespace std;
const string CC = "gcc";
const vector<string> CFLAGS = {"-Wall", "-Wextra", "-O2"};
const auto build_objs =
Recipe({
"./build/main.o",
"./build/other.o"}, {
"./src/main.c",
"./src/other.c"},
[](const vector<path> &inputs, const vector<path> &outputs) {
assert(inputs.size() == outputs.size());
for (int i = 0; i < inputs.size(); ++i) {
runner.
push(
Cmd({CC,
"-c", inputs[i].string(),
"-o", outputs[i].
string()}).push_many(CFLAGS));
}
});
const auto build_main =
Recipe({
"main"}, {
"./build/main.o",
"./build/other.o"},
[](const vector<path> &inputs, const vector<path> &outputs) {
assert(outputs.size() == 1);
auto cmd =
Cmd({CC,
"-o", outputs[0]});
for (const auto &input : inputs) {
cmd.
push(input.string());
}
});
int main(int argc, char *argv[]) {
GO_REBUILD_YOURSELF(argc, argv);
build_objs.build();
}
A class for running many commands in parallel.
Definition bob.hpp:437
bool run()
Runs all commands in the runner concurrently.
void push(Cmd cmd)
Push a single command to the runner.
Represents a command to be executed in the operating system shell.
Definition bob.hpp:287
Cmd & push(const string &part)
A build recipe that defiles how to produce outputs from inputs.
Definition bob.hpp:509
void build() const
Builds the outputs from the inputs using the recipe function.
Contains the functionality of the Bob build system.
Definition bob.hpp:47