Back Part 3 – Distributing a Haxe project 4 | ♥ 11

After hundreds of hours spent on your Haxe / Heaps project, you probably want to release it at some point.

All you want in the end is a basic Executable file that you could push on your favorite distribution platform. Let’s see how we could do that.

RedistHelper

About

RedistHelper is a free tool I wrote to facilitate my RPG Map redistributables creation. It makes the whole process automated and hassle free.

Install latest stable version

From a command line, just get the latest release by running:

haxelib install redistHelper

You will need my general purpose libs too:

haxelib install deepnightLibs

Git version

Optionally, you can also you the latest GitHub version using the following command. Be careful though, as it might be unstable.

haxelib git redistHelper https://github.com/deepnight/redistHelper.git
haxelib git deepnightLibs https://github.com/deepnight/deepnightLibs.git

Using redistHelper

Showing help

The most basic way to use is to open a command line inside your project root (where the HXML files are), then type:

haxelib run redistHelper

This will display the tool help, including some examples.

Basic usage

To package your project, just run:

haxelib run redistHelper myProject.hxml

RedistHelper will parse your HXML and create a redist folder containing all the required files. You can simply distribute that package and it should work :)

You can package all your HXML files in one single call:

haxelib run redistHelper gameHashlink.hxml gameJs.hxml gameSwf.hxml

You can optionally add the following parameters to the RedistHelper command:

  • -zip : will create a ZIP archive for each package
  • -v : enable verbose mode (mostly useful for debugging)

Embedding extra files

You might need to add some extra files to your packages, like a README or a LICENSE. Just add their path to you RedistHelper command:

haxelib run redistHelper game.hxml docs/README docs/license/LICENSE

You can rename any extra file on the file by adding a “@” to their path:

haxelib run redistHelper game.hxml docs/README@readme.txt

Available targets

HashLink project

The goal here is to turn your app into classic and easy to distribute Windows Executable (EXE).

When packaging HashLink (HL) projects, RedistHelper will copy all the required runtime files directly from the Haxe and HL folders from your system. This includes DLL and NDLL, the HL executable and a few other things.

Your project.hl file will be renamed to hlboot.dat which is the default file loaded by hl.exe when it’s run without parameters (see link).

The hl.exe itself is renamed to something closer to your actual project name, feel free to rename as you wish.

If your HXML uses the hldx library, the redistHelper will package a DirectX folder.

If your HXML uses the hlsdl library, the redistHelper will package a OpenGL (SDL) folder.

You can use the -hl32 to also package a 32 bits version of the HL runtimes, for older systems. Warning: this will use the last release HL 32 bits (1.10). All recent HL updates won’t be included!

HTML5 / Javascript

When packaging a JS target project, RedistHelper will produce a basic HTML file to load your app properly. You can use it to create your own integration.

In your HTML body, you basically should have something like that:

<canvas id="webgl"></canvas>
<script type="text/javascript" src="myApp.js"></script> 

Please note that the webgl ID is important here, as it’s the primary target for web apps build with using Haxe.

Neko VM

Neko is a lightweight virtual machine for Haxe which can be useful to build small command line tools for example.

RedistHelper will turn your Neko binary file (*.n) into a Windows Executable and add all the required runtime files.

Adobe Flash

While Flash is supported, it’s not super useful here, as the SWF file is already a package in its own.

Distributing on platforms

Itch.io

You have 2 ways to push an app on Itch.io:

If you install it, Butler can be used right from the command line to upload your fresh new build to itch.io in a single command line:

butler push redist/directx myUserName/my-app-name:win-directx64

If you want to upload a JS app that should be played right from the user browser on the itch.io website, you just have to package your app using the -zip parameter:

haxelib run redistHelper myJsGame.hxml -zip

This will create a ZIP archive that you can easily upload to your dashboard, or send using Butler.

Contributing

RedistHelper is open source (under MIT license). You can download the source, adapt to your needs or add more packaging targets.

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Anon:

    does heaps support ios or android as build targets? if so does redistHelper support those too?

    August 27, 2021 at 13:40
    • Sébastien Bénard:

      Hi, Heaps supports iOS/Android in theory, but the documentation is lacking to say the least. You might want to get in touch with Playdigious team that ported Dead Cells to mobile for more info, or try the official Haxe discord?

      September 6, 2021 at 11:01
  2. Nyrh:

    Super, j'ai réussi à faire mon .exe en 2 min alors que j'ai passé 2 semaines à essayer de passer par HL/C … :(
    J'ai dû fournir mon fichier res/ pour load les images ou autres par contre

    May 4, 2020 at 16:08
    • Sébastien Bénard:

      C'est possible de passer le dossier res en "embed", c'est à dire compilé avec le code. C'est via hxd.Res.initEmbed il me semble de mémoire

      May 4, 2020 at 21:51