Build is an opinionated c++
build-tool. It uses git
and node.js
. It's made
for use with the datcxx
project.
C++ build tools and package managers are highly ambitious and try to solve a larger set of problems than needed for this project. Let's make something that...
- Uses a subset of
package.json
. - No semver, or package-locks, use git commit hashes.
- No login, no users, no analytics, no fancy features.
npm install -g datcxx/build
All projects must have a package.json.
build -h
Use the init
command to automatically create a package.json
file.
build init
Use the add
command to add a dependency.
build add foo/bar
Adding a dependency with a hash will lock the dependency and install that exact commit at install-time. Without a hash, the dependency will get assigned the latest commit hash of the remote at install-time.
build add foo/bar ceda12f
Use the i
command to recursively install dependencies.
build i
To build your project, don't specify any commands just type build
. Use the
DEBUG=true
environment variable if you want to print what the compiler is
being asked to do.
build
When no command is specified, all flags are passed to the compiler. For example following flags are sent to the compiler.
build -g -O0
Name is required. But unlike npm the name and version do not create a unique identity in the world for your package. In fact, version is not used at all.
Put a description in it. It’s a string. This helps you remember what the package does.
A list of files to include. Nothing is included by default. Does not currently support globs.
A string that specifies the place where the code lives. This is helpful for people who want to contribute.
The “scripts” property is a dictionary containing script commands that are run at various times in the lifecycle of your package. The key is the lifecycle event, and the value is the command to run at that point. The following scripts are supported.
install
Run AFTER the package is installed.test
Run by the npm test command.
You can also create your own arbitrary scripts and run them with the command
build run <script-name>
.
{
"name": "hypercore",
"description": "Hypercore is a secure, distributed append-only log.",
"repository": "[email protected]:datcxx/cxx-hypercore.git",
"dependencies": {
"[email protected]:datcxx/cxx-flat-tree": "c051eac4"
},
"scripts": {
"test": "c++ -std=c++2a test/index.cxx lib/hypercore.so -o test/index && ./test/index",
"greeting": "echo Hello, World"
},
"flags": [
"-shared",
"-o ./lib/hypercore.so",
"-std=c++2a",
"-ferror-limit=2"
],
"files": [
"index.hxx",
"index.cxx"
]
}
Nice to have - as of now there is no caching strategy.