Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 56 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@ jobs:
build_system: [make, cmake, cmake-mingw, cmake-clang-cl, vs2019, makegcc14]

include:
- target: linux
archive_ext: tar.gz

- target: linux
runner: ubuntu-latest
haxe_nightly_dir: linux64
archive_ext: tar.gz

- target: linux
architecture: arm64
runner: ubuntu-24.04-arm
haxe_nightly_dir: linux-arm64

- target: darwin
haxe_nightly_dir: mac
archive_ext: tar.gz

- target: darwin
architecture: 64
runner: macos-latest
runner: macos-15-intel

- target: darwin
architecture: arm64
Expand Down Expand Up @@ -65,7 +72,6 @@ jobs:
cmake_generator: Visual Studio 17 2022

- target: windows
architecture: 64
runner: windows-2025
build_system: cmake-mingw

Expand All @@ -90,35 +96,21 @@ jobs:
- target: darwin
build_system: vs2019

- target: linux
architecture: 32

- target: darwin
architecture: 32

- target: linux
architecture: arm64

- target: windows
architecture: arm64

- target: windows
build_system: make

- target: darwin
architecture: 64
build_system: make

- target: darwin
build_system: makegcc14

- target: windows
build_system: makegcc14

- target: windows
architecture: 32
build_system: cmake-mingw

- target: darwin
build_system: cmake-mingw

Expand Down Expand Up @@ -148,31 +140,42 @@ jobs:

- name: "Install: Required Dev Packages"
run: |
set -eux
set -ex

case "${{ matrix.target }}" in
linux)
if [ ${{matrix.architecture}} == 32 ]; then
echo "MARCH=32" >> $GITHUB_ENV
sudo dpkg --add-architecture i386
SUFFIX=":i386"
EXTRA_APT_PKGS="gcc-multilib g++-multilib"
fi

case "${{ matrix.target }}${{ matrix.architecture }}" in
linux64)
echo "MARCH=64" >> $GITHUB_ENV
sudo apt-get update -y
sudo apt-get install --no-install-recommends -y \
libmbedtls-dev \
libopenal-dev \
libpng-dev \
libmbedtls-dev${SUFFIX} \
libopenal-dev${SUFFIX} \
libpng-dev${SUFFIX} \
libsdl2-dev \
libturbojpeg-dev \
libuv1-dev \
libvorbis-dev \
libsqlite3-dev
libturbojpeg-dev${SUFFIX} \
libuv1-dev${SUFFIX} \
libvorbis-dev${SUFFIX} \
libsqlite3-dev${SUFFIX} \
${EXTRA_APT_PKGS}
;;

darwin*)
darwin)
if [ "${{matrix.build_system}}" != "cmake" ]; then
brew update
brew bundle
fi
;;

windows*)
windows)
if [[ ${{ matrix.build_system }}${{ matrix.architecture }} == cmake-mingw32 ]]; then
echo "C:\mingw32\bin" >> $GITHUB_PATH
fi

if [[ ${{ matrix.build_system }} == cmake-mingw ]]; then
SDL_SUFFIX=mingw
else
Expand Down Expand Up @@ -200,10 +203,13 @@ jobs:
sudo apt update
sudo apt install -y gcc-14 g++-14
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 60 --slave /usr/bin/g++ g++ /usr/bin/g++-14
if [[ ${{ matrix.architecture }} == 32 ]]; then
sudo apt install -y gcc-14-multilib g++-14-multilib
fi
gcc --version

- name: Install haxe
uses: krdlab/setup-haxe@v2
uses: tobil4sk/setup-haxe@9d1527c4bb9d1d449d196a0822118692ceeac457
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is needed for linux arm64: krdlab/setup-haxe#71

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I think we'll need some official fork of setup-haxe one day, but it's fine for now.

with:
haxe-version: latest

