Explorar o código

Move all prebuild functionality into dune, take 2 (#11983)

* Reapply "Move all prebuild functionality into dune. (#11966)"

This reverts commit c85f26957a8318474314cf9d640867cf788fce6a.

* Delete dune-workspace.dev and pass --profile release in the Makefile.
Zeta hai 5 meses
pai
achega
f30a63f9d6
Modificáronse 12 ficheiros con 49 adicións e 52 borrados
  1. 1 1
      .github/workflows/main.yml
  2. 2 14
      Makefile
  3. 0 4
      Makefile.win
  4. 2 2
      dune
  5. 0 4
      dune-project
  6. 0 2
      dune-workspace.dev
  7. 1 1
      extra/github-actions/build-mac.yml
  8. 0 14
      src-prebuild/dune
  9. 5 0
      src/compiler/dune
  10. 3 3
      src/core/dune
  11. 14 2
      src/dune
  12. 21 5
      src/prebuild.ml

+ 1 - 1
.github/workflows/main.yml

@@ -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

+ 2 - 14
Makefile

@@ -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
 

+ 0 - 4
Makefile.win

@@ -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*//')" \

+ 2 - 2
dune

@@ -1,2 +1,2 @@
-(dirs :standard \ tests std extra)
-(data_only_dirs lib)
+(dirs src libs)
+(data_only_dirs src-json)

+ 0 - 4
dune-project

@@ -4,7 +4,3 @@
 (package
 	(name haxe)
 )
-
-(package
-	(name haxe_prebuild)
-)

+ 0 - 2
dune-workspace.dev

@@ -1,2 +0,0 @@
-(lang dune 1.11)
-(profile release)

+ 1 - 1
extra/github-actions/build-mac.yml

@@ -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

+ 0 - 14
src-prebuild/dune

@@ -1,14 +0,0 @@
-(include_subdirs no)
-
-(env
-	(_
-		(flags (-w -9 -w -32))
-	)
-)
-
-(executable
-	(name prebuild)
-	(public_name haxe_prebuild)
-	(package haxe_prebuild)
-	(libraries extlib json)
-)

+ 5 - 0
src/compiler/dune

@@ -0,0 +1,5 @@
+(rule
+	(deps (env_var ADD_REVISION))
+	(targets version.ml)
+	(action (with-stdout-to version.ml (run ../prebuild.exe version)))
+)

+ 3 - 3
src/core/dune

@@ -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)))
 )

+ 14 - 2
src/dune

@@ -23,7 +23,7 @@
 		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)
@@ -31,13 +31,25 @@
 	(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)
 )

+ 21 - 5
src-prebuild/prebuild.ml → src/prebuild.ml

@@ -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 ->