C build tool of the 21st century
at main 58 lines 1.9 kB view raw
1open Zenon_build 2open Common 3 4let info ~path ~builds () = 5 Eio_posix.run @@ fun env -> 6 let x = load_config ~log_level:`Quiet ~builds env path in 7 let builds = filter_builds x builds in 8 let build_map = make_build_map x in 9 let builds_with_deps_set = builds_with_deps build_map builds in 10 let targets = 11 List.filter (fun b -> String_set.mem b.Build.name builds_with_deps_set) x 12 in 13 List.iter 14 (fun (b : Build.t) -> 15 let sources = Build.locate_source_files b |> List.of_seq in 16 let linker = 17 Linker.auto_select_linker ~sources ?output:b.output ?linker:b.linker 18 b.name 19 in 20 Fmt.pr "@[<v 2>Target: %s@," b.name; 21 (match b.output with 22 | Some p -> Fmt.pr "Output: %s@," (Eio.Path.native_exn p) 23 | None -> Fmt.pr "Output: none@,"); 24 Fmt.pr "Type: %s@," 25 (match linker.link_type with 26 | Linker.Executable -> "executable" 27 | Linker.Shared -> "shared lib" 28 | Linker.Static -> "static lib"); 29 Fmt.pr "Linker: %s@," linker.name; 30 31 Fmt.pr "Source files: %d@," (List.length sources); 32 33 List.iter 34 (fun (f : Source_file.t) -> 35 let ext = Source_file.ext f in 36 let compiler_name = 37 match Hashtbl.find_opt b.compiler_index ext with 38 | Some c -> c.Compiler.name 39 | None -> "unknown" 40 in 41 Fmt.pr " %s: (compiler %s)@," 42 (Eio.Path.native_exn f.path) 43 compiler_name) 44 sources; 45 46 if not (List.is_empty b.depends_on) then 47 Fmt.pr "Dependencies: %a@," 48 (Fmt.list ~sep:(Fmt.any ", ") Fmt.string) 49 b.depends_on 50 else Fmt.pr "Dependencies: none@,"; 51 52 if not (List.is_empty b.pkgconf) then 53 Fmt.pr "Pkg-config: %a@," 54 (Fmt.list ~sep:(Fmt.any ", ") Fmt.string) 55 b.pkgconf; 56 57 Fmt.pr "@]@.") 58 targets