Skip to content

Building and Running

m0rkeulv edited this page Oct 25, 2026 · 4 revisions

This page explains how to build Haxe code from the IDE, run what you built and add commands of your own. Everything starts from the Haxe tool window (see The Haxe Tool Window). The fields of each run configuration are described in Run Configurations; debugging is covered in Debugging Overview.

Ways to build and run

You want to Use Output appears in
Run one of a build file's actions (build, test, run, clean or your own) Double-click the action in the build file's Actions group Run tool window
Build the program and launch it, or debug it The Build & run row in the Actions group, or the run icon in the editor gutter of the main class Build tool window for the compile, then Run or Debug
Build modules with the IDE's own build actions The module's Build command and Build | Build Project Run tool window, Haxe Build tab
Compile before any run configuration starts The Run Haxe action before-launch step Build tool window
Run a single haxe command Execute Haxe Command in the tool window toolbar Run tool window

Before any of these runs, the IDE saves all open files. A build runs code from the project, such as macros and build scripts, so in a project that is not trusted you are asked to trust it first. See Core Concepts.

Build file actions

Every build file in the Haxe tool window has an Actions group. It holds the built-in actions of the build file's type, your custom actions and, when the plugin can launch the output, a Build & run row.

Build file Built-in actions Command they run
hxml Build, and Clean when the file builds C++ haxe <file>; Clean runs haxelib run hxcpp Build.xml clean in the -cpp output folder, so the next build recompiles everything
Lime or OpenFL project (xml, or a Lime .hxp project) test, run, build, clean haxelib run lime <action> <file> <target> (openfl instead of lime for an OpenFL project)
NME project (.nmml) test, run, build, clean haxelib run nme <action> <file> <target>
HXP script build haxelib run hxp <file>
  • <target> is the target currently selected for the file. Change it on the file's Target row; see Targets and Sections.
  • haxe comes from the module's Haxe SDK. For haxelib, see Which haxelib the plugin uses.
  • An hxml file's commands run in its working directory, which you can change with Set Working Directory… (see Build Files). The commands of other build files run in the build file's folder.
  • For the Lime air target, the plugin passes the Flex/AIR SDK set for the project to the Lime tool as AIR_SDK.

To run an action, double-click it, or select it and press Enter, or right-click it and choose Run.

The first time you run an action, the plugin creates a Haxe Action run configuration for it, named after the file and the action (for example build.hxml Build). An action that launches a run configuration uses that configuration instead. Later runs reuse it. The configuration is selected in the run widget, so you can run it again from the main toolbar. It stores the file and the action name, not the command line, so a changed target or SDK applies the next time it runs.

Build & run

The Build & run row builds the file and then launches the program it produces. Next to the row's name you see which kind of run configuration it uses, for example HashLink Application. The row appears only when the plugin knows where the build's output goes and has a run configuration that can launch it:

Build output Run configuration
HashLink bytecode (-hl out.hl, or the Lime hl target) HashLink Application
JavaScript from an hxml file (-js out.js) Haxe Web Browser and Node.js Application, as two rows
JavaScript from the Lime, OpenFL or NME html5 target Haxe Web Browser
SWF (-swf out.swf, or the Lime or NME flash target) Haxe Flash Application
The Lime air target Haxe AIR Application
A C++ executable, from an hxml file (-cpp out) or a Lime, OpenFL or NME project (including the Lime cpp and mac targets) HXCPP Application (IntelliJ)
Neko (-neko out.n, or the Lime or NME neko target) Neko Application
An interpreter build (--interp) Haxe Interpreter; the row reads Run, since there is nothing to build first

JavaScript from an hxml file can be browser code or a Node.js program, and the build file does not say which, so it gets both rows. The Node.js Application row comes first when the build uses -lib hxnodejs or -D nodejs.

An hxml C++ build gets a row only when it links an executable for this machine: not with static_link or dll_link, and not for another platform such as android or iphoneos. The configuration's executable is ${executable}, which is worked out at each launch from the output folder, the main class or HAXE_OUTPUT_FILE, the -debug suffix of a debug build and the platform's file extension.

There is no Build & run row for other outputs, for example Lime builds for Android, iOS or Electron, or a plain HXP script. For those, run the build file's own run or test action, or create a run configuration yourself.

