Skip to content

Commit

Permalink
Fix staged pps on Windows (ocaml#10869)
Browse files Browse the repository at this point in the history
* Use backslashes when passing staged pps driver on Windows

Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
  • Loading branch information
nojb authored and anmonteiro committed Nov 17, 2024
1 parent 88992ca commit 61ee6bc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doc/changes/10869.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix staged pps preprocessors on Windows (which were not working at all
previously) (#10869, @nojb)
17 changes: 16 additions & 1 deletion otherlibs/stdune/src/string.ml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,22 @@ let need_quoting s =
;;

let quote_for_shell s = if need_quoting s then Stdlib.Filename.quote s else s
let quote_list_for_shell l = List.map l ~f:quote_for_shell |> concat ~sep:" "

let quote_list_for_shell = function
| [] -> ""
| prog :: args ->
let prog =
if Sys.win32 && contains prog '/'
then
map
~f:(function
| '/' -> '\\'
| c -> c)
prog
else prog
in
quote_for_shell prog :: List.map ~f:quote_for_shell args |> concat ~sep:" "
;;

let of_list chars =
let s = Bytes.make (List.length chars) '0' in
Expand Down
4 changes: 2 additions & 2 deletions otherlibs/stdune/src/string.mli
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ val need_quoting : string -> bool
[true] *)
val quote_for_shell : string -> string

(** [quote_list_for_shell l] is
[List.map l ~f:quote_for_shell |> concat ~sep:" "] *)
(** [quote_list_for_shell l] quotes a command-line so that it can be passed to
the system shell (eg by using [Sys.command]). *)
val quote_list_for_shell : string list -> string

val filter_map : string -> f:(char -> char option) -> string
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/dune
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(alias runtest-js)))

(cram
(applies_to windows-diff)
(applies_to windows-diff github6644)
(alias runtest-windows))

; DISABLED TESTS
Expand Down

0 comments on commit 61ee6bc

Please sign in to comment.