Expand Down Expand Up @@ -242,7 +248,11 @@ jobs:
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DFLAT_INSTALL_TREE=ON
;;
linux64)
linux32)
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} -DWITH_SDL=OFF \
-DCMAKE_TOOLCHAIN_FILE=other/cmake/linux32.toolchain.cmake
;;
linux*)
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} ;;
esac

Expand Down Expand Up @@ -279,7 +289,11 @@ jobs:
;;

make*)
make
if [[ ${{ matrix.target }}${{ matrix.architecture }} == linux32 ]]; then
make -o sdl # 32 bit sdl cannot be installed
else
make
fi
sudo make install
if [[ ${{ matrix.target }} == linux ]]; then
sudo ldconfig
Expand All @@ -298,17 +312,13 @@ jobs:
case "${{ matrix.build_system }}" in
cmake*)
case "${{matrix.target}}" in
linux)
cmake --install build --prefix /tmp/hashlink
/tmp/hashlink/bin/hl --version
windows)
export PATH=$(pwd)/build/bin:$PATH
;;
darwin)
*)
cmake --install build --prefix /tmp/hashlink
if [ -f /tmp/hashlink/hl ]; then /tmp/hashlink/hl --version; fi
;;
windows)
export PATH=$(pwd)/build/bin:$PATH
;;
esac
cd build && ctest --verbose --build-config ${{ matrix.cmake_configuration }}
;;
Expand All @@ -323,7 +333,8 @@ jobs:
darwin) otool -L ./hl ;;
esac

haxe -hl hello.hl -cp other/tests -main HelloWorld -D interp
haxe -hl hello.hl -cp other/tests -main HelloWorld -D interp \
${{ matrix.architecture == 32 && '-D hl-legacy32' || '' }}
./hl hello.hl

# ensure the executable still works when installed globally
Expand Down Expand Up @@ -355,7 +366,9 @@ jobs:
darwinarm64) platform_name=darwin-arm64 ;;
darwin64) platform_name=darwin ;;
windows*) platform_name=win${{matrix.architecture}} ;;
linux32) platform_name=linux-i386 ;;
linux64) platform_name=linux-amd64 ;;
linuxarm64) platform_name=linux-arm64 ;;
esac

short_commit=$(git rev-parse --short HEAD)
Expand Down Expand Up @@ -449,7 +462,9 @@ jobs:
--title "HashLink Nightly Build" \
"darwin-cmake-64/hashlink-${short_commit}-darwin-cmake.tar.gz#hashlink-latest-darwin.tar.gz" \
"darwin-cmake-arm64/hashlink-${short_commit}-darwin-arm64-cmake.tar.gz#hashlink-latest-darwin-arm64.tar.gz" \
"linux-make-32/hashlink-${short_commit}-linux-i386.tar.gz#hashlink-latest-linux-i386.tar.gz" \
"linux-make-64/hashlink-${short_commit}-linux-amd64.tar.gz#hashlink-latest-linux-amd64.tar.gz" \
"linux-make-arm64/hashlink-${short_commit}-linux-arm64.tar.gz#hashlink-latest-linux-arm64.tar.gz" \
"windows-vs2019-32/hashlink-${short_commit}-win32.zip#hashlink-latest-win32.zip" \
"windows-vs2019-64/hashlink-${short_commit}-win64.zip#hashlink-latest-win64.zip" \
"windows-cmake-mingw-64/hashlink-${short_commit}-win64-cmake-mingw.zip#hashlink-latest-win64-mingw.zip"
17 changes: 5 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,24 +256,20 @@ if(BUILD_TESTING)
haxe
)

if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32")
SET(HAXE_FLAGS -D hl-legacy32)
else()
SET(HAXE_FLAGS )
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
SET(HAXE_HL_FLAGS -D hl-legacy32)
endif()

if(MINGW)
set(HLC_LIBRARIES dbghelp)
else()
set(HLC_LIBRARIES)
endif()

