pijul nest
guest [sign in]

Frontend: starting the connection before linking

pmeunier
Jul 2, 2025, 9:24 PM
P27ILID2JNRMIXJNW47AWFYDU37BXQETA63W742HWVWGAXEET4QQC

Dependencies

  • [2] 6MGFBMON Debug and cleanup
  • [3] UWQB743K First working shell (with ocaml code)
  • [4] ODUDDQRY Adding the OCaml interface
  • [5] RLH67CXJ Make the "file" argument optional in `elpe build`

Change contents

  • edit in elpe/bin/elpe_bin.ml at line 1
    [3.63278]
    [3.73141]
    open Lwt.Syntax
  • replacement in elpe/bin/elpe_bin.ml at line 15
    [3.73589][3.73589:73843]()
    let run_shell (spec : Elpe.std_derivation) cmd =
    Lwt_main.run
    (let open Lwt.Syntax in
    let port = 50051 in
    let address = "127.0.0.1" in
    let* c = connection address port in
    Elpe.backend_conn := Some c;
    let* b = spec#setup in
    [3.73589]
    [3.63289]
    let run_shell (spec : Elpe.derivation) cmd =
    let* b = spec#setup in
  • replacement in elpe/bin/elpe_bin.ml at line 18
    [3.63290][3.73844:73938]()
    let* bash = (Elpe.ubuntu "bash-static")#build in
    let bash = List.hd bash.destdir in
    [3.63290]
    [3.73938]
    let* bash = (Elpe.ubuntu "bash-static")#build in
    let bash = List.hd bash.destdir in
  • replacement in elpe/bin/elpe_bin.ml at line 21
    [3.73939][3.73939:74021]()
    let f = Filename.temp_dir "elpe-" "" ^ "/setup" in
    Unix.mkfifo f 0o666;
    [3.73939]
    [3.63487]
    let f = Filename.temp_dir "elpe-" "" ^ "/setup" in
    Unix.mkfifo f 0o666;
  • replacement in elpe/bin/elpe_bin.ml at line 24
    [3.63488][3.74022:74310]()
    let pid =
    Unix.create_process
    (bash ^ "/usr/bin/bash-static")
    (match cmd with
    | None -> [| "bash"; "--init-file"; f; "-i" |]
    | Some cmd -> [| "bash"; "--init-file"; f; "-i"; "-c"; cmd |])
    Unix.stdin Unix.stdout Unix.stderr
    in
    [3.63488]
    [3.74310]
    let pid =
    Unix.create_process
    (bash ^ "/usr/bin/bash-static")
    (match cmd with
    | None -> [| "bash"; "--init-file"; f; "-i" |]
    | Some cmd -> [| "bash"; "--init-file"; f; "-i"; "-c"; cmd |])
    Unix.stdin Unix.stdout Unix.stderr
    in
  • replacement in elpe/bin/elpe_bin.ml at line 33
    [3.74311][3.74311:74447]()
    let p = Unix.openfile f [ Unix.O_WRONLY ] 0o644 in
    let _ = Unix.write_substring p b 0 (String.length b) in
    Unix.close p;
    [3.74311]
    [3.74447]
    let p = Unix.openfile f [ Unix.O_WRONLY ] 0o644 in
    let _ = Unix.write_substring p b 0 (String.length b) in
    Unix.close p;
  • replacement in elpe/bin/elpe_bin.ml at line 37
    [3.74448][3.74448:74557]()
    match Unix.waitpid [] pid with
    | _, Unix.WEXITED e -> Lwt.return e
    | _ -> failwith "Unknown")
    [3.74448]
    [3.74557]
    match Unix.waitpid [] pid with
    | _, Unix.WEXITED e -> Lwt.return e
    | _ -> failwith "Unknown"
  • replacement in elpe/bin/elpe_bin.ml at line 42
    [3.74599][3.74599:74889]()
    Lwt_main.run
    (let open Lwt.Syntax in
    let port = 50051 in
    let address = "127.0.0.1" in
    let* c = connection address port in
    Elpe.backend_conn := Some c;
    let* b = spec#build in
    print_endline (List.fold_left (fun _ x -> x) "" b.destdir);
    Lwt.return ())
    [3.74599]
    [3.63635]
    let* b = spec#build in
    print_endline (List.fold_left (fun _ x -> x) "" b.destdir);
    Lwt.return ()
  • edit in elpe/bin/elpe_bin.ml at line 71
    [3.64202]
    [3.64202]
    let port = 50051 in
    let address = "127.0.0.1" in
    let* c = connection address port in
    Elpe.backend_conn := Some c;
  • replacement in elpe/bin/elpe_bin.ml at line 83
    [3.64350][3.74980:75003]()
    Dynlink.loadfile obj
    [3.64350]
    [3.75003]
    Lwt.return (Dynlink.loadfile obj)
  • replacement in elpe/bin/elpe_bin.ml at line 92
    [3.75279][3.75279:75428]()
    compile files;
    match !Elpe.last_built_module with
    | None -> Unix._exit 0
    | Some last -> Unix._exit (run_shell last cmd))
    [3.75279]
    [3.75428]
    Lwt_main.run
    (let* _ = compile (if files = [] then [ "build.ml" ] else files) in
    match !Elpe.last_built_module with
    | None -> Unix._exit 0
    | Some last ->
    let* last = last in
    let* shell = run_shell last cmd in
    Unix._exit shell))
  • replacement in elpe/bin/elpe_bin.ml at line 106
    [3.75630][2.309:372](),[3.135][3.75652:75814](),[2.372][3.75652:75814](),[3.75652][3.75652:75814]()
    compile (if files = [] then [ "build.ml" ] else files);
    let _ =
    match !Elpe.last_built_module with
    | None -> ()
    | Some last -> run_build (last :> Elpe.derivation)
    in
    ())
    [3.75630]
    [3.64512]
    Lwt_main.run
    (let* _ = compile (if files = [] then [ "build.ml" ] else files) in
    match !Elpe.last_built_module with
    | None -> Lwt.return ()
    | Some last ->
    let* last = last in
    run_build (last :> Elpe.derivation)))