[Pkg-ocaml-maint-commits] r1067 - tools/build-dep-graph

Stefano Zacchiroli zack@costa.debian.org
Wed, 23 Mar 2005 21:33:14 +0000


Author: zack
Date: 2005-03-23 21:33:13 +0000 (Wed, 23 Mar 2005)
New Revision: 1067

Added:
   tools/build-dep-graph/build_order.txt
   tools/build-dep-graph/slice.ml
Modified:
   tools/build-dep-graph/Makefile
Log:
added slice.ml to find out rebuild order


Modified: tools/build-dep-graph/Makefile
===================================================================
--- tools/build-dep-graph/Makefile	2005-03-23 21:28:49 UTC (rev 1066)
+++ tools/build-dep-graph/Makefile	2005-03-23 21:33:13 UTC (rev 1067)
@@ -5,7 +5,7 @@
 	ocaml_src_pkgs.html	\
 	ocaml_src_pkgs.txt
 
-all: ocaml_build_deps.ps ocaml_build_deps.png ocaml_src_pkgs.html
+all: ocaml_build_deps.ps ocaml_build_deps.png ocaml_src_pkgs.html build_order.txt
 # to be used on alioth for updating graphs and lists linked by pkg-ocaml-maint home page
 install:
 	cp $(INSTALL_STUFF) ~/pkg-ocaml-maint/htdocs/
@@ -18,6 +18,8 @@
 	echo "</body></html>" >> $@
 ocaml_build_deps.dot: ocaml_src_pkgs.txt
 	./build-dep-graph.pl < $< > $@
+build_order.txt: ocaml_build_deps.dot
+	./slice.ml ocaml $< > $@
 %.png: %.dot
 	dot -Tpng $< > $@
 %.ps: %.dot

Added: tools/build-dep-graph/build_order.txt
===================================================================
--- tools/build-dep-graph/build_order.txt	2005-03-23 21:28:49 UTC (rev 1066)
+++ tools/build-dep-graph/build_order.txt	2005-03-23 21:33:13 UTC (rev 1067)
@@ -0,0 +1,77 @@
+ 0  ocaml                     []
+ 1  camlidl                   [ocaml]
+ 1  camlzip                   [ocaml]
+ 1  cdbs                      [ocaml]
+ 1  dag2html                  [ocaml]
+ 1  findlib                   [ocaml]
+ 1  fort                      [ocaml]
+ 1  geneweb                   [ocaml]
+ 1  headache                  [ocaml]
+ 1  hevea                     [ocaml]
+ 1  hlins                     [ocaml]
+ 1  lablgl                    [ocaml]
+ 1  ledit                     [ocaml]
+ 1  mlgmp                     [ocaml]
+ 1  mlgtk                     [ocaml]
+ 1  numerix                   [ocaml]
+ 1  ocaml-tools               [ocaml]
+ 1  ocamlagrep                [ocaml]
+ 1  ocamldsort                [ocaml]
+ 1  ocamlweb                  [ocaml]
+ 1  orpie                     [ocaml]
+ 1  otags                     [ocaml]
+ 1  perl4caml                 [ocaml]
+ 1  planets                   [ocaml]
+ 1  slat                      [ocaml]
+ 1  spamoracle                [ocaml]
+ 1  swig1.3                   [ocaml]
+ 2  bibtex2html               [hevea; ocaml]
+ 2  calendar                  [findlib; ocaml]
+ 2  cryptokit                 [numerix; ocaml]
+ 2  equeue                    [findlib; ocaml]
+ 2  extlib                    [findlib; ocaml]
+ 2  gmetadom                  [findlib; ocaml]
+ 2  lablgtk                   [lablgl; ocaml]
+ 2  lablgtk2                  [lablgl; ocaml]
+ 2  libpgsql-ocaml            [findlib; ocaml]
+ 2  mlglade                   [hevea; ocaml]
+ 2  mlpcap                    [findlib; ocaml]
+ 2  mysql-ocaml               [findlib; ocaml]
+ 2  ocaml-fileutils           [findlib; ocaml]
+ 2  ocaml-mad                 [findlib; ocaml]
+ 2  ocaml-shout               [findlib; ocaml]
+ 2  ocaml-sqlite              [findlib; ocaml]
+ 2  ocaml-vorbis              [findlib; ocaml]
+ 2  ocamlcreal                [mlgmp; ocaml]
+ 2  ocamlgraph                [findlib; ocaml]
+ 2  ocamlgsl                  [findlib; ocaml]
+ 2  ocamlsdl                  [lablgl; ocaml]
+ 2  ounit                     [findlib; ocaml]
+ 2  pagodacf                  [findlib; ocaml]
+ 2  pcre-ocaml                [findlib; ocaml]
+ 2  polygen                   [cdbs; ocaml]
+ 2  postgresql-ocaml          [findlib; ocaml]
+ 2  pycaml                    [ocaml-tools; ocaml]
+ 2  ulex                      [findlib; ocaml]
+ 2  wlex                      [findlib; ocaml]
+ 2  xstr                      [findlib; ocaml]
+ 3  ara                       [lablgtk2; lablgl; ocaml]
+ 3  cameleon                  [lablgtk; lablgl; ocaml]
+ 3  camlimages                [lablgtk; lablgl; ocaml]
+ 3  coq                       [lablgtk2; lablgl; ocaml]
+ 3  gdome2-xslt               [gmetadom; findlib; ocaml]
+ 3  lablgtk2-doc              [lablgtk2; lablgl; ocaml]
+ 3  lablgtkmathview           [gmetadom; findlib; ocaml]
+ 3  missinglib                [ounit; findlib; ocaml]
+ 3  mldonkey                  [lablgtk2; lablgl; ocaml]
+ 3  ocamlnet                  [pcre-ocaml; findlib; ocaml]
+ 3  ocamlodbc                 [lablgtk; lablgl; ocaml]
+ 3  regexp-pp                 [pcre-ocaml; findlib; ocaml]
+ 3  unison                    [lablgtk; lablgl; ocaml]
+ 4  advi                      [camlimages; lablgtk; lablgl; ocaml]
+ 4  dfsbuild                  [missinglib; ounit; findlib; ocaml]
+ 4  editex                    [gdome2-xslt; gmetadom; findlib; ocaml]
+ 4  netclient                 [ocamlnet; pcre-ocaml; findlib; ocaml]
+ 4  ocamldap                  [ocamlnet; pcre-ocaml; findlib; ocaml]
+ 4  ocamldbi                  [ocamlodbc; lablgtk; lablgl; ocaml]
+ 4  pxp                       [ocamlnet; pcre-ocaml; findlib; ocaml]