To use it:

  • From the editor: the class a build starts from (-main in an hxml file, <app main> in a Lime or OpenFL project) shows a run icon in the gutter, beside its static function main() or, when it has none, its name. Click it and choose Run or, where the output can be debugged, Debug. Each build file that starts from the class, and each kind of launch, has its own entries, named like the run configuration, for example Run 'build-hl.hxml (HashLink)'. Tests build files are left out; their test classes have their own icons (see Unit Tests). The icon offers no Profile; see Profiling Overview.
  • Run: double-click the row, or right-click it and choose Run.
  • Debug: right-click the row and choose Debug. This is offered for HashLink, C++, JavaScript (browser and Node.js), SWF and interpreter output. Debugging SWF output (Flash and AIR) needs the Flash/Flex plugin, which is available for IntelliJ IDEA Ultimate only. See Debugging Overview.
  • Profile (Experimental): right-click the row and choose Profile (shown as Profile with 'profiler' when only one profiler fits). This needs IntelliJ IDEA Ultimate and is offered for HashLink, C++, JavaScript in the browser and AIR output; Node.js programs cannot be profiled yet. See Profiling Overview.

The context menu of a Build & run row with Run, Debug and Profile with 'JavaScript Profiler'

The context menu of a Build & run row for a browser build

The first launch creates a run configuration named after the file and the kind, for example build.hxml (HashLink). It has a Run Haxe action step that runs the file's default build action before the program starts, and the plugin fills in where the output is. Later launches reuse the configuration and update the output paths if the build's layout changed; your other settings stay. Some values cannot be guessed, such as the browser, the Flash player or the Flex/AIR SDK. If one is missing, complete it in the run configuration; see Run Configurations.

When you choose Debug, the compile gets the arguments that make the output debuggable, for example -debug, and for C++ the debug server library of the configuration being debugged. See Debugging Overview.

The build command

Each module in the Haxe tool window has a Compilation group. Its Build command row says what the IDE runs when you build the module with Build | Build Project or Build | Build Module. Projects created from a new-project wizard template that generates a build file, and modules converted from 1.x, get a build command right away.

A module without a build command builds its default build file with that file's default action, for example haxe build.hxml or lime build html5. The row then ends in (default). The default build file is the project's active build file when the module has it, otherwise the module's only build file that is not a tests build file. A module with several build files and none of them active has no default; its row reads (not set) and these actions skip it.

To set the build command:

  1. Click the value of the Build command row, or right-click the row and choose Configure Build Command….

  2. In the Build Command dialog, set the fields:

    Field Meaning
    Build file: The build file to build. Default builds the module's default build file, named in brackets. None (skip on project build) keeps these actions from building the module at all.
    Command: (default) runs the file's default build action. Pick another action of the file to run that instead.
    Additional arguments: Arguments added to the end of the command, for example -debug.
  3. Click OK.

As a shortcut, right-click any action in a build file's Actions group and choose Set as Build Command.

To run the build command:

  • Choose Build | Build Project or Build | Build Module. The commands of all modules being built run one after another in a Haxe Build tab of the Run tool window. The output appears while each command runs; the first failing command stops the build, and so does Stop in the tab.
  • Or right-click the Build command row and choose Run Build Command. This runs it in a console in the Run tool window.
  • The IDE's standard Build before-launch step, which run configurations you create yourself start with, also runs the build command of the configuration's module.

The build command runs the chosen action's own command only. Actions it runs first are not run, so an action without a command of its own does not work as a build command.

When the compilation server is enabled for the module, build commands that run haxe directly or build a Lime, OpenFL or NME project compile through it. Builds that produce a SWF never use it.

The Run Haxe action before-launch step

Run Haxe action is a before-launch step that runs an action of a build file before a run configuration starts. The configurations that Build & run creates already have one. You can add it to any run configuration: open the configuration, and in its Before launch list add Run Haxe action. The Run Haxe Action dialog has these fields:

Field Meaning
Build file: The build file to build.
Action: The action to run: a built-in action of the file or one of your custom actions.
Arguments: Arguments added to the end of the action's command.
Add debug arguments when launched with Debug When the configuration is started with Debug, add the arguments that make the output debuggable. They depend on the configuration being debugged; the line below the checkbox shows them, for example Adds: -debug. Turn it off if your build file already contains them.

The step's output appears in the Build tool window. When the action runs other actions first, those run before it, each in its own tab; an action without a command of its own only runs those. If a build fails, the program is not started. In a project that is not trusted, the step skips the compile with Compile skipped: the project is not trusted and does not start the program.

Custom actions

A custom action is a command line of your own, attached to a build file. It appears in the file's Actions group next to the built-in actions and works like them: you can run it, use it as the build command and pick it in a Run Haxe action step or a Haxe Action run configuration. An action can also launch what it builds and run other actions first.

To add one:

  1. Right-click the build file's Actions group (or one of its actions) and choose Add Action….

  2. Fill in the Add Action dialog:

    Field Meaning
    Name: The name shown in the Actions group. Names the file already uses are refused: its built-in actions and its other custom actions.
    Command: The command line to run. It may stay empty when the action runs other actions first; it then only runs those.
    Work directory: Where the command runs. It starts as ${moduleRoot}; clear it to run in the build file's working directory.
    Create run configuration, Run existing configuration Launch something after the command; see Launching what an action builds.
    Run before Actions to run first; see Run other actions first.
  3. Click OK.

