Eclipse configuration

Eclipse is the preferred tool for the development of source code related to the MARTe project. In particular it promotes and guides the implementation of the framework coding standard and rules.

Prerequisites

Configuration

  1. Open Eclipse;

  2. Click on FileNewMakefile Project with existing code;

    1. In the section Toolchain for Indexer Setting:

      1. Select <none> if you are developing Microsoft Windows;

      2. Select Linux GCC if you are developing in Linux;

    2. Write MARTe2-dev as the Project Name;

    3. Point the Existing Code Location to the MARTe2-dev directory (the one cloned before);

    4. Press Finish;

  3. Open WindowPreferences;

    1. Select C/C++Code StyleCode Templates and click on Import;

      1. Select the file Docs/Assets/Configuration/marte_cpp_code_templates.xml.

    2. Select C/C++Code StyleFormatter and click on Import;

    1. Select the file Docs/Assets/Configuration/marte_cpp_formatting_rules.xml.

    1. Select C/C++EditorTemplates and click on Import;

    1. Select the file Docs/Assets/Configuration/marte_cpp_editor_templates.xml.

    2. Select the “Use code formatter” option.

    ../../../_images/C_CppEditorTemplatesImport.png
    1. Select GeneralEditorText EditorsSpelling*;

    1. Make sure to select first the option Enable spell checking;

    2. In User defined dictionary click on Browse… and select the file .dictionary which is the root folder of the MARTe2-dev repository (in Linux this file may not be visible in the dialog and consequently its path needs to be explicitly written in the text field).

      ../../../_images/GeneralEditorsTextEditorsSpellin.png
    1. Click Apply and Close to close the Preferences window.

  4. Open ProjectProperties;

    1. Select C/C++ Build;

      1. Unselect Use default built command;

      2. In the Build command text field:

        1. Write make -f Makefile.msc if you are developing in Microsoft Windows;

        ../../../_images/eclipse-configuration-2.png
        1. Write make -f Makefile.linux if you are developing in Linux;

      3. If you are developing in Microsoft Windows:

        1. Open a Windows console (cmd.exe) and type vcvars32 if you are compiling in 32 bits or vcvars64 if you are compiling in 64 bits;

        2. Go back to the eclipse project properties (but leave the Windows console opened);

        3. Select Environment (under C/C++ Build in the tree)

        4. Click on Add

          1. Write INCLUDE in the Name text field;

          2. In the Windows console type echo %INCLUDE%

          3. Write the output of the previous command in the VALUE text field;

          4. Select Add to all configurations;

        5. Click on Add

          1. Write LIB in the Name text field;

          2. In the Windows console type echo %LIB%

          3. Write the output of the previous command in the VALUE text field;

          4. Select Add to all configurations;

        6. Click on Add

          1. Write PATH in the Name text field;

          2. In the Windows console type echo %PATH%

          3. Write the output of the previous command in the VALUE text field;

          4. Select Add to all configurations;

        7. Click on Apply;

        8. Close the Windows console;

    2. Select C/C++ GeneralPaths and Symbols;

    1. Select the # Symbols tab;

      1. Select [ All configurations ] in the Configuration list;

      2. Select GNU C in the languages list;

      3. Click on Add:

        1. Write ARCHITECTURE in the Name text field;

        2. Write x86_cl in the Value text field if you are developing in Microsoft Windows;

        3. Write x86_gcc in the Value text field if you are developing in Linux;

        ../../../_images/eclipse-configuration-3.png
        1. Select Add to all configurations;

        2. Select Add to all languages;

        3. Click OK;

      4. Click on Add:

        1. Write ENVIRONMENT in the Name text field;

        2. Write Windows in the Value text field if you are developing in Microsoft Windows;

        3. Write Linux in the Value text field if you are developing in Linux;

        4. Select Add to all configurations;

        5. Select Add to all languages;

        6. Click OK;

    1. Click Apply and Close to close the Properties window.

  5. Compile the project by selecting ProjectBuild All;

  6. Select HelpInstall New Software;

    1. Select Work with - -All available sites-;

    2. Select Programming LanguagesC/C++ Unit Testing Support;

    3. Click on Next and follow the instructions;

    ../../../_images/HelpInstallNewSoftwareUniteTest.png
  7. Open RunRun Configurations;

    1. Select the C/C++ Unit on the left pane;

    2. Press the New launch configuration button (on the top left side);

    ../../../_images/RunConfigurationC_CppUnitNew.png
    1. Select the Main tab;

    1. Write MARTe2 GTest in the Name text field;

    2. Write MARTe2-dev in the Project text field;

    3. In the C/C++ Application text field:

      1. Write Build\msc\GTest\MainGTest.exe if you are developing in Microsoft Windows;

      2. Write Build/x86-linux/GTest/MainGTest.ex if you are developing in Linux;

    ../../../_images/RunConfigurationsC_CppUnitTestCreation.png
    1. In the Build configuration select Default;

    1. Select the C/C++ testing tab;

    1. In the Tests Runner drop-box, select Google Tests Runner;

    1. Select the Common tab;

      1. Select Run in the Display in favorites menu pane;

    1. If you are developing Microsoft Windows:

    1. Select the Environment tab;

      1. Click on New…;

        1. In the Name text field write PATH;

        2. In the Value text field write ${workspace_loc:/MARTe2-dev}/Build/msc/Core

      2. Make sure that the radio button Append environment to native environment is selected;

    1. Click on Apply;

    2. Click on Run to check if everything was setup properly and then Close.

  8. Select HelpInstall New Software;

    1. Click on the Add.. button;

      1. In the Name text field write Eclox;

      2. In the Location text field write: http://anb0s.github.io/eclox;

    2. In the Work with select Eclox - http://anb0s.github.io/eclox;

    3. Select eclox 0.12 and Eclox Doxygen in the menu;

    4. Click on Next and follow the instructions to install the pulg-in.

    ../../../_images/InstallEclox.png
  9. On the toolbar click in the @ sign and select Build Doxyfile.

    1. Select the MARTe2-devDoxyfile;

    2. Click OK;

    3. Verify that html files are created in MARTe2-dev/Build/dox/html directory.

  10. Select HelpEclipse MarketPlace.

  1. Search for cppcheclipse and install it following the instructions.

