Skip to content

Instantly share code, notes, and snippets.

@ruvi-d
Last active February 8, 2021 07:48
Show Gist options
  • Save ruvi-d/54e2fec01f9c5ae24ab1643fadf196d5 to your computer and use it in GitHub Desktop.
Save ruvi-d/54e2fec01f9c5ae24ab1643fadf196d5 to your computer and use it in GitHub Desktop.
Developer guide to setup dev tools to work with the nBallerina project

Dev setup - Ubuntu 20.04 LTS (WIP)

Host setup

IDE setup

  • VS Code formatting, goto File->Preferences->Settings
    • C_Cpp:Clang_format_fallback Style: LLVM
    • C_Cpp:Formatting : clangFormat
  • Extensions
    • C/C++ Extension Pack, C++ TestMate, Code Spell Checker, LLVM, C/C++ Snippets Pro

Compiling, Tests and debugging

  • Example minimum CMakeLists.txt for GTest

      cmake_minimum_required(VERSION 3.0)
      project(gtest_project)
    
      enable_testing()
    
      # Locate GTest
      find_package(GTest REQUIRED)
      include_directories(${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})
      
      # Link runTests with what we want to test and the GTest and pthread library
      add_executable(tests test.cpp answer.cpp)
      target_link_libraries(tests ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARY} pthread)
    
      add_test(NAME tests COMMAND tests)
    
      add_executable(app main.cpp answer.cpp)
    
  • First setup the LLVM compiler and CMake

    • Ctl + shift + p -> cmake select kit
      • Select Clang++-11
    • Ctl + shift + p -> cmake config
    • Select build variant (release/debug) from VS code bottom status bar
  • Build with F7

  • Run F5 (select target from bottom status bar)

  • Debug run Shift + F5

  • Tests can be run from tests extension. Supports debugging (break points)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment