The command-line compiler#
mx2cc is the command-line compiler for Monkey2.
Please note
The actual executable name of the command-line compiler is different and depends on the operating system!
The compiler binary#
The Monkey2 compiler mx2cc is located in the bin/ directory of your Monkey2 installation.
See the following table for the actual executable name on each host platform:
| Platform | Compiler binary |
|---|---|
| Windows | /bin/mx2cc_windows.exe |
| Linux | /bin/mx2cc_linux |
| macOS | /bin/mx2cc_macos |
| Raspberry Pi | /bin/mx2cc_raspbian |
Hint
If you add the Monkey2/bin/ directory to your PATH environment variable,
you are able to use the Monkey2 compiler directly from every directory on the command-line or in a terminal.
Compiler usage#
The command-line options for mx2cc are:
mx2cc command options input
Compiler commands#
| Command | Description |
|---|---|
| makeapp | Build an application. input should be a *.monkey2 file. |
| makemods | Build module(s). input should be a space separated list of module names, or nothing to make all modules. |
| makedocs | Build the documentation for a set of modules. input should be a space separated list of module names, or nothing to make all modules. |
Compiler options#
| Option | Description |
|---|---|
| -quiet | Emit less info when building. |
| -verbose | Emit more info when building. |
| -clean | Rebuilds everything from scratch. |
| -time | Output information about the build-time. |
| -parse | Parse only. Checks for parsing errors. |
| -semant | Parse and semant. Checks for parsing and semantic errors. |
| -translate | Parse, semant and translate. |
| -build | Parse, semant, translate and build. |
| -run | Runs the application after successful build. |
| -target=target | Set target to one of the following values: desktop (default: alias for current host), windows, macos, linux, raspbian, android, ios, emscripten |
| -config=config | Set config to: debug (default) or release |
| -apptype=apptype | Set apptype to: gui (default) or console |
Examples#
Compile a desktop gui app in debug mode (default) and run it:
mx2cc makeapp main.monkey2
Compile a console application in release mode for the host operating system and run it:
mx2cc makeapp -config=release -apptype=console myfile.monkey2
Compile a game for the 'iOS' target:
mx2cc makeapp -config=release -target=ios mygame.monkey2
Build the complete docs:
mx2cc makedocs
Force clean rebuild of all modules for the 'Android' target in release and debug mode:
mx2cc makemods -clean -target=android -config=debug
mx2cc makemods -clean -target=android -config=release
Compile your own module 'mymodule'. The module/library must be located in the 'modules' directory.
mx2cc makemods -config=debug mymodule
mx2cc makemods -config=release mymodule