#####################
# hello.hl

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.hl
COMMAND ${HAXE_COMPILER}
${HAXE_FLAGS}
${HAXE_HL_FLAGS}
-hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello.hl
-cp ${CMAKE_SOURCE_DIR}/other/tests -main HelloWorld
)
Expand All @@ -286,7 +282,7 @@ if(BUILD_TESTING)

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/threads.hl
COMMAND ${HAXE_COMPILER}
${HAXE_FLAGS}
${HAXE_HL_FLAGS}
-hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/threads.hl
-cp ${CMAKE_SOURCE_DIR}/other/tests -main Threads
)
Expand All @@ -299,7 +295,7 @@ if(BUILD_TESTING)

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/uvsample.hl
COMMAND ${HAXE_COMPILER}
${HAXE_FLAGS}
${HAXE_HL_FLAGS}
-hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/uvsample.hl
-cp ${CMAKE_SOURCE_DIR}/other/uvsample -main UVSample
)
Expand All @@ -312,7 +308,6 @@ if(BUILD_TESTING)

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello/hello.c
COMMAND ${HAXE_COMPILER}
${HAXE_FLAGS}
-hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/hello/hello.c
-cp ${CMAKE_SOURCE_DIR}/other/tests -main HelloWorld
)
Expand All @@ -336,7 +331,6 @@ if(BUILD_TESTING)

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/threads/threads.c
COMMAND ${HAXE_COMPILER}
${HAXE_FLAGS}
-hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/threads/threads.c
-cp ${CMAKE_SOURCE_DIR}/other/tests -main Threads
)
Expand All @@ -360,7 +354,6 @@ if(BUILD_TESTING)

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/uvsample/uvsample.c
COMMAND ${HAXE_COMPILER}
${HAXE_FLAGS}
-hl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/uvsample/uvsample.c
-cp ${CMAKE_SOURCE_DIR}/other/uvsample -main UVSample
)
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,15 @@ LIBFLAGS += -rpath @executable_path -rpath $(INSTALL_LIB_DIR)
LHL_LINK_FLAGS += -install_name @rpath/libhl.dylib
else

ifeq ($(ARCH),aarch64)
ARCH = arm64
endif

# Linux
CFLAGS += -m$(MARCH) -fPIC -pthread -fno-omit-frame-pointer $(shell pkg-config --cflags sdl2)
ifneq ($(ARCH),arm64)
CFLAGS += -m$(MARCH)
endif
CFLAGS += -fPIC -pthread -fno-omit-frame-pointer $(shell pkg-config --cflags sdl2)
LFLAGS += -lm -Wl,-rpath,.:'$$ORIGIN':$(INSTALL_LIB_DIR) -Wl,--no-undefined

ifeq ($(MARCH),32)
Expand Down Expand Up @@ -258,7 +265,7 @@ src/std/regexp.o: src/std/regexp.c
${CC} ${CFLAGS} -o $@ -c $< ${PCRE_FLAGS}

libhl: ${LIB}
${CC} ${CFLAGS} -o libhl.$(LIBEXT) -m${MARCH} ${LIBFLAGS} ${LHL_LINK_FLAGS} -shared $^ ${LIBHL_LDLIBS}
${CC} ${CFLAGS} -o libhl.$(LIBEXT) ${LIBFLAGS} ${LHL_LINK_FLAGS} -shared $^ ${LIBHL_LDLIBS}

hlc: ${BOOT}
${CC} ${CFLAGS} -o hlc ${BOOT} ${LFLAGS} ${EXTRA_LFLAGS} ${HLC_LDLIBS}
Expand Down
2 changes: 2 additions & 0 deletions other/cmake/linux32.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ set(CMAKE_SYSTEM_VERSION 1)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")

set(CMAKE_SYSTEM_PROCESSOR "i686")
2 changes: 1 addition & 1 deletion src/std/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static void *get_reg( int r ) {
case 1: return &regs->ebp;
case 2: return &regs->eip;
case 10: return &regs->eax;
case 11: return -1;
case 11: return (void*)-1;
# endif
case 3: return &regs->eflags;
default: return &user->u_debugreg[r-4];
Expand Down