5

I would like to develop for the pebble using CLION (jetbrains c/c++ IDE). I am aware of cloud pebble , and would still like to use Clion. Could anybody tell me how to set it up so that :

  1. I get auto complete for pebble sdk functions
  2. When I click on run , the command pebble build && install is run .
harveyslash
  • 5,906
  • 12
  • 58
  • 111

2 Answers2

3

I use CLION to develop the C code for my Pebble apps.

To build/run I just have a terminal open within CLION, but I do like being able to refactor, have static analysis find errors, and to jump to the Pebble defs.

I created a new project based on the C source directory, and I've added all my source files to the CMakeLists.txt and the path to the Pebble include files and the generated resource file. Here is my CMakeLists.txt

cmake_minimum_required(VERSION 3.3)
project(src)
add_definitions(-DNOT_PEBBLE_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES
        pblib/pblib.h ... main_menu_customizer.c main_menu_customizer.h string_values.c error_handler.c error_handler.h)

include_directories("~/Library/Application Support/Pebble SDK/SDKs/current/sdk-core/pebble/chalk/include" ../build/chalk/src)
add_executable(src ${SOURCE_FILES})

In a general header file I also have these definitions to ensure that the generated resource file gets picked up, and that I don't get spurious errors for APP_LOG (might be fixed in the latest CLION):

#if NOT_PEBBLE_BUILD
#include <resource_ids.auto.h>
#undef APP_LOG // Clion doesn't support
#endif

Although not directly related to your question, you can also now debug C code running in the emulator using GDB, although not within CLION. That would be cool.

Damian
  • 4,723
  • 2
  • 32
  • 53
2

You will need to add CMakeLists.txt files for the root project directory and src. Note that both files refer to the project name, in this case "sd" but it doesn't matter what you call it as long as it's the same in both files.

CMakeLists.txt:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(sd)
SET(PEBBLE_FLAVOUR basalt)
SET(PEBBLE_SDK_VER 3.13.1)

SET(PEBBLE_SDK_INCLUDE_DIR "$ENV{HOME}/.pebble-sdk/SDKs/${PEBBLE_SDK_VER}/sdk-core/pebble/${PEBBLE_FLAVOUR}/include")

INCLUDE_DIRECTORIES("${PEBBLE_SDK_INCLUDE_DIR}")
# The generated files such as resource_ids are picked up from here:
INCLUDE_DIRECTORIES("build/${PEBBLE_FLAVOUR}")
INCLUDE_DIRECTORIES("build/include")

ADD_SUBDIRECTORY(src)

src/CMakeLists.txt:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
FILE(GLOB MainSources *.c)
ADD_LIBRARY(sd ${MainSources})

For inline documentation to work you will just need to install the latest CLion 2016.2 EAP.

glebm
  • 20,282
  • 8
  • 51
  • 67