Skip to content

Commit

Permalink
Merge branch 'development' into cpp_typed_funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan63 committed Mar 6, 2025
2 parents d9e0cfa + 98b4326 commit ef6fe96
Show file tree
Hide file tree
Showing 88 changed files with 1,301 additions and 309 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:


linux-build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
PLATFORM: linux64
OPAMYES: 1
Expand All @@ -123,7 +123,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.opam/
key: ${{ runner.os }}-${{ matrix.ocaml }}-${{ hashFiles('./haxe.opam', './libs/') }}
key: ${{ runner.os }}-${{ matrix.ocaml }}-${{ hashFiles('./haxe.opam', './libs/') }}-1

- name: Install Neko from S3
run: |
Expand All @@ -148,10 +148,10 @@ jobs:
- name: Install dependencies
run: |
set -ex
sudo add-apt-repository ppa:avsm/ppa -y # provides OPAM 2
sudo add-apt-repository ppa:haxe/ocaml -y # provides newer version of mbedtls
sudo apt-get update -qqy
sudo apt-get install -qqy ocaml-nox opam libpcre2-dev zlib1g-dev libgtk2.0-dev libmbedtls-dev ninja-build
sudo apt-get install -qqy darcs bubblewrap ocaml-nox libpcre2-dev zlib1g-dev libgtk2.0-dev libmbedtls-dev ninja-build
curl -sSL https://github.com/ocaml/opam/releases/download/2.3.0/opam-2.3.0-x86_64-linux -o $RUNNER_TEMP/opam
sudo install $RUNNER_TEMP/opam /usr/local/bin/opam
- name: Install OCaml libraries
if: steps.cache-opam.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -213,7 +213,7 @@ jobs:

linux-test:
needs: linux-build
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
PLATFORM: linux64
TEST: ${{matrix.target}}
Expand Down Expand Up @@ -300,7 +300,7 @@ jobs:

test-docgen:
needs: linux-build
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
PLATFORM: linux64
HXCPP_COMPILE_CACHE: ~/hxcache
Expand Down Expand Up @@ -854,7 +854,7 @@ jobs:
deploy:
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
needs: [linux-test, linux-arm64-test, mac-test, windows64-test]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
# this is only needed for to get `COMMIT_DATE`...
# maybe https://github.community/t/expose-commit-timestamp-in-the-github-context-data/16460/3
Expand Down Expand Up @@ -924,7 +924,7 @@ jobs:
deploy_apidoc:
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
needs: [linux-test, linux-arm64-test, mac-test, windows64-test]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Install dependencies
run: |
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ NEKO_VERSION_TAG=v$(shell echo "$(NEKO_VERSION)" | sed "s/\./-/g")
all: haxe tools

haxe:
dune build --profile release src/haxe.exe
cp -f _build/default/src/haxe.exe ./"$(HAXE_OUTPUT)"
dune build --profile release

plugin: haxe
$(DUNE_COMMAND) build --profile release plugins/$(PLUGIN)/$(PLUGIN).cmxs
Expand Down Expand Up @@ -234,7 +233,7 @@ package_installer_mac: $(INSTALLER_TMP_DIR)/neko-osx.tar.gz package_unix
clean: clean_haxe clean_tools clean_package

clean_haxe:
rm -f -r _build $(HAXE_OUTPUT) $(PREBUILD_OUTPUT)
dune clean

clean_tools:
rm -f $(HAXE_OUTPUT) $(PREBUILD_OUTPUT) $(HAXELIB_OUTPUT)
Expand Down
6 changes: 6 additions & 0 deletions WinSetup.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Usage:
# - install Git
# - install Neko
# - checkout haxe git
# - run from command "powershell -noexit -ExecutionPolicy Bypass -File .\WinSetup.ps1"

function Cmd-Path($file) {
try { Split-Path -Parent (Get-Command "$file.exe" -ErrorAction Stop).Source } catch { "" }
}
Expand Down
7 changes: 7 additions & 0 deletions dune
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
(dirs src libs)
(data_only_dirs src-json)

(rule
(action
(copy src/haxe.exe haxe%{ext_exe}))
(mode
(promote (until-clean)))
(alias default))
18 changes: 9 additions & 9 deletions extra/github-actions/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
@import build-windows.yml

