Project Configuration
Modelify uses Atlas to analyze your C code. In order to map your C code, Atlas needs the same settings that the compiler needs to build your project. The following guide explains common ways to import an existing C code base into an Eclipse CDT project, and to prepare it for use with Atlas and Modelify.
If the project requires a special compiler (other than gcc), you may need to install additional CDT features to support your toolchain. Modelify is distributed with support for gcc and gcc-based cross compilers.
Installing a C compiler
Subsections below require a C compiler installed in your system so that you can compile your C code once it's imported into eclipse.
If you already have a C compiler installed then you can skip this section. Otherwise, you could follow steps below to install an open source C compiler.
- Download MinGW Installation Manager. For more information about MinGW see its Getting Started page.
- Run the downloaded file
- Important - it's strongly recommended to choose a MinGW installation directory that does not have spaces in the path.
- Install the following packages from "Basic Setup":
- mingw32-base - binaries for C compilation (gcc, link, etc.)
- mingw32-gcc-g++ - binaries for C++ compilation (g++, etc.)
- If any of the projects you plan to import has a makefile and must be built using that makefile, then install the following additional package:
- Msys-base - adds msys binaries, which include Linux commands commonly used in makefiles (rm, bash, etc.)
- The GnuWin32 project can also be installed, if the makefile requires a command from it.
It is not necessary to add MinGW to the Windows system path, and in fact is not recommended, because it can cause conflicts with other command-line tools.
Instead, you should add the MinGW/MSYS binaries to the build path for eclipse CDT:
- Run Modelify
- Click Window > Preferences
- On the dialog that opens, select C/C++ > Build > Environment
- Create a variable "PATH" pointing to the MinGW "bin" folder (default C:\MinGW\bin)
- If MSYS was installed, then add it to the path too (e.g C:\MinGW\bin;C:\MinGW\msys\1.0\bin)
- Also add the GnuWin32 path, if needed
- Verify that the radio button at the bottom is set to "Append", then apply preferences
Importing C projects in Eclipse
- If the project has a Makefile:
- From the File menu, select Import.
- In the popup dialogue, expand C/C++, select Existing Code as Makefile Project, and click Next.
- Enter a project name and indicate the directory to import. Set the Toolchain for Indexer Settings. For cross compilation with gcc, select Cross GCC. Otherwise, choose an installed compiler of your preference (e.g. MinGW GCC).
- Click Finish.
- Ensure the Makefile will be used to build the project
- Right-click on the project and click Properties
- Expand C/C++ Build and select Tool Chain Editor.
- Set the Current builder to Gnu Make Builder
- Click OK
- If the project does NOT have a Makefile:
- From the File menu, select New, then Other... .
- In the popup dialogue, expand C/C++, select C Project, and click Next.
- Expand the Project type Executable, and click Empty Project.
- Enter a project name and click Finish.
- Right-click on the project and select Import.
- In the popup dialogue, expand General, select File System, and click Next.
- Enter the parent directory, select files to import, and click Finish.
- Make adjustments to the include paths and preprocessor directives as needed. Right-click on the project, folders, or files, and select Properties.
- In the popup dialog, expand C/C++ Build
- Select Settings to add include paths and preprocessor directives as needed. See also: CDT Help.
- Select Tool Chain Editor
- Select desired tool chain under "Current toolchain:" option (e.g. MinGW GCC)
- Ensure "Current Builder:" is set to "CDT Internal Builder"
Configuring C projects for Atlas
At this point, your C project may already be configured correctly. In order for Atlas to obtain compiler settings (such as include paths and preprocessor directives), the CDT must be able to build your C project and observe invocations of your compiler. Review the steps below to ensure that Atlas can extract compiler information from the build process.
If your project uses a gcc-based cross compiler, configure the project to use it (instructions adapted from stackoverflow.com).
- Right-click on the project and select Preferences.
- Ensure the project is configured to use the Cross GCC Tool Chain.
- Expand C/C++ Build and select Tool Chain Editor.
- Set the Current toolchain to Cross GCC.
- Click Apply.
- In the popup dialog, select C/C++ Build.
- Check Generate Makefiles automatically, but do NOT Apply.
- Under C/C++ Build, select Settings.
- Under the Tool Settings tab, select Cross Settings. Set the cross compiler settings for Prefix and Path. For example:
- Prefix: arm-none-eabi-
- Path: <path to compiler>
- Select C/C++ Build again, uncheck Generate Makefiles automatically.
- Click Apply.
The steps below detail the changes necessary to accurately map the files built.
- If the project has a Makefile you have to perform an extra step to ensure that the CDT can observe invocations of your compiler during a build. Makefiles for large projects (such as Linux) suppress the full text of the invocation for readability, but there is usually a way to emit the invocations in verbose mode.
- Select C/C++ Build and uncheck "Use default build command". Adjust the command to make the output verbose. Common options include "make V=1" or "make VERBOSE=1".
- Configure Atlas to observe the build:
- Right-click on the project and select Properties.
- Select Atlas C Build.
- Under Build Commands, add the name of the compiler used by the project. Atlas will look for invocations of these compilers when parsing the output of the project's build.
- Under Source files to map, select Map only files in current build.
- Click OK.
Build
To accurately map the project, it must be built so that the compiler invocations can be observed.
- If your project uses a CDT-generated Makefile, or the Makefile has an "all" target
- Right-click on the project in the Project Explorer and select Build Project
- If your project has a hand-written Makefile
- Right-click on the project in the Project Explorer and expand Build Targets and select Create... .
- In Target name, enter the name of the build target. Click OK.
- In the Project Explorer view, expand the project, expand the Build Targets, and double-click on the target.
Map
After the project has been successfully built, it can be mapped with Atlas.
- Right-click on the project in the Project Explorer, expand Atlas, and select Enable Mapping.
- Select Atlas from the main menu, and select Re-Map Workspace.
Troubleshooting
If Atlas is unable to properly map the project, try the following:
- Clean and build the project and make sure the build output is being correctly parsed:
- Right-click on the project in the package explorer and select Properties.
- Look under Atlas C Build > Build Configuration File.
- If the Open button under Build Configuration File is grayed out, or if it says zero files were found, then Atlas was unable to detect the build configuration. Select C/C++ Build and uncheck Use default build command.
- Adjust the command to make the output verbose. Necessary flags may vary; common options include "V=1" or "VERBOSE=1".
- Clean and build the project. Check that Build Configuration File is nonzero.
- If Atlas's code map is still empty, it may be that the Makefile is improperly reporting changing directories.
- Right-click on the project in the package explorer and select Properties.
- Select C/C++ Build and uncheck Use default build command.
- Add the flag "--print-directory".
- Clean and build the project.
If you experience difficulty in setting up Atlas, please contact support@ensoftcorp.com for assistance.