Boost.GIL is a member of Boost libraries.
If you wish to contribute a new feature or a bug fix, please follow the workflow explained in this document.
git
command line basics.First, you need learn some minimal basics of the modular Boost super-project workflow.
The following steps are based on the official Boost Getting Started.
NOTE: For brevity, commands below use notation for POSIX-like operating systems and you may need to tweak them for Windows systems.
The preparation involves the following steps:
Clone the Boost super-project
git clone --recurse-submodules --jobs 8 https://github.com/boostorg/boost.git
master
or develop
cd boost
git checkout master
TIP: Modular Boost Library Maintenance
guide, for more realistic test environment, recommends to develop and test
individual Boost library against other Boost libraries as defined by
the Boost super-project master
branch:
cd boost
git checkout master
git pull
git submodule update --init --recursive --jobs 8
b2
driver program for Boost.Build engine../bootstrap.sh
./b2 --version
TIP: For more convenient path-less invocation, you can copy the b2
program to a location in your PATH
.
Optionally, create full content of /boost
virtual directory with
all Boost headers linked from the individual modular Boost libraries.
If you skip this step, executing b2
to run tests will automatically
create the directory with all headers required by Boost.GIL and tests.
./b2 -j8 headers
TIP: If something goes wrong, you end up with incomplete or accidentally modified files in your clone of the super-project repository, or you simply wish to start fresh, then you can clean and reset the whole repository and its modules:
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive --jobs 8
Regardless if you decide to develop again master
(recommended) or develop
branch of the Boost super-project, you should always base your contributions
(i.e. topic branches) on Boost.GIL develop
branch.
Go to the Boost.GIL library submodule.
cd libs/gil
develop
branch and bring it up to dategit checkout develop
git branch -vv
git pull origin develop
Follow Forking Projects guide to get personal copy of boostorg/gil repository from where you will be able to submit new contributions as pull requests.
Add your fork as git remote to the Boost.GIL submodule:
cd libs/gil
git remote add <username> https://github.com/<username>/gil.git
or, if you cloned from your fork already, add the upstream as origin
remote:
git remote add upstream https://github.com/boostorg/gil.git
# or
git remote rename origin <username>
git remote add origin https://github.com/boostorg/gil.git
All Boost.GIL contributions should be developed inside a topic branch created by
branching off the develop
branch of boostorg/gil.
IMPORTANT: Pull Requests must come from a branch based on develop
,
and never on master
.
NOTE: The branching workflow model Boost recommends is called Git Flow.
For example:
cd libs/gil
git checkout develop
git checkout -b feature/foo
Now, you are set to to develop a new feature for Boost.GIL, then git add and git commit your changes.
Once it's finished, you can submit it as pull request for review:
cd libs/gil
git checkout feature/foo
git push <username> feature/foo
Finally, sign in to your GitHub account and create a pull request.
Your pull request will be automatically built and tests will run on Travis CI and AppVeyor (see README for builds status). Please, keep an eye on those CI builds and correct any problems detected in your contribution by updating your pull request.
Depending on actual purpose of the update, you can follow a different strategy to update your pull request:
git commit --amend
, git rebase
and git push --force
when your
pull request is still work-in-progress and not ready for review yet.git commit
, git merge
and git push
to update your pull request
during review, in response to requests from reviewers.NOTE: Once review of your work has started, you should not rebase your work. You should create new commits and update your topic branch. This helps with traceability in the pull request and prevents the accidental history breakage. Those who review your work may be fetching it into their fork for local review.
Keep your topic branch up to date and synchronized with the upstream develop
branch:
cd libs/gil
git checkout develop
git pull origin develop
git checkout feature/foo
If review of your work has not started, prefer to merge:
git merge develop
git push <username> feature/foo
If your PR is still work-in-progress, you may rebase if you like:
git rebase develop
git push --force <username> feature/foo
If your pull request is a work-in-progress and has not been reviewed yet,
you may amend your commit or rebase onto the develop
branch:
cd libs/gil
git checkout feature/foo
git add -A
git commit --amend
git push --force <username> feature/foo
In order to update your pull request, for example in response to a change request from reviewer, just add new commits:
cd libs/gil
git checkout feature/foo
git add -A
git commit -m "Fix build Travis CI failures"
git push <username> feature/foo
Boost.GIL is a header-only library which does not require sources compilation. Only test runners and example programs have to be compiled.
By default, Boost.GIL uses Boost.Build to build all the executables.
We also provide configuration for two alternative build systems:
NOTE: The CMake and Faber are optional and the corresponding build configurations for Boost.GIL do not offer equivalents for all Boost.Build features. Most important difference to recognise is that Boost.Build will automatically build any other Boost libraries required by Boost.GIL as dependencies.
Boost.GIL tests and examples use the GIL I/O extension which depends on third-party libraries for read and write support of specific image formats:
sudo apt-get install libjpeg-dev libpng-dev libtiff5-dev libraw-dev
The b2 invocation
explains available options like toolset
, variant
and others.
Simply, just execute b2
to run all tests built using default
variant=debug
and default toolset
determined for your
development environment.
TIP: Pass b2
option -d 2
to output complete action text and commands,
as they are executed. It is useful to inspect compilation flags.
If no target or directory is specified, everything in the current directory is built. For example, all Boost.GIL tests can be built and run using:
cd libs/gil
../../b2
Run core tests only specifying location of directory with tests:
cd libs/gil
../../b2 -j8 test/core
Run all tests for selected extension (from Boost root directory, as alternative):
./b2 -j8 libs/gil/test/io
./b2 -j8 libs/gil/test/numeric
./b2 -j8 libs/gil/test/toolbox
Run I/O extension tests bundled in target called simple
:
./b2 libs/gil/test/io//simple
Maintainer: @mloskot
WARNING: The CMake configuration is only provided for convenience of contributors. It does not export or install any targets, deploy config files or support subproject workflow.
NOTE: CMake configuration does not build any dependencies required by Boost.GIL like Boost.Test and Boost.Filesystem libraries or any third-party image format libraries used by the I/O extension.
The provided CMake configuration allows a couple of ways to develop Boost.GIL:
-DBOOST_ROOT=/path/to/boost/root
, see
FindBoost
documentation for details).libs/gil
. This mode requires prior deployment of boost
virtual directory
with headers and stage build of required libraries, for example: ./b2 -j8 headers
./b2 -j8 variant=debug --with-test --with-filesystem stage
./b2 -j8 variant=release --with-test --with-filesystem stage
or, depending on specific requirements, more complete build:
./b2 -j8 variant=debug,release address-model=32,64 --layout=versioned --with-test --with-filesystem stage
Using the installed Boost enables a lightweight mode for the library development, inside a stand-alone clone Boost.GIL repository and without any need to clone the whole Boost super-project.
TIP: For the lightweight setup, prefer latest release of Boost.
For available custom CMake options, open the top-level CMakeLists.txt
and search for option
.
Here is an example of such lightweight workflow in Linux environment (Debian-based):
Install required Boost libraries
sudo apt-get update
sudo apt-get install libboost-dev libboost-test-dev libboost-filesystem-dev
git clone https://github.com/boostorg/gil.git
cd gil
Configure build with CMake
mkdir _build
cd _build/
cmake ..
TIP: By default, tests and examples are compiled using
the minimum required C++11.
Specify -DCMAKE_CXX_STANDARD=14|17|20
to use newer version.
For more CMake options available for GIL, check option
-s defined
in the top-level CMakeLists.txt
.
TIP: If CMake is failing to find Boost libraries, especially built
with --layout=versioned
, you can try a few hacks:
-DBoost_ARCHITECTURE=-x64
to help CMake find Boost 1.66 and above
add an architecture tag to the library file names in versioned build
The option added in CMake 3.13.0.-DBoost_COMPILER=-gcc5
or -DBoost_COMPILER=-vc141
to help CMake earlier
than 3.13 match your compiler with toolset used in the Boost library file names
(i.e. libboost_unit_test_framework-gcc5-mt-x64-1_69
and not -gcc55-
).
Fixed in CMake 3.13.0.if CMake is still failing to find Boost, you may try -DBoost_DEBUG=ON
to
get detailed diagnostics output from FindBoost.cmake
module.
List available CMake targets
cmake --build . --target help
Build selected target with CMake
cmake --build . --target gil_test_pixel
ctest --show-only | grep Test
Run selected test with CTest
ctest -R gil.tests.core.pixel
We provide example/cmake/CMakeSettings.json with reasonable default settings for the CMake support in Visual Studio. See example/cmake/README.md for more details.
We provide example/cmake/cmake-variants.yaml with reasonable default settings for the CMake Tools extension. See example/cmake/README.md for more details.
Maintainer: @stefanseefeld
TODO: Describe
clang-tidy can be run on demand to diagnose or diagnose and fix or refactor source code issues.
Since the CMake configuration is provided for building tests and examples,
it is easy to run clang-tidy
using either the integration built-in CMake 3.6+
as target property CXX_CLANG_TIDY
or the compile command database which
can be easily generated.
This mode uses the CMake built-in integration and runs clang-tidy
checks configured
in .clang-tidy.
All custom compilation warning levels (e.g. -Wall
) are disabled and
compiler defaults are used.
cd libs/gil
cmake -S . -B _build -DGIL_USE_CLANG_TIDY=ON
# all targets
cmake --build _build
# selected target
cmake --build _build --target test_headers_all_in_one
WARNING: This is advanced processing and depending on checks, it may fail to deliver expected results, especially if run against all configured translation units at ones.
Generate compile_commands.json
database
cd libs/gil
cmake -S . -B _build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
Edit compile_commands.json
and remove entries of commands for all but the .cpp
files you wish to refactor. For example, keep test_headers_all_in_one.cpp
only
to refactor all headers.
Run the parallel clang-tidy
runner script to apply the desired checks (and fixes)
across the library source code:
run-clang-tidy.py -p=_build -header-filter='boost\/gil\/.*' -checks='-*,modernize-use-using' -fix > cl.log 2>&1
Boost.GIL is a more than a decade old mature library maintained by several developers with help from a couple of dozens contributors. It is important to maintain consistent design, look and feel. Thus, below a few basic guidelines are listed.
First and foremost, make sure you are familiar with the official Boost Library Requirements and Guidelines.
Second, strive for writing idiomatic C++11, clean and elegant code.
NOTE: The Boost.GIL source code does not necessary represent clean and elegant code to look up to. The library has recently entered the transition to C++11. Major refactoring overhaul is ongoing.
Maintain structure your source code files according to the following guidelines:
\file
for Doxygen), revision information, etc.In header, put #include
guard based on header path and file name
#ifndef BOOST_GIL_<DIR1>_<DIR2>_<FILE>_HPP
#define BOOST_GIL_<DIR1>_<DIR2>_<FILE>_HPP
...
#endif
boost/gil/
or boost/gil/<component>/
.boost/gil/detail
or boost/gil/<component>/detail
.namespace boost { namespace gil {...}}
.namespace boost { namespace gil { namespace detail {...}}}
.