The following examples are for build2
beginners who just want to work with this project using build2
, and for maintainers who want to maintain the build2
packages of this project.
For more info, read build2
's documentation, in particular the build-system's manual.
-
If you don't already have a
build2
project, usebdep new
to immediately create a new "hello world" project. For example:bdep new myproject cd myproject
-
Add this line in your project's
./manifest
:depends: range-v3 ~0.11.0
(Of course you can use another version if it's available, see
build2
's documentation for the versions constraints) -
Then optionally specify how to find the package by adding in
./repositories.manifest
either:- to get it from
https://cppget.org
(assuming a published package exist in theapha
repo - it will be instable
once it reaches v1.x):: role: prerequisite location: https://pkg.cppget.org/1/alpha
- to get it from this git repository (here we'll us the
master
branch as an example):: role: prerequisite location: https://github.com/build2-packaging/range-v3.git#master
Specifying the repository in
repositories.manifest
will make all developers who want to work on your project to automatically fetch that package the specified repository without other operations, so it's a good default.- Another option (more for advanced
build2
users) is to add one of the repositories to your configuration manually usingbpkg add [...]
.
- to get it from
-
To make one of your target depends on the library, in the
buildfile
defining that target:import rangev3 = range-v3%lib{range-v3} lib{mylibrary} : $rangev3
The first line
import
s the library targetlib{range-v3}
from the packagerange-v3
. The second line specify thatlib{range-v3}
is a prerequisite oflib{mylibrary}
.
At this point, the C++ files defined as prerequisite of lib{mylibrary}
can use:
#include <range/v3/all.hpp> // For example, get everything.
You can now try to build your project (using b
or bdep update
), which will automatically first invoke bdep sync -f
to update your dependencies as specified.
(There are variations to these instructions. See build2
's build-system manual for details.)
-
Clone this repository (at a branch providing
build2
files), for example:git clone https://github.com/build2-packaging/range-v3.git#master range-v3 cd range-v3
-
Initialize the project in a configuration:
This means create or reuse a configuration directory and add the project in it to be configured. As a shortcut, it can be done in one command:
bdep init ...
.As an example, let's initialize the project to build with clang in C++17:
bdep init -C ../build-myconfig cc config.cxx=clang++ config.c=clang config.cxx.std=17
Note that you can initialize one project in more than one configurations.
-
You can now start to work on the project:
b
orb update
to build,b clean
to clean the generated files;b test
to build the test and run them all;b install config.install.root=../path/to/install/dir
to install the built project somewhere;b clean update test install config.install.root=../path/to/install/dir
to do these operations sequentially;
-
You can initialize the project in different configurations (clang in debug, msvc in release, etc.), then use
bdep update -a
,bdep test -a
, etc. to build and test on all these configurations. Seebdep
documentation or thebuild2
toolchain introduction.
You can just build, test, install the library without setting up a project using build2 (which is useful for implementing CI, for example, or when you just wanting to install a specific version in the system).
-
Create (or reuse) a
build2
configuration that will be used to build, test and install the package. As an example, let's make a configuration building with clang in C++17:mkdir build-clang cd build-clang bpkg create cc config.cxx=clang++ config.c=clang config.cxx.std=17 [...]
-
Then depending on how you prefer to acquire the package, either:
- Fetch and build range-v3, for example the version currently in branch
master
:bpkg build https://github.com/build2-packaging/range-v3.git#master
- Or add
https://cppget.org
repository, fetch and build the package - for example if the package is available in thealpha
repo:bpkg add bpkg add https://pkg.cppget.org/1/alpha bpkg fetch bpkg build range-v3
- Fetch and build range-v3, for example the version currently in branch
-
At this point, you might want to check that the tests run, at least for that configuration:
bpkg test range-v3
-
Install that version of range-v3 in
../path/to/install/dir
bpkg install range-v3 config.install.root=../path/to/install/dir
build2
provide a CI server open for submissions from any open-source project.
When working with a unpublished version of this range-v3
repository, you can send this specific revision for CI by:
-
Make the current revision accessible publicly so that the server can retrieve it. For example, push that specific commit somewhere in a github.com repository which is publicly accessible.
-
In the directory of the project:
bdep ci
And just follow the instructions.
See bdep ci
's manual for more details.
This is for the owners/maintainers of this project.
Note: you must have write-acccess to the repository to be allowed to complete the publication submission.
-
Before submitting the package, make sure the information of the package are up to date:
- Update the
version
field in./manifest
(and commit); - Make sure you are at the right git revision and make sure it's available publicly online.
- Ideally (this is optional but helps tooling), make sure there is a version tag pointing at the commit to publish.
Note: these could be done automatically using
bdep release
but this project is not maintained usingbuild2
so it's probably better to update the manifest manually. - Update the
-
Submit the package for publication (to https://cppget.org by default):
bdep publish
And follow the instructions.
See bdep publish
's manual for details.