Skip to content

Commit

Permalink
[make] Generate haxelib binary with nekotools boot -c on Mac/Linux (#…
Browse files Browse the repository at this point in the history
…11653)

* [make] Generate haxelib binary with `nekotools boot -c` on Mac/Linux

`nekotools boot` is a bit of a hack and some tools that deal with executables on linux can strip away the haxelib bytecode if it is done this way.

`nekotools boot -c` will generate a .c file which can then be compiled manually.

* [make] Fix for unix platforms if PLATFORM is defined

* [make] Set the HAXE_STD_PATH while building haxelib

Otherwise it doesn't work if haxe isn't already installed, or it might use the wrong version of the standard library

* [ci] Install missing neko headers during setup

They are now needed for compiling haxelib

* [ci] Ensure /usr/local/include exists before installing neko

* [ci] Install neko headers for earthly builds as well

* [make] Omit HAXE_STD_PATH when building haxelib on windows

For some reason this environment variable isn't working here on Windows

* [ci] Continue building x64 haxelib on mac arm64 for now

We don't have neko binaries for mac arm64 yet

`nekotools boot run.n` was previously also producing an x64 binary

* [make] Set rpath on mac when building haxelib

It looks like /usr/local/lib is no longer used as a default path in some cases.

* [make] Set std path for haxelib build on windows
  • Loading branch information
tobil4sk authored and kLabz committed Jul 18, 2024
1 parent d1ac29f commit edb46fa
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,11 @@ jobs:
tar -xf $RUNNER_TEMP/neko_latest.tar.gz -C $RUNNER_TEMP
NEKOPATH=`echo $RUNNER_TEMP/neko-*-*`
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/include
sudo mkdir -p /usr/local/lib/neko
sudo ln -s $NEKOPATH/{neko,nekoc,nekoml,nekotools} /usr/local/bin/
sudo ln -s $NEKOPATH/libneko.* /usr/local/lib/
sudo ln -s $NEKOPATH/include/* /usr/local/include/
sudo ln -s $NEKOPATH/*.ndll /usr/local/lib/neko/
echo "NEKOPATH=$NEKOPATH" >> $GITHUB_ENV
Expand Down Expand Up @@ -398,9 +400,11 @@ jobs:
tar -xf $RUNNER_TEMP/neko_latest.tar.gz -C $RUNNER_TEMP
NEKOPATH=`echo $RUNNER_TEMP/neko-*-*`
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/include
sudo mkdir -p /usr/local/lib/neko
sudo ln -s $NEKOPATH/{neko,nekoc,nekoml,nekotools} /usr/local/bin/
sudo ln -s $NEKOPATH/libneko.* /usr/local/lib/
sudo ln -s $NEKOPATH/include/* /usr/local/include/
sudo ln -s $NEKOPATH/*.ndll /usr/local/lib/neko/
echo "NEKOPATH=$NEKOPATH" >> $GITHUB_ENV
Expand Down Expand Up @@ -474,9 +478,11 @@ jobs:
tar -xf $RUNNER_TEMP/neko_latest.tar.gz -C $RUNNER_TEMP
NEKOPATH=`echo $RUNNER_TEMP/neko-*-*`
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/include
sudo mkdir -p /usr/local/lib/neko
sudo ln -s $NEKOPATH/{neko,nekoc,nekoml,nekotools} /usr/local/bin/
sudo ln -s $NEKOPATH/libneko.* /usr/local/lib/
sudo ln -s $NEKOPATH/include/* /usr/local/include/
sudo ln -s $NEKOPATH/*.ndll /usr/local/lib/neko/
echo "NEKOPATH=$NEKOPATH" >> $GITHUB_ENV
Expand Down Expand Up @@ -610,9 +616,11 @@ jobs:
tar -xf $RUNNER_TEMP/neko_latest.tar.gz -C $RUNNER_TEMP
NEKOPATH=`echo $RUNNER_TEMP/neko-*-*`
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/include
sudo mkdir -p /usr/local/lib/neko
sudo ln -s $NEKOPATH/{neko,nekoc,nekoml,nekotools} /usr/local/bin/
sudo ln -s $NEKOPATH/libneko.* /usr/local/lib/
sudo ln -s $NEKOPATH/include/* /usr/local/include/
sudo ln -s $NEKOPATH/*.ndll /usr/local/lib/neko/
echo "NEKOPATH=$NEKOPATH" >> $GITHUB_ENV
Expand Down Expand Up @@ -670,7 +678,7 @@ jobs:
set -ex
eval $(opam env)
opam config exec -- make -s -j`sysctl -n hw.ncpu` STATICLINK=1 "LIB_PARAMS=/usr/local/lib/libz.a /usr/local/lib/libpcre2-8.a /usr/local/lib/libmbedtls.a /usr/local/lib/libmbedcrypto.a /usr/local/lib/libmbedx509.a -cclib '-framework Security -framework CoreFoundation'" haxe
opam config exec -- make -s haxelib
opam config exec -- arch -x86_64 make -s haxelib
make -s package_unix package_installer_mac
ls -l out
otool -L ./haxe
Expand Down Expand Up @@ -949,9 +957,11 @@ jobs:
tar -xf $RUNNER_TEMP/neko_latest.tar.gz -C $RUNNER_TEMP
NEKOPATH=`echo $RUNNER_TEMP/neko-*-*`
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/include
sudo mkdir -p /usr/local/lib/neko
sudo ln -s $NEKOPATH/{neko,nekoc,nekoml,nekotools} /usr/local/bin/
sudo ln -s $NEKOPATH/libneko.* /usr/local/lib/
sudo ln -s $NEKOPATH/include/* /usr/local/include/
sudo ln -s $NEKOPATH/*.ndll /usr/local/lib/neko/
echo "NEKOPATH=$NEKOPATH" >> $GITHUB_ENV
Expand Down
1 change: 1 addition & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ INSTALL_NEKO:
ARG PREFIX=/usr/local
RUN bash -c "ln -s \"$NEKOPATH\"/{neko,nekoc,nekoml,nekotools} \"$PREFIX/bin/\""
RUN bash -c "ln -s \"$NEKOPATH\"/libneko.* \"$PREFIX/lib/\""
RUN bash -c "ln -s \"$NEKOPATH\"/*.h \"$PREFIX/include/\""
RUN mkdir -p "$PREFIX/lib/neko/"
RUN bash -c "ln -s \"$NEKOPATH\"/*.ndll \"$PREFIX/lib/neko/\""
RUN ldconfig
Expand Down
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,24 @@ copy_haxetoolkit: /cygdrive/c/HaxeToolkit/haxe/haxe.exe
cp $< $@
endif

ifeq ($(SYSTEM_NAME),Mac)
# This assumes that haxelib and neko will both be installed into INSTALL_DIR,
# which is the case when installing using the mac installer package
HAXELIB_LFLAGS= -Wl,-rpath,$(INSTALL_DIR)/lib
endif

haxelib_unix:
cd $(CURDIR)/extra/haxelib_src && \
HAXE_STD_PATH=$(CURDIR)/std $(CURDIR)/$(HAXE_OUTPUT) client.hxml && \
nekotools boot -c run.n
$(CC) $(CURDIR)/extra/haxelib_src/run.c -o $(HAXELIB_OUTPUT) -lneko $(HAXELIB_LFLAGS)

# haxelib should depends on haxe, but we don't want to do that...
haxelib:
(cd $(CURDIR)/extra/haxelib_src && $(CURDIR)/$(HAXE_OUTPUT) client.hxml && nekotools boot run.n)
mv extra/haxelib_src/run$(EXTENSION) $(HAXELIB_OUTPUT)
ifeq ($(SYSTEM_NAME),Windows)
haxelib: haxelib_$(PLATFORM)
else
haxelib: haxelib_unix
endif

tools: haxelib

Expand Down
7 changes: 7 additions & 0 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ PACKAGE_FILES=$(HAXE_OUTPUT) $(HAXELIB_OUTPUT) std \
"$$(cygcheck $(CURDIR)/$(HAXE_OUTPUT) | grep libmbedtls.dll | sed -e 's/^\s*//')" \
"$$(cygcheck $(CURDIR)/$(HAXE_OUTPUT) | grep libmbedx509.dll | sed -e 's/^\s*//')"

