Skip to content

Commit

Permalink
[make] Compile haxelib binary with hxcpp
Browse files Browse the repository at this point in the history
This avoids the dependency on neko, which means that haxe no longer has
to be packaged with neko as a mandatory dependency.

Haxelib has to be run through interp first in order to install hxcpp.
  • Loading branch information
tobil4sk committed Aug 30, 2024
1 parent 7415e9f commit b0f859f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
35 changes: 19 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,27 @@ 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_SRC_PATH=$(CURDIR)/extra/haxelib_src

HAXELIB_INTERP=HAXE_STD_PATH=$(CURDIR)/std $(CURDIR)/$(HAXE_OUTPUT) \
--cwd $(HAXELIB_SRC_PATH) each.hxml --run haxelib.client.Main

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_SRC_PATH)/haxelib_hxb.zip:
HAXE_STD_PATH=$(CURDIR)/std $(CURDIR)/$(HAXE_OUTPUT) --cwd $(HAXELIB_SRC_PATH) \
each.hxml --interp haxelib.client.Main --hxb haxelib_hxb.zip

HAXELIB_INTERP=HAXE_STD_PATH=$(CURDIR)/std $(CURDIR)/$(HAXE_OUTPUT) \
--hxb-lib $(HAXELIB_SRC_PATH)/haxelib_hxb.zip \
--run haxelib.client.Main

# haxelib should depends on haxe, but we don't want to do that...
ifeq ($(SYSTEM_NAME),Windows)
haxelib: haxelib_$(PLATFORM)
else
haxelib: haxelib_unix
endif
# since haxelib isn't available in PATH yet, we have to pass -D no-compilation and build manually
haxelib: $(HAXELIB_SRC_PATH)/haxelib_hxb.zip
$(HAXELIB_INTERP) config > /dev/null || $(HAXELIB_INTERP) setup ~/.local/share/haxe/lib
$(HAXELIB_INTERP) path hxcpp > /dev/null || $(HAXELIB_INTERP) install hxcpp
HAXE_STD_PATH=$(CURDIR)/std $(CURDIR)/$(HAXE_OUTPUT) --cwd $(HAXELIB_SRC_PATH) \
client_cpp.hxml -D destination=$(CURDIR)/$(HAXELIB_OUTPUT) -D no-compilation
cd $(HAXELIB_SRC_PATH)/bin/cpp && $(HAXELIB_INTERP) run hxcpp Build.xml haxe

tools: haxelib

Expand Down Expand Up @@ -249,7 +252,7 @@ clean_haxe:
rm -f -r _build $(HAXE_OUTPUT) $(PREBUILD_OUTPUT)

clean_tools:
rm -f $(HAXE_OUTPUT) $(PREBUILD_OUTPUT) $(HAXELIB_OUTPUT)
rm -rf $(HAXE_OUTPUT) $(PREBUILD_OUTPUT) $(HAXELIB_OUTPUT) $(HAXELIB_SRC_PATH)/haxelib_hxb.zip $(HAXELIB_SRC_PATH)/bin/cpp

clean_package:
rm -rf $(PACKAGE_OUT_DIR)
Expand Down
7 changes: 0 additions & 7 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ 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

0 comments on commit b0f859f

Please sign in to comment.