haxe
haxe copied to clipboard
Adds a new `--std-path` argument to set standard library path.
This PR adds an --std-path argument to set standard library path as an alternative to setting the HAXE_STD_PATH environment variable.
This is useful to be able to use Haxe from the ninja build system, as it does not support setting environment variables from its build scripts: https://github.com/ninja-build/ninja/issues/1002
I have also read that I might need to set HAXELIB_PATH and HAXEPATH to get haxelib working. I quickly checked the source code and the compiler does seem to invoke haxelib in some places, so would it be acceptable to add more flags for those paths? Or is there a better mechanism that could be used as an alternative?
Also this is my first using OCaml and hacking on the compiler to let me know of any issues with the code.
Ok, I think some weirdness is happening with the CI.
The Build Haxe build step is green and reported as passing, but its actually failing:
File "src/optimization/dce.ml", line 90, characters 13-48:
90 | List.exists (ExtString.String.starts_with file) dce.std_dirs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type prefix:string -> bool
but an expression was expected of type 'a -> bool
make: *** [Makefile:81: haxe] Error 1
... and its failing with the error that my other PR fixes: https://github.com/HaxeFoundation/haxe/pull/11779
Some quick search shows that it may need $ErrorActionPreference = 'Stop' there to stop if any command fails.
Two things:
-
We try to avoid magic values like
"", so it's better to declarecom.std_pathasstring optionand then do(match com.std_path with None -> (* the "" case *) | Some std_path -> (* the other case *)). -
This hooks into
get_std_class_paths, which is called viasetup_common_context, which is called beforeparse_args(seecompile_ctxin compiler.ml). Unless I'm misreading something here I can't see how this implementation actually works timing-wise becausecom.std_pathis set only after it's relevant.
This was never updated.