Skip to content

Commit

Permalink
Move all prebuild functionality into dune, take 2 (#11983)
Browse files Browse the repository at this point in the history
* Reapply "Move all prebuild functionality into dune. (#11966)"

This reverts commit c85f269.

* Delete dune-workspace.dev and pass --profile release in the Makefile.
  • Loading branch information
Apprentice-Alchemist authored Feb 6, 2025
1 parent c85f269 commit f30a63f
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ jobs:
run: |
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 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\"" haxe
opam config exec -- make -s haxelib
make -s package_unix package_installer_mac
ls -l out
Expand Down
16 changes: 2 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,14 @@ NEKO_VERSION=2.4.0-rc.1
NEKO_MAJOR_VERSION=$(shell echo "$(NEKO_VERSION)" | grep -oE "^[0-9]+")
NEKO_VERSION_TAG=v$(shell echo "$(NEKO_VERSION)" | sed "s/\./-/g")

ifneq ($(STATICLINK),0)
LIB_PARAMS= -cclib '-Wl,-Bstatic -lpcre2-8 -lz -lmbedtls -lmbedx509 -lmbedcrypto -Wl,-Bdynamic '
else
LIB_PARAMS?= -cclib -lpcre2-8 -cclib -lz -cclib -lmbedtls -cclib -lmbedx509 -cclib -lmbedcrypto
endif
ifeq ($(SYSTEM_NAME),Mac)
LIB_PARAMS+= -cclib '-framework Security -framework CoreFoundation'
endif

all: haxe tools

haxe:
$(DUNE_COMMAND) build --workspace dune-workspace.dev src-prebuild/prebuild.exe
_build/default/src-prebuild/prebuild.exe libparams $(LIB_PARAMS) > lib.sexp
_build/default/src-prebuild/prebuild.exe version "$(ADD_REVISION)" "$(BRANCH)" "$(COMMIT_SHA)" > src/compiler/version.ml
$(DUNE_COMMAND) build --workspace dune-workspace.dev src/haxe.exe
dune build --profile release src/haxe.exe
cp -f _build/default/src/haxe.exe ./"$(HAXE_OUTPUT)"

plugin: haxe
$(DUNE_COMMAND) build --workspace dune-workspace.dev plugins/$(PLUGIN)/$(PLUGIN).cmxs
$(DUNE_COMMAND) build --profile release plugins/$(PLUGIN)/$(PLUGIN).cmxs
mkdir -p plugins/$(PLUGIN)/cmxs/$(SYSTEM_NAME)
cp -f _build/default/plugins/$(PLUGIN)/$(PLUGIN).cmxs plugins/$(PLUGIN)/cmxs/$(SYSTEM_NAME)/plugin.cmxs

Expand Down
4 changes: 0 additions & 4 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ ifdef FILTER
CC_CMD=($(COMPILER) $(ALL_CFLAGS) -c $< 2>tmp.cmi && $(FILTER)) || ($(FILTER) && exit 1)
endif

ifeq ($(STATICLINK),0)
LIB_PARAMS = -cclib -lpcre2-8 -cclib -lz -cclib -lcrypt32 -cclib -lmbedtls -cclib -lmbedcrypto -cclib -lmbedx509
endif

PACKAGE_FILES=$(HAXE_OUTPUT) $(HAXELIB_OUTPUT) std \
"$$(cygcheck $(CURDIR)/$(HAXE_OUTPUT) | grep zlib1.dll | sed -e 's/^\s*//')" \
"$$(cygcheck $(CURDIR)/$(HAXE_OUTPUT) | grep libpcre2-8-0.dll | sed -e 's/^\s*//')" \
Expand Down
4 changes: 2 additions & 2 deletions dune
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(dirs :standard \ tests std extra)
(data_only_dirs lib)
(dirs src libs)
(data_only_dirs src-json)
4 changes: 0 additions & 4 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@
(package
(name haxe)
)

(package
(name haxe_prebuild)
)
2 changes: 0 additions & 2 deletions dune-workspace.dev

This file was deleted.

2 changes: 1 addition & 1 deletion extra/github-actions/build-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
run: |
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 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\"" haxe
opam config exec -- make -s haxelib
make -s package_unix package_installer_mac
ls -l out
Expand Down
14 changes: 0 additions & 14 deletions src-prebuild/dune

This file was deleted.

5 changes: 5 additions & 0 deletions src/compiler/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(rule
(deps (env_var ADD_REVISION))
(targets version.ml)
(action (with-stdout-to version.ml (run ../prebuild.exe version)))
)
6 changes: 3 additions & 3 deletions src/core/dune
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
(rule
(targets metaList.ml)
(deps ../../src-json/meta.json)
(action (with-stdout-to metaList.ml (run %{bin:haxe_prebuild} meta ../../src-json/meta.json)))
(action (with-stdout-to metaList.ml (run ../prebuild.exe meta ../../src-json/meta.json)))
)

(rule
(targets defineList.ml)
(deps ../../src-json/define.json)
(action (with-stdout-to defineList.ml (run %{bin:haxe_prebuild} define ../../src-json/define.json)))
(action (with-stdout-to defineList.ml (run ../prebuild.exe define ../../src-json/define.json)))
)

(rule
(targets warningList.ml)
(deps ../../src-json/warning.json)
(action (with-stdout-to warningList.ml (run %{bin:haxe_prebuild} warning ../../src-json/warning.json)))
(action (with-stdout-to warningList.ml (run ../prebuild.exe warning ../../src-json/warning.json)))
)
16 changes: 14 additions & 2 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,33 @@
xml-light extlib sha terminal_size
luv
)
(modules (:standard \ haxe))
(modules (:standard \ haxe prebuild))
(preprocess (per_module
((pps sedlex.ppx) json lexer)
((pps ppx_parser) grammar)
))
(wrapped false)
)