linux-build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
PLATFORM: linux64
OPAMYES: 1
Expand All @@ -42,17 +42,17 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.opam/
key: ${{ runner.os }}-${{ matrix.ocaml }}-${{ hashFiles('./haxe.opam', './libs/') }}
key: ${{ runner.os }}-${{ matrix.ocaml }}-${{ hashFiles('./haxe.opam', './libs/') }}-1

@import install-neko-unix.yml

- name: Install dependencies
run: |
set -ex
sudo add-apt-repository ppa:avsm/ppa -y # provides OPAM 2
sudo add-apt-repository ppa:haxe/ocaml -y # provides newer version of mbedtls
sudo apt-get update -qqy
sudo apt-get install -qqy ocaml-nox opam libpcre2-dev zlib1g-dev libgtk2.0-dev libmbedtls-dev ninja-build
sudo apt-get install -qqy darcs bubblewrap ocaml-nox libpcre2-dev zlib1g-dev libgtk2.0-dev libmbedtls-dev ninja-build
curl -sSL https://github.com/ocaml/opam/releases/download/2.3.0/opam-2.3.0-x86_64-linux -o $RUNNER_TEMP/opam
sudo install $RUNNER_TEMP/opam /usr/local/bin/opam
- name: Install OCaml libraries
if: steps.cache-opam.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:

linux-test:
needs: linux-build
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
PLATFORM: linux64
TEST: ${{matrix.target}}
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:

