Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix staged pps on Windows #10869

Merged
merged 12 commits into from
Sep 5, 2024
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)
12 changes: 11 additions & 1 deletion otherlibs/stdune/src/string.ml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,17 @@ 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 concat ~sep:"\\" (split_on_char ~sep:'/' prog)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use String.map directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

else prog
in
prog :: List.map ~f:quote_for_shell args |> concat ~sep:" "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prog is no longer quoted_for_shell. Is it expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is wrong: fixed in 4d27a90

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

;;

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
Loading