Added: tools/build-dep-graph/slice.ml
===================================================================
--- tools/build-dep-graph/slice.ml	2005-03-23 21:28:49 UTC (rev 1066)
+++ tools/build-dep-graph/slice.ml	2005-03-23 21:33:13 UTC (rev 1067)
@@ -0,0 +1,100 @@
+#!/usr/bin/ocamlrun /usr/bin/ocaml
+#use "topfind";;
+#require "str";;
+
+open Printf
+
+(** @param src source node
+  * @param dst destination node
+  * @param edges associative list representation of a DAG
+  * @return a list of all paths connecting src to dst
+  *)
+let all_paths src dst edges =
+  let rec neighbours src' = function
+    | (src, dst) :: rest when src = src' -> dst :: neighbours src' rest
+    | _ :: rest -> neighbours src' rest
+    | [] -> []
+  in
+  let rec aux_single acc src =
+    if src = dst then
+      [dst::acc]
+    else
+      aux_multi (src :: acc) (neighbours src edges)
+  and aux_multi acc = function
+    | [] -> []
+    | src :: rest -> aux_single acc src @ aux_multi acc rest
+  in
+    List.map (fun path -> List.tl (List.rev path)) (aux_single [] src)
+
+(** @param paths list of paths
+  * @return the longest path among those passed *)
+let longest_path paths =
+  let rec aux path len = function
+    | path' :: rest ->
+        let len' = List.length path' in
+        if len' > len then
+          aux path' len' rest
+        else
+          aux path len rest
+    | [] -> path
+  in
+    aux [] 0 paths
+
+(** @param target reference node for computing distances
+  * @param edges associative list representation of a DAG
+  * @return a list of triples <node, path, pathlen> where node is a node of the
+  * graph, path the longest path from it to target, pathlen the length of that
+  * path *)
+let slice target edges =
+  let module S = Set.Make (String) in
+  let nodes =
+    S.elements
+      (List.fold_left
+        (fun set n -> S.add n set)
+        S.empty
+        (let (l1, l2) = List.split edges in l1 @ l2))
+  in
+    List.map
+      (fun node ->
+         let p = longest_path (all_paths node target edges) in
+         (node, p, List.length p))
+      nodes
+
+let node_RE = Str.regexp "[\t\r\n ]*\\([a-zA-Z0-9]+\\).*label=\"\\([^\"]+\\)\""
+let edge_RE = Str.regexp "[\t\r\n ]*\\([a-zA-Z0-9]+\\)[\t\r\n ]*->[\t\r\n ]*\\([a-zA-Z0-9]+\\)"
+
+(** @param fname .dot (graphviz) file name
+  * @return a list of pairs <src, dst> result of parsing the .dot file, both are
+  * labels extracted from the file *)
+let parse_edges fname =
+  let ic = open_in fname in
+  let node2label = Hashtbl.create 200 in
+  let resolve node =
+    try Hashtbl.find node2label node with Not_found -> assert false
+  in
+  let edges = ref [] in
+    try
+      while true do
+        let line = input_line ic in
+          if Str.string_match node_RE line 0 then (* node line, save label *)
+            Hashtbl.add node2label
+              (Str.matched_group 1 line) (Str.matched_group 2 line)
+          else if Str.string_match edge_RE line 0 then
+            let src = resolve (Str.matched_group 1 line) in
+            let dst = resolve (Str.matched_group 2 line) in
+            edges := (src, dst) :: !edges
+      done;
+      []  (* dummy value *)
+    with End_of_file ->
+          !edges
+
+(** pretty printing of triples returned by parse_edges *)
+let print_slices distances =
+  List.iter
+    (fun (name, path, _) ->
+       printf "%2d  %-25s [%s]\n" (List.length path) name
+        (String.concat "; " path))
+    (List.sort (fun (_, _, l1) (_, _, l2) -> compare l1 l2) distances)
+
+let _ = print_slices (slice Sys.argv.(1) (parse_edges Sys.argv.(2)))
+


Property changes on: tools/build-dep-graph/slice.ml
___________________________________________________________________
Name: svn:executable
   + *