diff --git a/bin/main.ml b/bin/main.ml index cae9be5d..8cf16934 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -630,7 +630,7 @@ let target_hint (setup : Main.setup) path = (* Only suggest hints for the basename, otherwise it's slow when there are lots of files *) List.filter_map candidates ~f:(fun path -> - if Path.parent_exn path = sub_dir then + if Path.equal (Path.parent_exn path) sub_dir then Some (Path.to_string path) else None) diff --git a/src/build_system.ml b/src/build_system.ml index 6f3e924e..b8fa87d7 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -431,7 +431,7 @@ let get_dir_status t ~dir = Path.Table.find_or_add t.dirs dir ~f:(fun _ -> if Path.is_in_source_tree dir then Dir_status.Loaded (File_tree.files_of t.file_tree dir) - else if dir = Path.build_dir then + else if Path.equal dir Path.build_dir then (* Not allowed to look here *) Dir_status.Loaded Path.Set.empty else if not (Path.is_managed dir) then @@ -901,7 +901,7 @@ and load_dir_and_get_targets t ~dir = | [] -> assert false | x :: l -> t.load_dir_stack <- l; - assert (x = dir))); + assert (Path.equal x dir))); Path.Table.replace t.dirs ~key:dir ~data:Failed_to_load; reraise exn @@ -1095,7 +1095,7 @@ The following targets are not: | [] -> assert false | x :: l -> t.load_dir_stack <- l; - assert (x = dir)); + assert (Path.equal x dir)); (* Compile the rules and cleanup stale artifacts *) List.iter rules ~f:(compile_rule t ~copy_source:false); @@ -1528,7 +1528,7 @@ let get_collector t ~dir = Exn.code_error (if Path.is_in_source_tree dir then "Build_system.get_collector called on source directory" - else if dir = Path.build_dir then + else if Path.equal dir Path.build_dir then "Build_system.get_collector called on build_dir" else if not (Path.is_managed dir) then "Build_system.get_collector called on external directory" diff --git a/src/dir_contents.ml b/src/dir_contents.ml index 1440d2c9..0cb2dee5 100644 --- a/src/dir_contents.ml +++ b/src/dir_contents.ml @@ -549,7 +549,7 @@ module Dir_status = struct let project_root = Path.of_local (File_tree.Dir.project ft_dir).root in match Super_context.stanzas_in sctx ~dir with | None -> - if dir = project_root || + if Path.equal dir project_root || is_standalone (get sctx ~dir:(Path.parent_exn dir)) then Standalone (Some (ft_dir, None)) else diff --git a/src/jbuild.ml b/src/jbuild.ml index 4f86ae40..9ad3b66d 100644 --- a/src/jbuild.ml +++ b/src/jbuild.ml @@ -1846,7 +1846,7 @@ module Stanzas = struct if not (Path.exists current_file) then Loc.fail loc "File %s doesn't exist." (Path.to_string_maybe_quoted current_file); - if List.exists include_stack ~f:(fun (_, f) -> f = current_file) then + if List.exists include_stack ~f:(fun (_, f) -> Path.equal f current_file) then raise (Include_loop (current_file, include_stack)); let sexps = Io.Sexp.load ~lexer current_file ~mode:Many in parse stanza_parser sexps ~lexer ~current_file ~include_stack diff --git a/src/jbuild_load.ml b/src/jbuild_load.ml index fe5510d8..a3ab2ab3 100644 --- a/src/jbuild_load.ml +++ b/src/jbuild_load.ml @@ -242,7 +242,7 @@ let load ?extra_ignored_subtrees ?(ignore_promoted_rules=false) () = ~f:(fun dir acc -> let p = File_tree.Dir.project dir in match Path.kind (File_tree.Dir.path dir) with - | Local d when d = p.root -> p :: acc + | Local d when Path.Local.equal d p.root -> p :: acc | _ -> acc) in let packages = diff --git a/src/js_of_ocaml_rules.ml b/src/js_of_ocaml_rules.ml index 910871fb..67202a77 100644 --- a/src/js_of_ocaml_rules.ml +++ b/src/js_of_ocaml_rules.ml @@ -125,7 +125,7 @@ let build_cm cc ~(js_of_ocaml:Jbuild.Js_of_ocaml.t) ~src ~target = >>> js_of_ocaml_rule sctx ~dir ~flags:(fun flags -> As flags) ~spec ~target:itarget ] - @ (if target = itarget then + @ (if Path.equal target itarget then [] else [Build.symlink ~src:itarget ~dst:target]) diff --git a/src/print_diff.ml b/src/print_diff.ml index b5fe1bfe..c25180de 100644 --- a/src/print_diff.ml +++ b/src/print_diff.ml @@ -8,7 +8,7 @@ let print ?(skip_trailing_cr=Sys.win32) path1 path2 = Path.extract_build_context_dir path1, Path.extract_build_context_dir path2 with - | Some (dir1, f1), Some (dir2, f2) when dir1 = dir2 -> + | Some (dir1, f1), Some (dir2, f2) when Path.equal dir1 dir2 -> (dir1, Path.to_string f1, Path.to_string f2) | _ -> (Path.root, Path.to_string path1, Path.to_string path2) diff --git a/src/process.ml b/src/process.ml index 6c59b2aa..8dbc0e36 100644 --- a/src/process.ml +++ b/src/process.ml @@ -125,7 +125,7 @@ module Fancy = struct in match stdout_to, stderr_to with | (File fn1 | Opened_file { filename = fn1; _ }), - (File fn2 | Opened_file { filename = fn2; _ }) when fn1 = fn2 -> + (File fn2 | Opened_file { filename = fn2; _ }) when Path.equal fn1 fn2 -> sprintf "%s &> %s" s (Path.to_string fn1) | _ -> let s = diff --git a/src/stdune/path.ml b/src/stdune/path.ml index e7d73cdd..3683a9b1 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -136,6 +136,7 @@ module Local : sig val is_root : t -> bool val compare : t -> t -> Ordering.t val compare_val : t -> t -> Ordering.t + val equal : t -> t -> bool val of_string : ?error_loc:Usexp.Loc.t -> string -> t val to_string : t -> string val relative : ?error_loc:Usexp.Loc.t -> t -> string -> t @@ -172,6 +173,11 @@ end = struct let compare_val x y = String.compare (to_string x) (to_string y) + let equal x y = + match compare x y with + | Eq -> true + | Gt | Lt -> false + let root = make "." let is_root t = t = root diff --git a/src/stdune/path.mli b/src/stdune/path.mli index 7ed85a3c..4e2c1c0a 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -2,6 +2,7 @@ module Local : sig type t val sexp_of_t : t -> Sexp.t + val equal : t -> t -> bool end (** In the outside world *) @@ -31,6 +32,8 @@ val sexp_of_t : t Sexp.To_sexp.t val compare : t -> t -> Ordering.t (** a directory is smaller than its descendants *) +val equal : t -> t -> bool + module Set : sig include Set.S with type elt = t val sexp_of_t : t Sexp.To_sexp.t diff --git a/src/super_context.ml b/src/super_context.ml index 060db608..5a4340f4 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -638,7 +638,7 @@ let create List.iter stanzas ~f:(function | Dune_env.T config -> let inherit_from = - if ctx_dir = Scope.root scope then + if Path.equal ctx_dir (Scope.root scope) then context_env_node else lazy (Env.get t ~dir:(Path.parent_exn ctx_dir)) @@ -811,7 +811,7 @@ module Action = struct | Some host -> fun exe -> match Path.extract_build_context_dir exe with - | Some (dir, exe) when dir = sctx.context.build_dir -> + | Some (dir, exe) when Path.equal dir sctx.context.build_dir -> Path.append host.context.build_dir exe | _ -> exe