test-docgen:
needs: linux-build
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
PLATFORM: linux64
HXCPP_COMPILE_CACHE: ~/hxcache
Expand Down Expand Up @@ -478,7 +478,7 @@ jobs:
deploy:
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
needs: [linux-test, linux-arm64-test, mac-test, windows64-test]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
# this is only needed for to get `COMMIT_DATE`...
# maybe https://github.community/t/expose-commit-timestamp-in-the-github-context-data/16460/3
Expand Down Expand Up @@ -548,7 +548,7 @@ jobs:
deploy_apidoc:
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
needs: [linux-test, linux-arm64-test, mac-test, windows64-test]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Install dependencies
run: |
Expand Down
6 changes: 4 additions & 2 deletions src-json/define.json
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@
{
"name": "NoDeprecationWarnings",
"define": "no-deprecation-warnings",
"doc": "Do not warn if fields annotated with `@:deprecated` are used."
"doc": "Do not warn if fields annotated with `@:deprecated` are used.",
"deprecated": "Use -w to configure warnings. See https://haxe.org/manual/cr-warnings.html for more information."
},
{
"name": "NoFlashOverride",
Expand Down Expand Up @@ -791,7 +792,8 @@
{
"name": "WarnVarShadowing",
"define": "warn-var-shadowing",
"doc": "Warn about shadowing variable declarations."
"doc": "Warn about shadowing variable declarations.",
"deprecated": "Use -w to configure warnings. See https://haxe.org/manual/cr-warnings.html for more information."
},
{
"name": "NoTre",
Expand Down
3 changes: 2 additions & 1 deletion src-json/warning.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
{
"name": "WVarShadow",
"doc": "A local variable hides another by using the same name",
"parent": "WTyper"
"parent": "WTyper",
"enabled": false
},
{
"name": "WExternWithExpr",
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/args.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let process_args arg_spec =
let parse_args com =
let usage = Printf.sprintf
"Haxe Compiler %s - (C)2005-2024 Haxe Foundation\nUsage: haxe%s <target> [options] [hxml files and dot paths...]\n"
s_version_full (if Sys.os_type = "Win32" then ".exe" else "")
(s_version_full com.version) (if Sys.os_type = "Win32" then ".exe" else "")
in
let actx = {
classes = [([],"Std")];
Expand Down Expand Up @@ -154,7 +154,7 @@ let parse_args com =
com.debug <- true;
),"","add debug information to the compiled code");
("Miscellaneous",["--version"],["-version"],Arg.Unit (fun() ->
raise (Helper.HelpMessage s_version_full);
raise (Helper.HelpMessage (s_version_full com.version));
),"","print version and exit");
("Miscellaneous", ["-h";"--help"], ["-help"], Arg.Unit (fun () ->
raise (Arg.Help "")
Expand Down
18 changes: 15 additions & 3 deletions src/compiler/compilationCache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,27 @@ class cache = object(self)
) cc#get_modules acc
) contexts []

method taint_module m_path reason =
Hashtbl.iter (fun _ cc ->
Hashtbl.iter (fun _ m ->
if m.m_path = m_path then m.m_extra.m_cache_state <- MSBad (Tainted reason)
) cc#get_modules;
Hashtbl.iter (fun _ mc ->
if mc.HxbData.mc_path = m_path then
mc.HxbData.mc_extra.m_cache_state <- match reason, mc.mc_extra.m_cache_state with
| CheckDisplayFile, (MSBad _ as state) -> state
| _ -> MSBad (Tainted reason)
) cc#get_hxb
) contexts

method taint_modules file_key reason =
Hashtbl.iter (fun _ cc ->
Hashtbl.iter (fun _ m ->
if Path.UniqueKey.lazy_key m.m_extra.m_file = file_key then m.m_extra.m_cache_state <- MSBad (Tainted reason)
) cc#get_modules;
let open HxbData in
Hashtbl.iter (fun _ mc ->
if Path.UniqueKey.lazy_key mc.mc_extra.m_file = file_key then
mc.mc_extra.m_cache_state <- match reason, mc.mc_extra.m_cache_state with
if Path.UniqueKey.lazy_key mc.HxbData.mc_extra.m_file = file_key then
mc.HxbData.mc_extra.m_cache_state <- match reason, mc.HxbData.mc_extra.m_cache_state with
| CheckDisplayFile, (MSBad _ as state) -> state
| _ -> MSBad (Tainted reason)
) cc#get_hxb
Expand Down
27 changes: 24 additions & 3 deletions src/compiler/compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ module Setup = struct
let setup_common_context ctx =
let com = ctx.com in
ctx.com.print <- ctx.comm.write_out;
Common.define_value com Define.HaxeVer (Printf.sprintf "%.3f" (float_of_int Globals.version /. 1000.));
Common.define_value com Define.HaxeVer (Printf.sprintf "%.3f" (float_of_int version /. 1000.));
Common.raw_define com "haxe3";
Common.raw_define com "haxe4";
Common.raw_define com "haxe5";
Expand Down Expand Up @@ -296,6 +296,7 @@ let do_type ctx mctx actx display_file_dot_path =
Some (MacroContext.call_init_macro ctx.com mctx path)
) mctx (List.rev actx.config_macros) in
enter_stage com CInitMacrosDone;
update_platform_config com; (* make sure to adapt all flags changes defined during init macros *)
ServerMessage.compiler_stage com;

let macros = match mctx with None -> None | Some mctx -> mctx.g.macros in
Expand All @@ -309,7 +310,10 @@ let do_type ctx mctx actx display_file_dot_path =
com.callbacks#run com.error_ext com.callbacks#get_after_init_macros;
run_or_diagnose ctx (fun () ->
if com.display.dms_kind <> DMNone then DisplayTexpr.check_display_file tctx cs;
List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos)) (List.rev actx.classes);
List.iter (fun cpath ->
ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos);
Typecore.flush_pass tctx.g PBuildClass "actx.classes"
) (List.rev actx.classes);
Finalization.finalize tctx;
);
end with TypeloadParse.DisplayInMacroBlock ->
Expand Down Expand Up @@ -418,6 +422,10 @@ let compile ctx actx callbacks =
) (List.rev actx.cmds)
end

let make_ice_message com msg backtrace =
let ver = (s_version_full com.version) in
let os_type = if Sys.unix then "unix" else "windows" in
Printf.sprintf "%s\nHaxe: %s; OS type: %s;\n%s" msg ver os_type backtrace
let compile_safe ctx f =
let com = ctx.com in
try
Expand Down Expand Up @@ -445,6 +453,12 @@ with
handle_diagnostics ctx msg null_pos DKCompilerMessage;
| Failure msg when not Helper.is_debug_run ->
error ctx ("Error: " ^ msg) null_pos
| Globals.Ice (msg,backtrace) when is_diagnostics com ->
let s = make_ice_message com msg backtrace in
handle_diagnostics ctx s null_pos DKCompilerMessage
| Globals.Ice (msg,backtrace) when not Helper.is_debug_run ->
let s = make_ice_message com msg backtrace in
error ctx ("Error: " ^ s) null_pos
| Helper.HelpMessage msg ->
print_endline msg
| Parser.TypePath (p,c,is_import,pos) ->
Expand Down Expand Up @@ -516,7 +530,14 @@ let compile_ctx callbacks ctx =
catch_completion_and_exit ctx callbacks run

