Skip to content

Latest commit

 

History

History
227 lines (136 loc) · 6.26 KB

gettingstarted.rst

File metadata and controls

227 lines (136 loc) · 6.26 KB

Getting started

Welcome to biicode.

Biicode manages your project's dependencies so you can use the libs you need (Curl, Catch, Fann, OpenSSL, OpenCV, Poco, Boost, Libuv, GTest ...) as you wish within your project. Biicode uses CMake to configure and build your projects and it is compatible with many IDEs and version control systems.

This guide will help you get your first biicode block off the ground. Let's run a block with a unit test using the in biicode. There's no need to install GTest, biicode downloads and configures it for you, is already in biicode!

Basics

Make sure biicode is installed<first_steps>. Open the terminal and execute bii setup:cpp to ensure you've got all tools required.

Create your first project

bii init -L a folder to create a new project. The commands below create unit_test/ folder as a biicode project containing a block and a main.cpp file.

~$ bii init unit_test -L
~$ cd unit_test
~/unit_test$ echo "//main.cpp code goes here" >> main.cpp

Place this code into the main.cpp file:

#include "google/gtest/include/gtest/gtest.h"

int sum(int a, int b) {return a+b;}

TEST(Sum, Normal) {
  EXPECT_EQ(5, sum(2, 3));
}

int main(int argc, char **argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

It is just a sum function and a test using Google Test framework.

The #include is composed as #include <biicode_user>/<block_name>/path/to/file. In this case, it #includes the include/gtest/gtest.h header from block and user google.

In the web, you see its latest version is 10 tagged STABLE:

image

Retrieve the dependency:

~/unit_test$ bii find
...

INFO: Analyzing compatibility for found dependencies... 
INFO: All dependencies resolved
Find resolved new dependencies:
  google/gtest: 10
INFO: Saving files from: google/gtest

bii find creates a biicode.conf file and downloads GoogleTest block into your bii/deps folder:

unit_test/
      ├── bii/
      │   ├── deps/
      │   │   └── google/
      │   │       └── gtest/
      ├── biicode.conf
      └── main.cpp

[optional] Keeping #includes short

Keep reading to see how to keep your #includes as usual. You can also skip this section.<cpp_run>

#include "gtest/gtest.h"

Instead of using long #includes, you can write the specs to retrieve this dependency in your biicode.conf.

  • Split the long #include "google/gtest/include/gtest/gtest.h" in two halfs:
[requirements]
   google/gtest: 10

[includes]
    gtest/gtest.h: google/gtest/include

You can also use patterns:

[includes]
    gtest/*.h: google/gtest/include

Using an IDE

biicode configures your default settings to no IDE and MinGW (Windows) or UNIX Makefiles (MacOS and Linux). You can change these values executing bii configure:

~/unit_test$ bii configure -G "Visual Studio 10"

Here's more about configuring your IDE <generators_ide>.

Build and run

Build and run your Unit Test, check it works:

~/unit_test$ bii build
...
~/unit_test$ bin/user_unit_test_main
[==========] Running 1 test from 1 test case.
...
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (15 ms total)
[  PASSED  ] 1 test.

Linux/Mac users might run as:

~/unit_test$ ./bin/user_unit_test_main

That's it, that output means Google Test was downloaded, configured and built in your project!

unit_test/
      ├── bii/
      ├── biicode.conf
      ├── bin
      │   └── user_unit_test_main
      ├── CMakeLists.txt
      └── main.cpp

Congrats! You have just used GoogleTest within your project. You know that we are available at for any problems. You can also for suggestions and feedback.

Publishing

Publish to make your libs available in biicode.

  • Execute $ bii user your_username.
~/unit_test$ bii publish

INFO: *****************************
INFO: ***** Publishing public ****
INFO: *****************************
INFO: Successfully published your_username/unit_test: 0

Go to your profile at www.biicode.com/your_username to check what you've just uploaded.

image

  • Log in to edit the block's web description.
  • Make sure you've to publish. It's free.

Take a look into your block's biicode.conf file (~/unit_test/biicode.conf). [parent] section tells you "who is your parent version", which is the latest published version of your block and looks like this:

[parent]
   your_username/unit_test: 0

Celebrate! You've just published your first block in biicode. You know that we are available at for any issues. You can also for suggestions and feedback.