Skip to content

Commit 1fe3751

Browse files
committed
quote bsc bsdep
1 parent eb04be5 commit 1fe3751

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

jscomp/bsb/bsb_ninja_gen.ml

+7-5
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ let output_ninja_and_namespace_map
140140
~has_builtin:(built_in_dependency <> None)
141141
~bs_suffix
142142
generators in
143-
let bsc = bsc_dir // bsc_exe in (* The path to [bsc.exe] independent of config *)
144-
let bsdep = bsc_dir // bsb_helper_exe in (* The path to [bsb_heler.exe] *)
143+
144+
145145
let cwd_lib_bs = cwd // Bsb_config.lib_bs in
146146
let ppx_flags = Bsb_build_util.ppx_flags ppx_files in
147147
let refmt_flags = String.concat Ext_string.single_space refmt_flags in
@@ -169,7 +169,7 @@ let output_ninja_and_namespace_map
169169
);
170170
Ext_option.iter built_in_dependency (fun x ->
171171
Bsb_ninja_util.output_kv Bsb_ninja_global_vars.g_stdlib_incl
172-
(Filename.quote x.package_install_path) oc
172+
(Ext_filename.maybe_quote x.package_install_path) oc
173173
)
174174
;
175175
(*
@@ -187,8 +187,10 @@ let output_ninja_and_namespace_map
187187
[|
188188
Bsb_ninja_global_vars.g_pkg_flg, g_pkg_flg ;
189189
Bsb_ninja_global_vars.src_root_dir, cwd (* TODO: need check its integrity -- allow relocate or not? *);
190-
Bsb_ninja_global_vars.bsc, bsc ;
191-
Bsb_ninja_global_vars.bsdep, bsdep;
190+
(* The path to [bsc.exe] independent of config *)
191+
Bsb_ninja_global_vars.bsc, (Ext_filename.maybe_quote (bsc_dir // bsc_exe));
192+
(* The path to [bsb_heler.exe] *)
193+
Bsb_ninja_global_vars.bsdep, (Ext_filename.maybe_quote (bsc_dir // bsb_helper_exe)) ;
192194
Bsb_ninja_global_vars.warnings, Bsb_warning.opt_warning_to_string not_dev warning ;
193195
Bsb_ninja_global_vars.bsc_flags, (get_bsc_flags not_dev bsc_flags) ;
194196
Bsb_ninja_global_vars.ppx_flags, ppx_flags;

jscomp/ext/ext_filename.ml

+15-1
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,18 @@ let simple_convert_node_path_to_os_path =
6767
Ext_string.replace_slash_backward
6868
else failwith ("Unknown OS : " ^ Sys.os_type)
6969

70-
70+
(* reference ninja.cc IsKnownShellSafeCharacter *)
71+
let maybe_quote ( s : string) =
72+
let noneed_quote =
73+
Ext_string.for_all s (function
74+
| '0' .. '9'
75+
| 'a' .. 'z'
76+
| 'A' .. 'Z'
77+
| '_' | '+'
78+
| '-' | '.'
79+
| '/' -> true
80+
| _ -> false
81+
) in
82+
if noneed_quote then
83+
s
84+
else Filename.quote s

jscomp/ext/ext_filename.mli

+3
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ val package_dir : string Lazy.t
5555

5656
val simple_convert_node_path_to_os_path : string -> string
5757

58+
val maybe_quote:
59+
string ->
60+
string

0 commit comments

Comments
 (0)