Sebastien Mondet avatar Sebastien Mondet committed 640c98d

build: add (un)install targets

Comments (0)

Files changed (1)

  • +48 -3
    mk
 
 let chain l =
   List.iter l ~f:(fun cmd ->
+      printf "! %s\n%!" cmd;
       if  Sys.command cmd = 0
       then ()
       else ksprintf failwith "%S failed." cmd
   Sys.chdir "../";
   ()
 
+let version = "0.0.0"
+let description = "Basic Error Monads"
+let name = "pvem"
+
+let cma = sprintf "%s.cma"
+let cmi = sprintf "%s.cmi"
+let cmx = sprintf "%s.cmx"
+let cmo = sprintf "%s.cmo"
+let cmxa = sprintf "%s.cmxa"
+let cmxs = sprintf "%s.cmxs"
+let a = sprintf "%s.a"
+let installable n =
+  List.map ~f:(fun f -> f n) [cmx; cmo; cma; cmi; cmxa; cmxs; a]
+
+let meta () =
+  let out = open_out "META" in
+  fprintf out "version = %S\n\
+               description = %S\n\
+               archive(byte) = %S\n\
+               archive(byte,plugin) = %S\n\
+               archive(native) = %S\n\
+               archive(native, plugin) = %S\n\
+               exists_if = %S\n\
+              "
+    version description
+    (cma name) (cma name) (cmxa name) (cmxs name) (cma name);
+  close_out out
 
 let build () =
   in_build_directory (fun () ->
         "cp ../pvem.ml .";
         "ocamlc -c pvem.ml -annot -o _build/pvem.cmo";
         "ocamlopt -c pvem.ml -annot -o _build/pvem.cmx";
-      ])
+        "ocamlc pvem.cmo -a -o pvem.cma";
+        "ocamlopt pvem.cmx -a -o pvem.cmxa";
+        "ocamlopt pvem.cmx -a -o pvem.a";
+        "ocamlopt pvem.cmx -shared -o pvem.cmxs";
+      ];
+      meta ();
+    )
 
 let () =
   match args with
     say "Building the documentation.";
     in_build_directory (fun () ->
         chain [
-          "ocamldoc -charset UTF-8 -colorize-code -html pvem.ml";
+          sprintf "ocamldoc -charset UTF-8 -colorize-code -html %s.ml" name;
+        ])
+  | exec :: "install" :: [] ->
+    say "Installing";
+    in_build_directory (fun () ->
+        chain [
+          sprintf "ocamlfind install %s META %s"
+            name (String.concat " " (installable name))
         ])
+  | exec :: "uninstall" :: [] ->
+    chain [
+      sprintf "ocamlfind remove %s" name
+    ]
   | exec :: "clean" :: []
   | exec :: "C" :: [] ->
     cmdf "rm -fr _build"
   | _ ->
-    say "usage: ./mk [build|install|uninstall|clean]"
+    say "usage: ./mk [build|test|install|uninstall|clean]"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.