Coverage

Linux developers can integrate the coverage tool (lcov) with-in the eclipse development environment. It should be noted that the gcov integration delivered with the Linux Tools - Gcov Support does not work well with the folder structure of the MARTe2 project.

  1. Open RunExternal ToolsExternal Tools Configurations…;

    1. Click New launch configuration

    2. In the Name text field write: MARTe2 lcov

    3. Select the Main tab:

    1. In the Location text field write: ${workspace_loc:/MARTe2-dev/EclipseLcov.sh}

    2. In the Working Directory text field write: ${workspace_loc:/MARTe2-dev}

    1. Select the Refresh tab:

    1. Select Refresh resources upon completion.

    2. Select The project containing the selected resources

    3. Mark Recursively include sub-folders

    1. Select the Build tab:

      1. Unselect Build before launch

    1. Select the Common tab:

    1. Select External Tools in the Display in favorites menu pane.

    1. Click Apply;

    2. Click Run.

The coverage html will be generated in a folder named cov_html under the Build folder. Open the index.html file to browse the results.

../../../_images/eclipse-configuration-8.png

Linting

Core developers in the F4E premises can configure the linting procedure as follows:

  1. Make sure that you can login using SSH to the lint server (defined with the variable HOST) using public key authentication (i.e. without a password);

  2. Open ProjectBuild ConfigurationsManage;

    1. Click New;

    2. In the Name text field write MARTe2 linting;

    3. In the Description text field write MARTe2 linting procedure;

    4. Select Default in the Copy settings fromExisting configuration list;

    5. Click OK;

  3. Open ProjectProperties;

    1. Select C/C++ Build

      1. Select MARTe2 linting in the Configuration list;

      2. Unselect Use default built command;

      3. In the Build command text field:

        • Write the full path to the EclipseLint.bat script if you are developing in Microsoft Windows;

        • Write the full path to the EclipseLint.sh script if you are developing in Linux;

        ../../../_images/eclipse-configuration-9.png
      4. Unselect Generate Makefiles automatically;

      5. In the Build directory text field write ${workspace_loc:/MARTe2-dev}

      6. In the Behavior tab:

        1. Unselect Stop on first build error;

        2. Unselect Clean;

      7. Click Apply and close.

Tips and tricks

  • To format code, click on the file that you want format and then select SourceFormat.

  • The html generated by eclox will be available in a folder named html under the AssetsConfiguration folder.

  • To run CppCheck, open the file that you want to check and do right click → cppcheckRun cppcheck.

    ../../../_images/eclipse-configuration-10.png