Development Environment

The SPARK SDK provides a seamless development experience with Visual Studio Code (VS Code), a popular and powerful source code editor. This section will guide you through setting up your development environment using VS Code and introduce the required extensions for debugging and for an optimized coding experience.

Prerequisites

Ensure that you have already followed the steps outlined in the Getting started section of the documentation, which covers the installation and setup of the SPARK SDK virtual environment. Having the virtual environment initialized is a prerequisite for testing example applications or writing your own.

Creating a New Application Alongside the Example Applications

The most straight forward way to create a project for a new application is to start from an existing one that is similar. Use the procedure listed below to create a project for a new application called “My App” which is similar to the Hello World example.

  1. Open a file explorer and duplicate the app/example/hello_world folder and rename it to app/example/my_app.

  2. Rename app/example/my_app/hello_world_coord.c to app/my_app/my_app_coord.c. Do the same for the _node.c file.

  3. Open the app/example/my_app/CMakeLists.txt file and change any reference to hello_world to my_app.

  4. Open .vscode/cmake-variants.json and add a new entry for my_app.

    "my_app": {
        "short": "My App",
        "settings": {
            "APP": "my_app"
        }
    }
    
  5. Add my_app variant to the list example application app/example/CMakeLists.txt.

    elseif (APP STREQUAL "my_app")
        add_subdirectory(my_app)
    
  6. Duplicate the bsp/interface/app/hello_world folder and rename it to bsp/interface/app/my_app

  7. Rename iface_hello_word.h and iface_hello_word_evk.c to iface_my_app.h and iface_my_app_evk.c.

  8. Open bsp/interface/app/my_app/CMakeLists.txt and change any reference to hello_world to my_app.

  9. Add my_app variant to the list example application bsp/interface/app/CMakeLists.txt.

    elseif (APP STREQUAL "my_app")
        add_subdirectory(my_app)
    
  10. Replace any #include "x_hello_world.h" with #include "x_my_app.h" in the new sources files.

  11. Select the my_app variant in VS Code and build the project.

At this point, the My App project should be functional and can be built just like the Hello World project. The content of my_app.c and swc_cfg.h can now be edited to reflect the My App application requirements.

Build System

The SPARK SDK uses CMake build system for project building and configuration. With CMakeLists, developers can define project structure, dependencies, and compile options in a concise and platform-independent manner. It supports various toolchains and platforms, allowing for seamless cross-platform development. With CMake, you can easily manage complex projects and specify library dependencies.

CMake external resources

The official CMake documentation is a comprehensive resource that covers all aspects of CMake, including syntax, commands, variables, and modules. You can access it at: https://cmake.org/documentation/

The CMake tutorial provides step-by-step instructions and examples to help you get started with CMake. It covers basic concepts, creating CMakeLists files, building projects, and more. You can find the tutorial here: https://cmake.org/cmake/help/latest/guide/tutorial/index.html