(executable
(name prebuild)
(libraries extlib json unix)
(modules prebuild)
)

(rule
(deps (env_var STATICLINK) (env_var LIB_PARAMS))
(targets libs.sexp)
(action (with-stdout-to libs.sexp (run ./prebuild.exe libparams %{system})))
)

(executable
(name haxe)
(public_name haxe)
(package haxe)
(libraries haxe)
(modules haxe)
(link_flags (:include ../lib.sexp))
(link_flags (:include libs.sexp))
; Uncomment to enable bytecode output for ocamldebug support
; (modes byte)
)
26 changes: 21 additions & 5 deletions src-prebuild/prebuild.ml → src/prebuild.ml
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,29 @@ match Array.to_list (Sys.argv) with
print_endline "";
print_endline "let from_string = function";
print_endline (gen_warning_parse warnings);
| _ :: "libparams" :: params ->
Printf.printf "(%s)" (String.concat " " (List.map (fun s -> Printf.sprintf "\"%s\"" s) params))
| [_ ;"version";add_revision;branch;sha] ->
begin match add_revision with
| "0" | "" ->
| [_; "libparams"; os] ->
Printf.printf "(";
(begin match Sys.getenv_opt "LIB_PARAMS" with
| Some params ->
Printf.printf "%s" params;
| None ->
if Sys.win32 then
Printf.printf "-cclib -lpcre2-8 -cclib -lz -cclib -lcrypt32 -cclib -lmbedtls -cclib -lmbedcrypto -cclib -lmbedx509"
else
if Option.is_some (Sys.getenv_opt "STATICLINK") && os <> "macosx" then
Printf.printf "-cclib \"-Wl,-Bstatic -lpcre2-8 -lz -lmbedtls -lmbedx509 -lmbedcrypto -Wl,-Bdynamic \""
else
Printf.printf "-cclib -lpcre2-8 -cclib -lz -cclib -lmbedtls -cclib -lmbedx509 -cclib -lmbedcrypto";
end);
if os = "macosx" then Printf.printf " -cclib \"-framework Security -framework CoreFoundation\"";
Printf.printf ")";
| [_ ;"version";] ->
begin match Sys.getenv_opt "ADD_REVISION" with
| Some "0" | Some "" | None ->
print_endline "let version_extra = None"
| _ ->
let branch = Stdlib.input_line (Unix.open_process_in "git rev-parse --abbrev-ref HEAD") in
let sha = Stdlib.input_line (Unix.open_process_in "git rev-parse --short HEAD") in
Printf.printf "let version_extra = Some (\"git build %s\",\"%s\")" branch sha
end
| args ->
Expand Down

0 comments on commit f30a63f

Please sign in to comment.