Note: this is only a goal README. Most of things described here are not implemented yet.
Table of contents:
Checkout the simple explaination.
An easy to use and (not yet) powerful C++ build system. It uses JavaScript executed by Node.js to provide powerful scripting language, so you easily setup your project build process.
cpp-build provides object oriented way to represent your applications.
Create Project.js
in main project folder:
const cb = require("cpp-build");
let app = {
name: "ConsoleApp",
language: "C++17",
includeDirectories: [ "include" ],
files: [
"include/PrintHello.hpp",
"src/PrintHello.cpp",
"src/Main.cpp"
]
};
// Export application as a target to build.
// NOTE: first argument has to be "module"!
cb.export(module, app);
Following project structure assumed:
- include/
- PrintHello.hpp (declarations)
- src/
- PrintHello.cpp (definitions)
- Main.cpp (main function)
- Create "build" folder inside main project folder
- Open terminal in "build" folder.
- Execute following command:
node cpp-build ../Project.js -g -b -i
-g
generates project files-b
builds project-i
installs it to default directory
What you can do with cpp-build:
- Write your code
- Tell cpp-build how your project is organised
- Build project on any platform using any tool*
* - compiler or tool must be supported by cpp-build and be able to build your code.
cpp-build is a cross-platform meta build system. It generates build files used by specific compilers or tools.
- GNU Make (generates Makefiles)
- // TODO: expand it.
Use those to quickly introduce yourself.
let workspace = new cb.TargetGroup("GameWorkspace");
let lib = new cb.StaticLibrary("GameEngine");
let app = new cb.Application("Game");
app.link(lib);
workspace.targets = [ lib, app ];
// Setup "lib"...
// Setup "app"...
cb.export(module, workspace);
This requires the external code to export its settings using cpp-build.
let testApp = new cb.Application("Test");
// Setup configuration options
testApp.configuration = {
"gtest.root": ""
};
// To link external libraries we have
// to wait until target is configured.
testApp.on("configured", (cfg) =>
{
// Load google test:
let gtestWks = require(cfg["gtest.root"] + "/workspace.js");
let gtestProj = gtestWks.targets.find( t => t.name == "gtest" );
// Add google test as dependency:
if (gtestProj) {
testApp.link(googleTestProject);
}
else
throw 'google test library project not found.';
}
);
let wks = new cb.TargetGroup("MyWorkspace");
let app = new cb.Application("MyApplication");
let lib = new cb.StaticLibrary("MyLibrary");
wks.targets = [ app, lib ];
app.installs = [
// Installs (recursively) all files from:
// build_output_dir/bin/
// to:
// install_base_dir/bin/cfgName/
{ from: "bin/**", to: `bin/${cb.cfgName}` }
];
lib.installs = [
{ from: "include/**", to: "include" },
{ from: "lib/**", to: `lib/${cb.cfgName}` },
{ from: "bin/**", to: `bin/${cb.cfgName}` },
{ from: "docs/**", to: "docs" }
];
cb.export(module, wks);