Skip to content
0xffff-lib, a low level core library
Python C++ Makefile
Branch: master
Clone or download
iosmanthus Add makefile (#20)
* Abort travis pipeline if the first task fails

Signed-off-by: Iosmanthus Teng <>

* Add buildifier to check bzl files

Signed-off-by: Iosmanthus Teng <>

* formated by buildifier

Signed-off-by: Iosmanthus Teng <>

* add jobs: checks and tests

Signed-off-by: Iosmanthus Teng <>

* Add a makefile

* make format to format the code including: BUILDs/WORKSPACE and
* make test/simple-test to run test suite
* make clean to clean up the binaries

Signed-off-by: Iosmanthus Teng <>
Latest commit acda135 Aug 8, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Refine `` (#14) Aug 7, 2019
src Travis ci pipeline jobs (#18) (#19) Aug 7, 2019
tests Travis ci pipeline jobs (#18) (#19) Aug 7, 2019
.travis.yml Travis ci pipeline jobs (#18) (#19) Aug 7, 2019
LICENSE Create LICENSE Aug 3, 2019
Makefile updated travis-ci badge Aug 5, 2019


Build Status


0xffff-lib is a low level core library whose goal is enabling newbie to be familiar with modern C++ development, computer science's core courses and how to contribute to open source project by building a data-structure and algorithm library from scratch with the help of testing framework googletest and building system bazel.



  1. Install bazel which is a build system used to build our library:
  2. Install g++, which is the default c++ compiler in many Linux distribution.


  1. bazel test: if you just want to check if any test failed.
  2. bazel test tests --test_output=all: if you want more verbose information.

Project structure

Currently, our library is quite simple and crude, we need more contributors to enhance it which is one of the project's motivations: encourage newbie to contribute to open source project.

├── src
│   └── collections # Collection type
│       ├── BUILD # Bazel build file
│       └── ...
├── tests # Where testing codes live
│   ├── BUILD
│   └──
└── WORKSPACE # import extenal dependencies

Add modules

For instance, if we are going to a matrix calculation module to our library. Considering the module doesn't belong to any existing module, we need to add a directory called matrix for logical need. Now our src directory looks like:

├── collections
│   ├── BUILD
│   └── vector.h
└── matrix
    ├── BUILD
    ├── matrix.h
    ├── svd.h
    └── ...

In the example above, we need a BUILD file to describe how to build matrix module. The BUILD file is read by bazel and determine how the module build and visibility to other modules. Now let's see how to write such a BUILD file from scratch.

    # Name of our module
    name = "matrix",
    # All file with type `cc` is our sources
    srcs = glob("[*.cc]"),
    # Includes all header file in `hdrs`
    hdrs = glob(["*.h"]),
    # Visible from other package
    visibility = ["//visibility:public"],

Now we have successfully added a module to our library, now it's time to add some tests to examine if the module works as we expected. For now, all the tests live in tests which is also a package managed by bazel. So it contains a BUILD file. Let's check out its content:

    name = "tests",
    srcs = glob(["*.cc"]),
    deps = [
        # We need to import the module we want to test
        # New module; or "//src/matrix:matrix"

        // Import googletest to our tests.

Then, we create a file named

#include "src/matrix/matrix.h"
#include <gtest/gtest.h>

TEST(TestMatrix, TestAdd) {
    Matrix<int> lhs({{1, 2, 3});
    Matrix<int> rhs({{0, 0, 0}};
    Matrix<int> expected({1, 2, 3});

    EXPECT_EQ(expected, lhs + rhs);

Then, we can run the test by: bazel test and check if the function of the module works as expected.


CI support is coming. And we will make some tags in the issues including:

  • Feature request; There will detailed document to describe the proposal.
    • Easy
    • Medium
    • Hard
  • Help wanted
You can’t perform that action at this time.