@@ -187,12 +187,12 @@ let step ~prog ~args ~common ~no_rebuild ~context ~on_exit () =
187187 directory lock.
188188
189189 Returns the absolute path to the executable. *)
190- let build_prog_via_rpc_if_necessary ~dir ~no_rebuild prog =
190+ let build_prog_via_rpc_if_necessary ~dir ~no_rebuild ~ prog builder lock_held_by =
191191 match Filename. analyze_program_name prog with
192192 | In_path ->
193193 (* This case is reached if [dune exec] is passed the name of an
194194 executable (rather than a path to an executable). When dune is running
195- directly, dune will try to resolve the executbale name within the public
195+ directly, dune will try to resolve the executable name within the public
196196 executables defined in the current project and its dependencies, and
197197 only if no executable with the given name is found will dune then
198198 resolve the name within the $PATH variable instead. Looking up an
@@ -225,7 +225,18 @@ let build_prog_via_rpc_if_necessary ~dir ~no_rebuild prog =
225225 Dune_lang.Dep_conf. File
226226 (Dune_lang.String_with_vars. make_text Loc. none (Path. to_string path))
227227 in
228- Build. build_via_rpc_server ~print_on_success: false ~targets: [ target ])
228+ let targets = Rpc.Group.Build. prepare_targets [ target ] in
229+ let + build_outcome =
230+ Rpc.Rpc_common. fire_message
231+ ~name: " build"
232+ ~wait: true
233+ ~lock_held_by
234+ builder
235+ (Rpc.Rpc_common. Request
236+ (Dune_rpc.Decl.Request. witness Dune_rpc_impl.Decl. build))
237+ targets
238+ in
239+ Rpc.Rpc_common. wrap_build_outcome_exn ~print_on_success: false build_outcome)
229240 in
230241 Path. to_absolute_filename path
231242 | Absolute ->
@@ -234,7 +245,7 @@ let build_prog_via_rpc_if_necessary ~dir ~no_rebuild prog =
234245 else not_found ~hints: [] ~prog
235246;;
236247
237- let exec_building_via_rpc_server ~common ~prog ~args ~no_rebuild =
248+ let exec_building_via_rpc_server ~common ~prog ~args ~no_rebuild builder lock_held_by =
238249 let open Fiber.O in
239250 let ensure_terminal v =
240251 match (v : Cmd_arg.t ) with
@@ -252,7 +263,9 @@ let exec_building_via_rpc_server ~common ~prog ~args ~no_rebuild =
252263 let dir = Context_name. build_dir context in
253264 let prog = ensure_terminal prog in
254265 let args = List. map args ~f: ensure_terminal in
255- let + prog = build_prog_via_rpc_if_necessary ~dir ~no_rebuild prog in
266+ let + prog =
267+ build_prog_via_rpc_if_necessary ~dir ~no_rebuild ~prog builder lock_held_by
268+ in
256269 restore_cwd_and_execve (Common. root common) prog args Env. initial
257270;;
258271
@@ -311,18 +324,9 @@ let term : unit Term.t =
311324 | Pid_from_lockfile pid -> sprintf " (pid: %d)" pid)
312325 ]
313326 | No ->
314- if not (Common.Builder. equal builder Common.Builder. default)
315- then
316- User_warning. emit
317- [ Pp. textf
318- " Your build request is being forwarded to a running Dune instance%s. Note \
319- that certain command line arguments may be ignored."
320- (match lock_held_by with
321- | Unknown -> " "
322- | Pid_from_lockfile pid -> sprintf " (pid: %d)" pid)
323- ];
324327 Scheduler. go_without_rpc_server ~common ~config
325- @@ fun () -> exec_building_via_rpc_server ~common ~prog ~args ~no_rebuild )
328+ @@ fun () ->
329+ exec_building_via_rpc_server ~common ~prog ~args ~no_rebuild builder lock_held_by)
326330 | Ok () -> exec_building_directly ~common ~config ~context ~prog ~args ~no_rebuild
327331;;
328332
0 commit comments