The context menu of an action offers more:

  • Duplicate Action… opens Add Action filled in with a copy of the row: a custom action's values, a built-in action's command or the Build & run row's build with its launch. The copy is named name (copy), and its command uses ${haxe}, ${haxelib} and ${target}, so a built-in action becomes one you can change. Extra flags, such as Lime's -64, stay in the copy.
  • Edit Action… changes a custom action. Built-in actions cannot be edited; duplicate them instead.
  • Remove Action asks first. When other actions run it first, a second question offers Remove There Too, Keep as Missing (the step stays there, shown as missing) and Cancel (removes nothing).

The command and the work directory can use these variables:

Variable Expands to
${target} The target selected for the file, for example html5. Only in the command, and only for Lime, OpenFL and NME files; elsewhere it stays as written.
${serverPort} The port of the compilation server, which is started when needed. Only in the command; it stays as written while the compilation server is disabled.
${haxe}, ${haxelib} The haxe and haxelib executables of the module's Haxe SDK, so the command follows an SDK change and works on every platform. Only in the command.
${moduleRoot} The module's root folder.
${projectRoot} The project's root folder.

For example, a release build of the selected target, for a project.xml in the module's root folder:

${haxelib} run lime build project.xml ${target} -release

Note

The command runs directly, not through a shell, so shell syntax such as |, > or && does not work. To use it, call the shell yourself, for example sh -c "..." or cmd /c .... A program name without a path, such as haxe, is looked up on the PATH; use ${haxe} or ${haxelib} for the SDK's own. On Windows, .bat and .cmd programs on the PATH are found too.

Launching what an action builds

Two collapsed groups of the Add Action dialog make an action launch a program after its command. An action uses at most one of them:

  • Create run configuration: choose the Type:, for example HashLink Application or HXCPP Application (IntelliJ). The fields below it start from the build file's current target and output; a field you leave blank keeps following them. Add debug arguments when launched with Debug works as in the Run Haxe action step. The configuration is named after the file, the action and the type, for example build.hxml release (HashLink), and runs the action as its Run Haxe action step.
  • Run existing configuration: choose any configuration from the run widget under Configuration:, of any type. With a command, the command becomes that configuration's Run Haxe action step, ahead of its own steps; without one, the action only starts the configuration.

The row of a launching action shows, after its name, what it starts. Its context menu offers Run, Debug when the configuration can be debugged and Profile for the types a profiler supports. Renaming the action keeps its build steps pointing at it; removing it drops them.

Run other actions first

The Run before group lists actions that run before this one, in order. Each runs in its own working directory with its own SDK and variables. The first failure stops the rest and the action itself.

  • Click + to add one. The popup lists the file's own actions first, then one entry per module, which opens its build files and their actions. An action of another build file reads as module › path › action.
  • A pick that would make an action run itself is refused with a message, for example Cannot add release: circular reference, it already runs prepare first.
  • An action without a command of its own only runs its Run before actions, for example an all action that runs clean and then build.
  • References follow when the action is renamed and when its build file, or a folder above it, is moved or renamed. A reference to an action that no longer exists shows as (missing), and running the action reports it.
  • To clean before a C++ build, put the Clean action in Run before. A single command such as ... clean && ... does not work, because commands do not run through a shell.

For commands that do not belong to a build file, such as a formatter or a linter, use tools instead.

Running a single haxe command

Execute Haxe Command in the toolbar of the Haxe tool window asks for Arguments passed to the haxe compiler: and runs the project's default haxe with them, in the project folder. It remembers the last arguments you entered.

Where output appears

What runs Where its output appears
Actions, custom actions, the Run Build Command entry, tools and Execute Haxe Command A console tab in the Run tool window
Build | Build Project and Build | Build Module The Haxe Build tab in the Run tool window
The Run Haxe action step, including the compile of Build & run The Build tool window, titled with the file and the action, for example build.hxml: Build
The program started by a run configuration The Run or Debug tool window

In the Run tool window consoles, compiler messages such as Main.hx:12: characters 4-9 : ... link to the source line; click the file name to open it. For a launched program, such positions resolve against the class paths of the build that produced it first, so two modules' Main.hx are not mixed up. Actions, tools, Build | Build Project and the Run Haxe action step run in a pseudo-terminal, so when a tool asks a question, you can type the answer in the console.

Stopping a build

  • Commands in the Run tool window: click Stop in their tab.
  • Build | Build Project and Build | Build Module: click Stop in the Haxe Build tab. This ends the running command and skips the remaining modules; the tab ends with Haxe build stopped.
  • The compile of a Run Haxe action step: click Stop in the Build tool window. This ends the compiler process, which also helps when a compile hangs.

Clone this wiki locally