# haxelib should depends on haxe, but we don't want to do that...
haxelib_win:
cd $(CURDIR)/extra/haxelib_src && \
HAXE_STD_PATH=$$(cygpath -m $(CURDIR)/std) $(CURDIR)/$(HAXE_OUTPUT) client.hxml && \
nekotools boot run.n
mv extra/haxelib_src/run$(EXTENSION) $(HAXELIB_OUTPUT)

echo_package_files:
echo $(PACKAGE_FILES)

Expand Down
2 changes: 1 addition & 1 deletion extra/github-actions/build-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
set -ex
eval $(opam env)
opam config exec -- make -s -j`sysctl -n hw.ncpu` STATICLINK=1 "LIB_PARAMS=/usr/local/lib/libz.a /usr/local/lib/libpcre2-8.a /usr/local/lib/libmbedtls.a /usr/local/lib/libmbedcrypto.a /usr/local/lib/libmbedx509.a -cclib '-framework Security -framework CoreFoundation'" haxe
opam config exec -- make -s haxelib
opam config exec -- arch -x86_64 make -s haxelib
make -s package_unix package_installer_mac
ls -l out
otool -L ./haxe
Expand Down
2 changes: 2 additions & 0 deletions extra/github-actions/install-neko-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
tar -xf $RUNNER_TEMP/neko_latest.tar.gz -C $RUNNER_TEMP
NEKOPATH=`echo $RUNNER_TEMP/neko-*-*`
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/include
sudo mkdir -p /usr/local/lib/neko
sudo ln -s $NEKOPATH/{neko,nekoc,nekoml,nekotools} /usr/local/bin/
sudo ln -s $NEKOPATH/libneko.* /usr/local/lib/
sudo ln -s $NEKOPATH/include/* /usr/local/include/
sudo ln -s $NEKOPATH/*.ndll /usr/local/lib/neko/
echo "NEKOPATH=$NEKOPATH" >> $GITHUB_ENV
Expand Down

0 comments on commit edb46fa

Please sign in to comment.