Skip to content

Instantly share code, notes, and snippets.

@ZwodahS
Last active July 6, 2022 07:37

Revisions

  1. ZwodahS revised this gist Feb 9, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion how_to_build_for_mac_haxe_heap.md
    Original file line number Diff line number Diff line change
    @@ -76,9 +76,11 @@ There are 2 ways to get hl and the required libraries.
    The first way is to get it from github [releases](https://github.com/HaxeFoundation/hashlink/releases) directly.
    The second way is to build hashlink ourselves by following the instruction on hashlink [github](https://github.com/HaxeFoundation/hashlink).

    First, copy `hl` to `MacOS`.

    For the libraries, we will put them in `Frameworks`.
    First, copy `hl` to `MacOS`
    Copy all `hdll` and also `libhl.dylib` to `Frameworks`.

    Not all hdll are required. For heaps, the basic required ones are
    - `fmt.hdll`
    - `openal.hdll`
  2. ZwodahS revised this gist Feb 9, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion how_to_build_for_mac_haxe_heap.md
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ The following is what I got working.
    <key>CFBundleName</key>
    <string>Game Name</string>
    <key>CFBundleGetInfoString</key>
    <string>Made with Haxe/Heaps</string>
    <string>Made with Haxe/Heaps</string>
    <key>CFBundleIconFile</key>
    <string>icon.png</string>
    <key>CFBundleIdentifier</key>
  3. ZwodahS revised this gist Feb 9, 2022. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions how_to_build_for_mac_haxe_heap.md
    Original file line number Diff line number Diff line change
    @@ -10,13 +10,13 @@ Game.app
    |_Info.plist
    |_MacOS
    |_run.sh
    |_hl
    |_hlboot.dat
    |_hl
    |_hlboot.dat
    |_Resources
    |_res.pak
    |_Frameworks
    |_*.dylib
    |_*.hdll
    |_*.dylib
    |_*.hdll
    ```

    ### Info.plist
  4. ZwodahS revised this gist Feb 9, 2022. 1 changed file with 16 additions and 18 deletions.
    34 changes: 16 additions & 18 deletions how_to_build_for_mac_haxe_heap.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,7 @@
    # How to build .app for Haxe/Heaps

    ## Preparing your game
    Normally you would load your resources from the same directory as your binary, but when building for Mac, you will have to do it slightly differently.
    This is optional but good to do.

    Instead of loading your res from `.`, your should load it from `../Resources/`.
    Normally you would load your resources from the same directory as your binary, but when building for Mac, you will have to do it slightly differently. Instead of loading your res from `.`, your should load it from `../Resources/`.

    ## Mac .app structure
    ```
    @@ -13,11 +10,13 @@ Game.app
    |_Info.plist
    |_MacOS
    |_run.sh
    |_*.dylib
    |_*.hdll
    |_hl
    |_hlboot.dat
    |_Resources
    |_res.pak
    |_Frameworks
    |_*.dylib
    |_*.hdll
    ```

    ### Info.plist
    @@ -57,26 +56,29 @@ The following is what I got working.
    </dict>
    </plist>
    ```
    We will also be using run.sh to run instead of running hl directly.

    ### run.sh
    We will also be using run.sh to run instead of running hl directly.
    ```
    #!/bin/bash
    BASEDIR=$(dirname "$0")
    cd $BASEDIR
    export DYLD_LIBRARY_PATH=.
    export DYLD_LIBRARY_PATH=../Frameworks
    ./hl
    ```
    This is to help set the running directory + also set the dylib path.

    ### hlboot.dat
    Rename your game.hl to hlboot.dat. Alternatively you could just specify the name in the run.sh.
    Rename your game.hl to hlboot.dat and copy it to `MacOS`. Alternatively you could just specify the name in the run.sh.

    ### dylib and hdll
    Since there is no releases for Mac on Hashlink's github, we will need to build hashlink ourselves.
    Follow the instructions on the hashlink [github](https://github.com/HaxeFoundation/hashlink).
    ### hl, dylib and hdll
    There are 2 ways to get hl and the required libraries.
    The first way is to get it from github [releases](https://github.com/HaxeFoundation/hashlink/releases) directly.
    The second way is to build hashlink ourselves by following the instruction on hashlink [github](https://github.com/HaxeFoundation/hashlink).

    Let's first copy all the `hdll` in hashlink and also `libhl.dylib` to `MacOS`.
    For the libraries, we will put them in `Frameworks`.
    First, copy `hl` to `MacOS`
    Copy all `hdll` and also `libhl.dylib` to `Frameworks`.
    Not all hdll are required. For heaps, the basic required ones are
    - `fmt.hdll`
    - `openal.hdll`
    @@ -121,8 +123,4 @@ fmt.hdll:
    ```
    Although it looks like we will only need `libvorbisfile.3.dylib`, if you run `otool -L libvorbisfile.3.dylib`, you will realised that the other `dylib` are required by vorbisfile.

    Do this and you can figure what you need, and the specific name that the file needs to be.

    All `dylib` and `hdll` can be placed in `MacOS` together with hl and run.sh.
    I believe we can put it elsewhere, i.e. Frameworks, and export the path instead.
    I haven't test that as of the writing, so when I find time, I will test and update again.
    Do this and you can figure what you need, and the specific name that the file needs to be.
  5. ZwodahS revised this gist Feb 8, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions how_to_build_for_mac_haxe_heap.md
    Original file line number Diff line number Diff line change
    @@ -102,10 +102,10 @@ For each of them, there will be some dylib that are required.
    #### uv.hdll
    - `libuv.1.dylib`

    Note that the dylib name needs to be exactly what is required or it will not work.
    These name works as of now but it may change in the future with new releases of hashlink etc.
    Note that the dylib names need to be exactly what is required or it will not work.
    These names work as of now but it may change in the future with new releases of hashlink etc.

    You can find out what the name needs to be by using `otool` recursively.
    You can find out what the names of each of the dylib needs to be by using `otool` recursively.

    `otool -L fmt.hdll`

  6. ZwodahS revised this gist Feb 8, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions how_to_build_for_mac_haxe_heap.md
    Original file line number Diff line number Diff line change
    @@ -101,6 +101,7 @@ For each of them, there will be some dylib that are required.

    #### uv.hdll
    - `libuv.1.dylib`

    Note that the dylib name needs to be exactly what is required or it will not work.
    These name works as of now but it may change in the future with new releases of hashlink etc.

  7. ZwodahS created this gist Feb 8, 2022.
    127 changes: 127 additions & 0 deletions how_to_build_for_mac_haxe_heap.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,127 @@
    # How to build .app for Haxe/Heaps

    ## Preparing your game
    Normally you would load your resources from the same directory as your binary, but when building for Mac, you will have to do it slightly differently.
    This is optional but good to do.

    Instead of loading your res from `.`, your should load it from `../Resources/`.

    ## Mac .app structure
    ```
    Game.app
    |_Contents
    |_Info.plist
    |_MacOS
    |_run.sh
    |_*.dylib
    |_*.hdll
    |_hl
    |_hlboot.dat
    |_Resources
    ```

    ### Info.plist
    You should be able to to find the full xml online, (or just copy it from another .app)
    The following is what I got working.
    ```
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>run.sh</string>
    <key>CFBundleName</key>
    <string>Game Name</string>
    <key>CFBundleGetInfoString</key>
    <string>Made with Haxe/Heaps</string>
    <key>CFBundleIconFile</key>
    <string>icon.png</string>
    <key>CFBundleIdentifier</key>
    <string></string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>0.1.0</string>
    <key>CFBundleSignature</key>
    <string></string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>CFBundleSupportedPlatforms</key>
    <array>
    <string>MacOSX</string>
    </array>
    </dict>
    </plist>
    ```
    We will also be using run.sh to run instead of running hl directly.

    ### run.sh
    ```
    #!/bin/bash
    BASEDIR=$(dirname "$0")
    cd $BASEDIR
    export DYLD_LIBRARY_PATH=.
    ./hl
    ```
    This is to help set the running directory + also set the dylib path.

    ### hlboot.dat
    Rename your game.hl to hlboot.dat. Alternatively you could just specify the name in the run.sh.

    ### dylib and hdll
    Since there is no releases for Mac on Hashlink's github, we will need to build hashlink ourselves.
    Follow the instructions on the hashlink [github](https://github.com/HaxeFoundation/hashlink).

    Let's first copy all the `hdll` in hashlink and also `libhl.dylib` to `MacOS`.
    Not all hdll are required. For heaps, the basic required ones are
    - `fmt.hdll`
    - `openal.hdll`
    - `sdl.hdll`(if you are using sdl)
    - `ui.hdll`
    - `uv.hdll`

    For each of them, there will be some dylib that are required.

    #### fmt.hdll
    - `libpng16.16.dylib`
    - `libturbojpeg.0.dylib`
    - `libvorbisfile.3.dylib`
    - `libvorbis.0.dylib` `libogg.0.dylib`
    - `libz.1.dylib`

    #### sdl.hdll
    - `libSDL2-2.0.0.dylib`

    #### openal.hdll
    - `libopenal.dylib`

    #### uv.hdll
    - `libuv.1.dylib`
    Note that the dylib name needs to be exactly what is required or it will not work.
    These name works as of now but it may change in the future with new releases of hashlink etc.

    You can find out what the name needs to be by using `otool` recursively.

    `otool -L fmt.hdll`

    ```
    fmt.hdll:
    fmt.hdll (compatibility version 0.0.0, current version 0.0.0)
    libhl.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 54.0.0, current version 54.0.0)
    /usr/local/opt/jpeg-turbo/lib/libturbojpeg.0.dylib (compatibility version 0.0.0, current version 0.2.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
    /usr/local/opt/libvorbis/lib/libvorbisfile.3.dylib (compatibility version 7.0.0, current version 7.8.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.0.0)
    ```
    Although it looks like we will only need `libvorbisfile.3.dylib`, if you run `otool -L libvorbisfile.3.dylib`, you will realised that the other `dylib` are required by vorbisfile.

    Do this and you can figure what you need, and the specific name that the file needs to be.

    All `dylib` and `hdll` can be placed in `MacOS` together with hl and run.sh.
    I believe we can put it elsewhere, i.e. Frameworks, and export the path instead.
    I haven't test that as of the writing, so when I find time, I will test and update again.