Building Eclipse and MCUXpresso IDE Projects From the Command Line

DZone 's Guide to

Building Eclipse and MCUXpresso IDE Projects From the Command Line

Love working from the command line? Well, here's how to build your Eclipse IDE projects (specifically MCUXpresso IDE projects) from a command line.

· IoT Zone ·
Free Resource

Eclipse as an IDE takes care of compiling and building all my source files. But in an automated build system, I would like to build it from the command line, too. While using make files (see Tutorial: Makefile Projects with Eclipse) is an option, there is another easy way to build Eclipse projects from the command line:

Building MCUXpresso IDE from Command Line

Building MCUXpresso IDE from the command line

I’m using MCUXpresso 10.0.2 (Eclipse Neon-based with GNU ARM tools) in this article, but the same should work for any other Eclipse version. The principle is to launch Eclipse in ‘headless mode’ using the org.eclipse.cdt.managedbuilder.core.headlessbuild plugin.

Batch File

I’m using the following batch file to do a command line (aka ‘headless’ build) with Eclipse:

# Batch file to build an Eclipse project from the command line on Windows
# Example for using MCUXpresso IDE

# path to GNU tools and compiler: arm-none-eabi-gcc.exe, ....
SET TOOLCHAIN_PATH=C:\nxp\MCUXpressoIDE_10.0.2_411\ide\tools\bin

# variable to the command line Eclipse IDE executable
SET IDE=C:\nxp\MCUXpressoIDE_10.0.2_411\ide\mcuxpressoidec.exe

ECHO Extending PATH if not already present
ECHO %PATH%|findstr /i /c:"%TOOLCHAIN_PATH:"=%">nul || set PATH=%PATH%;%TOOLCHAIN_PATH%

ECHO Launching Eclipse IDE
"%IDE%" -nosplash --launcher.suppressErrors -application org.eclipse.cdt.managedbuilder.core.headlessbuild -data "c:\tmp\wsp" -build frdmk64f_rtos_examples_freertos_event

The batch file can be found on GitHub.

It uses the following batch variables:

  • TOOLCHAIN_PATH: path variable to the compiler/linker/etc.
  • IDE: path/name variable of the command line IDE. On Windows, it is the Eclipse executable with a ‘c’ at the end. For Linux, it is the normal Eclipse executable.

Additional variables (or arguments) could be used for the workspace name and project name. The batch file checks if the toolchain path is already present in the PATH. If not, it gets added.

Then it launches the IDE with the following options:

  • -nosplash: do not show splash screen
  • –launcher.suppressErrors: do not show error dialog (e.g. if the workspace is already used)
  • -application org.eclipse.cdt.managedbuilder.core.headlessbuild: launch the IDE in command line/headless mode
  • -data <wsp folder name>: workspace to be used. Can be an empty workspace, but then I have to use the -import or -importAll option to import projects (see options in next section)
  • -build <project name>: build the project

The above builds a single project in a workspace. See the next section or the Links section at the end for other options.

Other Headless Build Options

The complete set of options can be found here:

 * Helper method to process expected arguments
 * Arguments
 *   -import     {[uri:/]/path/to/project}
 *   -importAll  {[uri:/]/path/to/projectTreeURI} Import all projects in the tree
 *   -build      {project_name_reg_ex/config_name_reg_ex | all}
 *   -cleanBuild {project_name_reg_ex/config_name_reg_ex | all}
 *   -I          {include_path} additional include_path to add to tools
 *   -include    {include_file} additional include_file to pass to tools
 *   -D          {prepoc_define} addition preprocessor defines to pass to the tools
 *   -E {var=value} replace/add value to environment variable when running all tools
 *   -Ea {var=value} append value to environment variable when running all tools
 *   -Ep {var=value} prepend value to environment variable when running all tools
 *   -Er         {var} remove/unset the given environment variable
 *   -T          {toolid} {optionid=value} replace a tool option value
 *   -Ta         {toolid} {optionid=value} append to a tool option value
 *   -Tp         {toolid} {optionid=value} prepend to a tool option value
 *   -Tr         {toolid} {optionid=value} remove a tool option value
 *   -no-indexer Disable indexer
 *   -markerType Which markers to consider
 *   -printErrorMarkers Print all error markers that caused build to fail
 * Each argument may be specified more than once
 * @param args String[] of arguments to parse
 * @return boolean indicating success


With the headless build options, I can use Eclipse to build projects from the command line.

Another option would be to use Eclipse with normal makefile projects. Then I could use make with that makefile (make -f myMakefile.mak). That builds faster because it does not need to start the IDE, but is more work to set up the make files. Otherwise, the IDE headless build is a very good alternative.

Happy commanding!


iot ,mcuxpresso ,makefile ,batch file ,command line ,tutorial

Published at DZone with permission of Erich Styger , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}