Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add helper scripts to build .config.in and .install

  • Loading branch information...
commit 7e5fe8a5a1037d7dbfc81405bf7bb2bc4e1a9967 1 parent 041d639
Thomas Gazagnaire samoht authored
3  Makefile
@@ -5,7 +5,8 @@ SRC_EXT=src_ext
5 5 TARGETS = opam opam-server \
6 6 opam-rsync-init opam-rsync-update opam-rsync-download opam-rsync-upload \
7 7 opam-git-init opam-git-update opam-git-download opam-git-upload \
8   - opam-server-init opam-server-update opam-server-download opam-server-upload
  8 + opam-server-init opam-server-update opam-server-download opam-server-upload \
  9 + opam-mk-config opam-mk-install
9 10
10 11 .PHONY: all
11 12
12 opam.ocp
@@ -136,4 +136,16 @@ begin program "opam-server-upload"
136 136 requires = [ "opam-server-lib" ]
137 137 end
138 138
  139 +end
  140 +
  141 +(* Helpers *)
  142 +
  143 +begin program "opam-mk-config"
  144 + files = [ "src/opam_mk_config.ml" ]
  145 + requires = [ "opam-lib" ]
  146 +end
  147 +
  148 +begin program "opam-mk-install"
  149 + files = [ "src/opam_mk_install.ml" ]
  150 + requires = [ "opam-lib" ]
139 151 end
76 src/opam_mk_config.ml
... ... @@ -0,0 +1,76 @@
  1 +(***********************************************************************)
  2 +(* *)
  3 +(* Copyright 2012 OCamlPro *)
  4 +(* Copyright 2012 INRIA *)
  5 +(* *)
  6 +(* All rights reserved. This file is distributed under the terms of *)
  7 +(* the GNU Public License version 3.0. *)
  8 +(* *)
  9 +(* TypeRex is distributed in the hope that it will be useful, *)
  10 +(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
  11 +(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
  12 +(* GNU General Public License for more details. *)
  13 +(* *)
  14 +(***********************************************************************)
  15 +
  16 +(* Small helper to create .config.in files *)
  17 +
  18 +let version () =
  19 + Printf.printf "\
  20 +%s version %s
  21 +
  22 +Copyright (C) 2012 OCamlPro - INRIA
  23 +
  24 +This is free software; see the source for copying conditions. There is NO
  25 +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
  26 + Sys.argv.(0) Globals.version;
  27 + exit 0
  28 +
  29 +let usage =
  30 + Printf.sprintf "%s -package <name> [-lib <name>|-syntax <name>]+" Sys.argv.(0)
  31 +
  32 +let p = ref ""
  33 +let sections = ref []
  34 +let add x = sections := x :: !sections
  35 +let add_l x = add ("library", x)
  36 +let add_s x = add ("syntax", x)
  37 +
  38 +let specs = Arg.align [
  39 + ("-version", Arg.Unit version, " display version information");
  40 + ("-lib" , Arg.String add_l, "<name> add a library");
  41 + ("-syntax" , Arg.String add_s, "<name> add a syntax extension");
  42 + ("-package", Arg.Set_string p, "<name> set the package name");
  43 +]
  44 +
  45 +let ano x =
  46 + Printf.eprintf "Don't know what to do with %s\n" x;
  47 + exit 1
  48 +
  49 +let _ =
  50 + Arg.parse specs ano usage
  51 +
  52 +let sections = List.rev !sections
  53 +let package =
  54 + if !p = "" then (
  55 + Printf.eprintf "Missing package name\n";
  56 + exit 1
  57 + ) else
  58 + !p
  59 +
  60 +let () =
  61 + let oc = open_out (package ^ ".config.in") in
  62 + List.iter (fun (section, name) ->
  63 + Printf.fprintf oc "\
  64 +%s %S {
  65 + asmcomp: [ \"-I\" \"%%{lib}%%/%s\" ]
  66 + bytelink: [ \"-I\" \"%%{lib}%%/%s\" ]
  67 + asmlink: [ \"-I\" \"%%{lib}%%/%s\" \"%s.cmxa\" ]
  68 + bytelink: [ \"-I\" \"%%{lib}%%/%s\" \"%s.cma\" ]
  69 + requires: [ XXX ]
  70 +}\n\n"
  71 + section name
  72 + package
  73 + package
  74 + package name
  75 + package name
  76 + ) sections
78 src/opam_mk_install.ml
... ... @@ -0,0 +1,78 @@
  1 +(***********************************************************************)
  2 +(* *)
  3 +(* Copyright 2012 OCamlPro *)
  4 +(* Copyright 2012 INRIA *)
  5 +(* *)
  6 +(* All rights reserved. This file is distributed under the terms of *)
  7 +(* the GNU Public License version 3.0. *)
  8 +(* *)
  9 +(* TypeRex is distributed in the hope that it will be useful, *)
  10 +(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
  11 +(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
  12 +(* GNU General Public License for more details. *)
  13 +(* *)
  14 +(***********************************************************************)
  15 +
  16 +(* Small helper to create .install.in files *)
  17 +
  18 +let version () =
  19 + Printf.printf "\
  20 +%s version %s
  21 +
  22 +Copyright (C) 2012 OCamlPro - INRIA
  23 +
  24 +This is free software; see the source for copying conditions. There is NO
  25 +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
  26 + Sys.argv.(0) Globals.version;
  27 + exit 0
  28 +
  29 +let usage =
  30 + Printf.sprintf "%s -package <name> [-lib <name>|-syntax <name>|-bin <name>]+" Sys.argv.(0)
  31 +
  32 +let p = ref ""
  33 +
  34 +let sections = ref []
  35 +let add x = sections := x :: !sections
  36 +let add_l x = add ("lib", x)
  37 +let add_s x = add ("lib", x)
  38 +let add_b x = add ("bin", x)
  39 +
  40 +let specs = Arg.align [
  41 + ("-version", Arg.Unit version, " display version information");
  42 + ("-bin" , Arg.String add_b, "<name> add a library");
  43 + ("-lib" , Arg.String add_l, "<name> add a library");
  44 + ("-syntax" , Arg.String add_s, "<name> add a syntax extension");
  45 + ("-package", Arg.Set_string p, "<name> set the package name");
  46 +]
  47 +
  48 +let ano x =
  49 + Printf.eprintf "Don't know what to do with %s\n" x;
  50 + exit 1
  51 +
  52 +let _ =
  53 + Arg.parse specs ano usage
  54 +
  55 +let package =
  56 + if !p <> "" then (
  57 + !p
  58 + ) else (
  59 + Printf.eprintf "Missing package name\n";
  60 + exit 1
  61 + )
  62 +
  63 +let sections = List.rev !sections
  64 +
  65 +let () =
  66 + let oc = open_out (package ^ ".install") in
  67 + let libs = List.filter (fun (s,_) -> s = "lib") sections in
  68 + let bins = List.filter (fun (s,_) -> s = "bin") sections in
  69 + if libs <> [] then (
  70 + Printf.fprintf oc "lib: [";
  71 + List.iter (fun (_, name) -> Printf.fprintf oc "%S " name) libs;
  72 + Printf.fprintf oc "]\n"
  73 + );
  74 + if bins <> [] then (
  75 + Printf.fprintf oc "bin: [";
  76 + List.iter (fun (_, name) -> Printf.fprintf oc "%s " name) libs;
  77 + Printf.fprintf oc "]\n"
  78 + )

0 comments on commit 7e5fe8a

Please sign in to comment.
Something went wrong with that request. Please try again.