Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[make] Compile haxelib binary with hxcpp #11755

Open
wants to merge 8 commits into
base: development
Choose a base branch
from
Open
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
37 changes: 21 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,29 @@ 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
HAXE_STD_PATH=$(CURDIR)/std
HAXELIB_SRC_PATH=extra/haxelib_src

$(HAXELIB_SRC_PATH)/haxelib_hxb.zip:
HAXE_STD_PATH=$(HAXE_STD_PATH) ./$(HAXE_OUTPUT) --cwd $(HAXELIB_SRC_PATH) \
each.hxml --interp haxelib.client.Main --hxb haxelib_hxb.zip

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_INTERP=HAXE_STD_PATH=./std ./$(HAXE_OUTPUT) \
--hxb-lib $(HAXELIB_SRC_PATH)/haxelib_hxb.zip --run haxelib.client.Main

haxelib_hxcpp: $(HAXELIB_SRC_PATH)/haxelib_hxb.zip
$(HAXELIB_INTERP) config > /dev/null || $(HAXELIB_INTERP) newrepo
$(HAXELIB_INTERP) path hxcpp > /dev/null || \
($(HAXELIB_INTERP) git hxcpp https://github.com/HaxeFoundation/hxcpp.git && \
hxcpp_path=`$(HAXELIB_INTERP) libpath hxcpp | tr -d '\r'` && \
./$(HAXE_OUTPUT) --cwd $$hxcpp_path/tools/hxcpp compile.hxml)

# 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_hxcpp
HAXE_STD_PATH=$(HAXE_STD_PATH) ./$(HAXE_OUTPUT) --cwd $(HAXELIB_SRC_PATH) \
client_cpp.hxml -D destination=../../../../$(HAXELIB_OUTPUT) -D no-compilation
$(HAXELIB_INTERP) --cwd $(HAXELIB_SRC_PATH)/bin/cpp run hxcpp Build.xml haxe

tools: haxelib

Expand Down Expand Up @@ -249,7 +254,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
8 changes: 1 addition & 7 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ MAKEFILENAME=Makefile.win
include Makefile
HAXE_OUTPUT=haxe.exe
HAXELIB_OUTPUT=haxelib.exe
HAXE_STD_PATH=$(shell cygpath -m "$(CURDIR)/std")
PREBUILD_OUTPUT=prebuild.exe
EXTENSION=.exe
PACKAGE_SRC_EXTENSION=.zip
Expand Down Expand Up @@ -53,13 +54,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
10 changes: 6 additions & 4 deletions src/generators/gencpp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7050,10 +7050,12 @@ let write_build_options common_ctx filename defines =
PMap.iter ( fun name value -> match name with
| "true" | "sys" | "dce" | "cpp" | "debug" -> ()
| _ -> write_define name (escape_command value)) defines;
let pin,pid = Process_helper.open_process_args_in_pid "haxelib" [|"haxelib"; "path"; "hxcpp"|] in
set_binary_mode_in pin false;
write_define "hxcpp" (Stdlib.input_line pin);
Stdlib.ignore (Process_helper.close_process_in_pid (pin,pid));
if not (PMap.exists "no_compilation" defines) then begin
let pin,pid = Process_helper.open_process_args_in_pid "haxelib" [|"haxelib"; "path"; "hxcpp"|] in
set_binary_mode_in pin false;
write_define "hxcpp" (Stdlib.input_line pin);
Stdlib.ignore (Process_helper.close_process_in_pid (pin,pid));
end;
writer#close;;

let create_member_types common_ctx =
Expand Down
Loading