Compiler Batch Files / Scripts

The GameMaker compiler allows you to place Batch files (Windows) or Shell scripts (on macOS and Linux) in your project directory, and in the directory for each extension in your project.

Placement

A script file may be placed at the root of your project directory, alongside the project's .yyp file.

A script file may also be placed in the directory of an extension, which may look like this: <project_directory>/extensions/<extension_folder>/.

The extension versions of a script file will be executed first, and its root version will be executed last. The order in which extensions are executed can't be controlled, so an extension developer must ensure that one extension's scripts don't rely on another extension's scripts.

Execution

Script files with specific names, placed in any of the directories described above, are executed at various points during the compilation process:

NOTE These steps are listed in the order that they are run, except for those under "Platform-Specific Steps".

Windows Batch File NamemacOS/Linux Shell Script NameDescription
pre_project_step.batpre_project_step.shThis is executed before the asset compiler has loaded the project files
post_project_step.batpost_project_step.shThis is executed after the asset compiler has loaded the project files
pre_run_step.batpre_run_step.shOnly runs when testing the game ("Run" or F5 in the IDE), not run when creating a package

This is executed before the game deployment is about to start
pre_build_step.batpre_build_step.shThis is executed before the asset compiler is asked to build the game
post_textures.batpost_textures.shThis is executed after the textures for your game have been generated. You can use this step to optimise your game textures manually.

This script receives an environment variable called TexturesDir, which stores the path to the generated textures.
post_build_step.batpost_build_step.shThis is executed after the asset compiler has been started for building the game
remote_build_step.batremote_build_step.shThis is executed on the remote machine, when you are on a Windows machine and compiling remotely for macOS/iOS/tvOS or Ubuntu.
pre_package_step.batpre_package_step.shThis is executed before the final packaging step, which is when all files are ready but the final ZIP file or store package is about to be created
post_package_step.batpost_package_step.shOnly runs when creating a package/executable

This is executed after the final packaging step has completed and the final ZIP file or store package has been prepared
post_run_step.batpost_run_step.shOnly runs when testing the game ("Run" or F5 in the IDE), not run when creating a package

This is executed when the game is prepared and ready to run; after the script's execution the game is started
Platform-Specific Steps
pre_gradle_step.batpre_gradle_step.shAndroid This is executed when the files necessary for the Android tools have been created, but before Gradle is called. You can use this step to access and modify the Android files yourself, before the Android tools compile it into a final executable.

These script files are supported when building on all target platforms.

Extension Version and Options Environment Variables

You can retrieve the extension version and any of the extension options in the Batch files/Shell scripts: 

Replace <ExtensionName> here with the name of the extension you're using.

Disabling Scripts for an Extension

If you use multiple extensions that run scripts, for example, Steamworks and GDK, then you'll want to disable Steamworks when exporting to GDK, and vice-versa.

For that, see: How to Disable Extensions?