let create_context comm cs compilation_step params = {
com = Common.create compilation_step cs version params (DisplayTypes.DisplayMode.create !Parser.display_mode);
com = Common.create compilation_step cs {
version = version;
major = version_major;
minor = version_minor;
revision = version_revision;
pre = version_pre;
extra = Version.version_extra;
} params (DisplayTypes.DisplayMode.create !Parser.display_mode);
messages = [];
has_next = false;
has_error = false;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(rule
(deps (env_var ADD_REVISION))
(deps (env_var ADD_REVISION) (universe))
(targets version.ml)
(action (with-stdout-to version.ml (run ../prebuild.exe version)))
)
4 changes: 2 additions & 2 deletions src/compiler/hxb/hxbReader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,7 @@ class hxb_reader
a.a_read <- self#read_option (fun () -> self#read_field_ref);
a.a_write <- self#read_option (fun () -> self#read_field_ref);
a.a_call <- self#read_option (fun () -> self#read_field_ref);
a.a_constructor <- self#read_option (fun () -> self#read_field_ref);

a.a_ops <- self#read_list (fun () ->
let i = read_byte ch in
Expand Down Expand Up @@ -2078,8 +2079,7 @@ class hxb_reader
^ "Attach the following information:"
in
let backtrace = Printexc.raw_backtrace_to_string backtrace in
let s = Printf.sprintf "%s\nHaxe: %s\n%s" msg s_version_full backtrace in
failwith s
raise (Globals.Ice (msg, backtrace))

method private read_chunk_data kind =
let path = String.concat "_" (ExtLib.String.nsplit (s_type_path mpath) ".") in
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/hxb/hxbWriter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,7 @@ module HxbWriter = struct
^ "Attach the following information:"
in
let backtrace = Printexc.raw_backtrace_to_string backtrace in
let s = Printf.sprintf "%s\nHaxe: %s\n%s" msg s_version_full backtrace in
failwith s
raise (Globals.Ice (msg, backtrace))

let in_nested_scope writer = match writer.field_stack with
| [] -> false (* can happen for cl_init and in EXD *)
Expand Down Expand Up @@ -1918,6 +1917,7 @@ module HxbWriter = struct
Chunk.write_option writer.chunk a.a_read (write_field_ref writer c CfrStatic );
Chunk.write_option writer.chunk a.a_write (write_field_ref writer c CfrStatic);
Chunk.write_option writer.chunk a.a_call (write_field_ref writer c CfrStatic);
Chunk.write_option writer.chunk a.a_constructor (write_field_ref writer c CfrStatic);

Chunk.write_list writer.chunk a.a_ops (fun (op, cf) ->
Chunk.write_u8 writer.chunk (binop_index op);
Expand Down
4 changes: 2 additions & 2 deletions src/context/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ type context = {
is_macro_context : bool;
mutable json_out : json_api option;
(* config *)
version : int;
version : compiler_version;
mutable args : string list;
mutable display : DisplayTypes.DisplayMode.settings;
mutable debug : bool;
Expand Down Expand Up @@ -968,7 +968,7 @@ let init_platform com =
end;
(* Set the source header, unless the user has set one already or the platform sets a custom one *)
if not (defined com Define.SourceHeader) && (com.platform <> Hl) then
define_value com Define.SourceHeader ("Generated by Haxe " ^ s_version_full);
define_value com Define.SourceHeader ("Generated by Haxe " ^ (s_version_full com.version));
let forbid acc p = if p = name || PMap.mem p acc then acc else PMap.add p Forbidden acc in
com.package_rules <- List.fold_left forbid com.package_rules ("java" :: (List.map platform_name platforms));
update_platform_config com;
Expand Down
Loading

0 comments on commit ef6fe96

Please sign in to comment.