@@ -72,33 +72,19 @@ module Repository = struct
7272end
7373
7474let dev_tool_path_to_source_dir path =
75- let lock_dir_location =
76- Path.Build. relative Path.Build. root " .dev-tools.locks" |> Path. build
77- in
78- let absolute = Path. to_absolute_filename lock_dir_location in
79- match Path.External. is_descendant ~of_: (Path.External. of_string absolute) path with
80- | false ->
75+ match Path.Expert. try_localize_external (Path. external_ path) with
76+ | External _ | In_source_tree _ ->
8177 Code_error. raise
8278 " External path is not pointing to lock dir location"
83- [ " external" , Path.External. to_dyn path
84- ; " dev tool lock dir location" , Path. to_dyn lock_dir_location
85- ]
86- | true ->
87- let as_string = Path.External. to_string path in
88- (match String. drop_prefix ~prefix: absolute as_string with
89- | None ->
90- (* we checked for descendants before, thus it has to match the prefix *)
91- assert false
92- | Some suffix ->
93- (match String. split ~on: '/' suffix with
94- | "" :: dev_tool_name :: components ->
95- Path.Source.L. relative
96- Path.Source. root
97- ([ " _build" ; " .dev-tools.locks" ; dev_tool_name ] @ components)
98- | components ->
99- Code_error. raise
100- " Unexpected external path"
101- [ " dir" , Path.External. to_dyn path
102- ; " components" , Dyn. (list string ) components
103- ]))
79+ [ " external" , Path.External. to_dyn path ]
80+ | In_build_dir b ->
81+ (match Path.Build. explode b with
82+ | ".dev-tools.locks" :: dev_tool_name :: components ->
83+ Path.Source.L. relative
84+ Path.Source. root
85+ ([ " _build" ; " .dev-tools.locks" ; dev_tool_name ] @ components)
86+ | components ->
87+ Code_error. raise
88+ " Unexpected external path"
89+ [ " dir" , Path.External. to_dyn path; " components" , Dyn. (list string ) components ])
10490;;
0 commit comments