C++ Dependency Management: Biicode

I'm interested in building, dependency management, packagin and deployment in regards to software projects. For Java, Scala, Python, and so on is quite easy since there are tools like Maven, Gradle, pip, Sbt, etc. But regarding C++_, the best options I've found are Maven with Nar plugin or Gradle with cpp plugin (incubation).

I knew about Biicode almost 2 years ago, but I've never found time to test it, until today.

How does Biicode work?

Firstly we have to install Biicode.

I've made tiny example project using logging system from Poco library.

I've executed this command to create the project, called bii_log.

bii new carlovin/bii_log --hello=cpp

I've created the project under my Biicode username, just in case I'd like to publish later.

Previous command generates the structure of files and directories, although we are going to focus only on:

blocks/carlosvin/bii_log/main.cpp
blocks/carlosvin/bii_log/biicode.conf

In biicode.conf we are going to configure our dependencies, in this example Poco library.

# Biicode configuration file

[requirements]
    fenix/poco(develop): 0

[parent]
        carlosvin/bii_log: 0

[includes]
    Poco/*.h: fenix/poco/Foundation/include

In [includes] section, we are overriding the path to file headers. If we don't override it we'd had to do something like this:

#include "fenix/poco/Foundation/include/Logger.h"

Thanks to this line, include declarations are going to be clearer, as follows:

#include "Poco/Logger.h"

Easy, now we can start using Poco in our project, e.g:

#include "Poco/FileChannel.h"
#include "Poco/FormattingChannel.h"
#include "Poco/PatternFormatter.h"
#include "Poco/Logger.h"
#include "Poco/AutoPtr.h"

using Poco::FileChannel;
using Poco::FormattingChannel;
using Poco::PatternFormatter;
using Poco::Logger;
using Poco::AutoPtr;

int main(int argc, char** argv) {
        AutoPtr<FileChannel> pChannel(new FileChannel);
        pChannel->setProperty("path", "log/sample.log");
        pChannel->setProperty("rotation", "100 K");
        pChannel->setProperty("archive", "timestamp");

        //AutoPtr<ConsoleChannel> pCons(new ConsoleChannel);
        AutoPtr<PatternFormatter> pPF(new PatternFormatter);
        pPF->setProperty("pattern", "%Y-%m-%d %H:%M:%S %s: %t");
        AutoPtr<FormattingChannel> pFC(new FormattingChannel(pPF, pChannel));
        Logger::root().setChannel(pFC);

        Logger & logger = Logger::get("TestChannel");
        for(int i=0; i<10000; i++){
                poco_information(logger, "This is a info");
                poco_warning(logger, "This is a warning");
        }
        return 0;
}

To compile the project we only have to execute following command:

bii cpp:build

To publish the project and to allow everyone use it as we have used Poco:

bii publish

Besides the ease to use, I like so much the integration with Eclipse with CDT. After "bii cpp:build" execution all files were properly indexed.

I've read also an article about the good integration with CLion: When CLion met biicode.

Comments