Haxe Documentation

repository·development·Indexed 27 days ago

https://github.com/haxefoundation/haxe

Haxe is a high-level, strictly-typed programming language and cross-compiler designed to build applications for platforms including JavaScript, C++, JVM, Lua, PHP 7, Python 3, HashLink, NekoVM, and Flash. The toolkit includes the Haxe programming language, a high-speed cross-compiler, and a cross-platform standard library.

Tokens
2K
Snippets
6
Records
17
Agent score
92%

What's inside Haxe

  1. Overview of Haxe Toolkit

    development

    Haxe is an open source toolkit for building cross-platform tools and applications. It consists of:

    • The Haxe programming language: A modern, high-level, strictly-typed language.
    • The Haxe cross-compiler: A high-speed compiler targeting multiple platforms.
    • The Haxe standard library: A complete, cross-platform library of common functionality.

    Supported compilation targets include:

    • JavaScript
    • C++
    • JVM
    • Lua
    • PHP 7
    • Python 3
    • HashLink
    • NekoVM
    • Flash (SWF Bytecode)
    • Haxe interpreter
  2. Set up OCaml development environment

    development

    The Haxe compiler is written in OCaml and requires OCaml version 5.0 or higher. It is recommended to use OPAM 2.x.

    • Unix (Mac, Linux): Follow the official OPAM installation instructions.
    • Windows: Use the Cygwin/MinGW-based OPAM environment provided by fdopen. Ensure you use 64-bit versions and OPAM 2.
    • Docker/WSL Note: If you encounter errors related to bubblewrap or Linux user namespaces during opam init, use the --disable-sandboxing flag.
  3. Use a plugin in a Haxe project

    development

    To use a plugin in a Haxe project, you must first set it up as a local Haxe library using haxelib dev. Once registered, you can access the plugin's functionality within a Haxe macro.

    1. Register the plugin:
    $ haxelib dev example path/to/haxe/plugins/example
    1. Access it in a macro:
    macro static public function testPlugin() {
    	Example.plugin.hello();
    	return macro {}
    }
  4. Obtain Haxe source code

    development

    To build Haxe from source, clone the repository using the --recursive flag to ensure all necessary submodules are included. If downloading source archives (.zip or .tarballs) from GitHub releases, you must manually place the submodule source code into the appropriate sub-folders.

    git clone --recursive https://github.com/HaxeFoundation/haxe.git
  5. Install native and OCaml dependencies

    development

    Haxe requires several native libraries and OCaml libraries.

    Native Libraries

    Install these using your system package manager:

    PlatformCommand / Instructions
    macOSbrew install zlib pcre2 mbedtls@3 (Note: use mbedTLS 3.x, 4.x is not supported)
    Debian/Ubuntusudo apt install libpcre2-dev zlib1g-dev libmbedtls-dev
    Windows (Cygwin)Run setup-x86_64.exe and install make, git, zlib-devel, libpcre2-devel, mingw64-x86_64-gcc-core, mingw64-x86_64-zlib, and mingw64-x86_64-pcre2. Copy zlib1.dll and libpcre2-8-0.dll from the Cygwin mingw bin directory to the Haxe source directory.
    NekoInstall Neko (required for haxelib) via Neko binaries (add to PATH) or via Chocolatey.

    OCaml Libraries

    Use OPAM to pin the Haxe package to your local source directory and install its dependencies as defined in the repository's opam file.

    # pin the haxe package to the checked out Haxe source directory
    opam pin add haxe path/to/haxe --kind=path --no-action
    
    # install the haxe package dependencies (as listed in the `opam` file)
    opam install haxe --deps-only
  6. Update Flash Player signatures in Homebrew Cask

    development

    To update Flash Player signatures in Homebrew Cask, use a macOS machine to run the developer script provided by homebrew-cask. This semi-automates the update process.

    Steps:

    1. Clone the homebrew-cask repository: git clone https://github.com/Homebrew/homebrew-cask
    2. Run the update script with the new version string: ./developer/bin/update_cask_family flash $NEW_VERSION_STRING

    If the homebrew-cask CI passes, the Pull Request will be automatically merged by a bot.

    Note: Adobe's appcast (used by homebrew-cask CI to verify version strings) is often outdated for approximately one day after a new Flash Player release. You may need to wait for the appcast to sync before the CI succeeds.

  7. Install the built Haxe compiler

    development

    Before installing, remove any existing Haxe installations to avoid conflicts and ensure the HAXE_STD_PATH environment variable is not set.

    • Unix (Mac/Linux): Run sudo make install.
    • Windows: Add the checked-out Haxe source directory to the beginning of your PATH environment variable.
    # On Unix
    sudo make install
  8. Install Haxe

    development

    You can install Haxe by downloading pre-built binaries for your specific platform from the official download page.

    Available platforms include:

    • Windows: via .exe installer or .zip binaries.
    • OSX: via .pkg installer or .tar.gz binaries.
    • Linux: via software packages or .tar.gz binaries (32-bit and 64-bit).

    For automated development builds, visit build.haxe.org.

  9. Use objsize for OCaml value size computation

    development

    The objsize library provides tools to compute the size of OCaml values. It can calculate:

    • Count of words used for values.
    • Count of values' headers.
    • Maximal depth of values.
    • Size of values in bytes.

    For detailed API documentation, refer to the objsize.mli file in the library directory.