Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

oasis infrastructure

  • Loading branch information...
commit 8dce29a480d812a2099cf18fbc0b9c5dd30a23ed 1 parent fb781c0
@little-arhat little-arhat authored
View
5 .gitignore
@@ -0,0 +1,5 @@
+_build
+setup.data
+setup.log
+src/config.*
+*.ba*
View
5 AUTHORS.txt
@@ -0,0 +1,5 @@
+(* OASIS_START *)
+(* DO NOT EDIT (digest: 95826e936a6c5a9f1637c9758822a251) *)
+Authors of lwt_zmq
+Roma Sokolov
+(* OASIS_STOP *)
View
38 INSTALL.txt
@@ -0,0 +1,38 @@
+(* OASIS_START *)
+(* DO NOT EDIT (digest: 1ac7fa8366ddaa7cbdb76a0225149c11) *)
+This is the INSTALL file for the lwt_zmq distribution.
+
+This package uses OASIS to generate its build system. See section OASIS for
+full information.
+
+Dependencies
+============
+
+In order to compile this package, you will need:
+* ocaml
+* findlib
+* lwt
+* ZMQ
+
+Installing
+==========
+
+1. Uncompress the source archive and go to the root of the package
+2. Run 'ocaml setup.ml -configure'
+3. Run 'ocaml setup.ml -build'
+4. Run 'ocaml setup.ml -install'
+
+Uninstalling
+============
+
+1. Go to the root of the package
+2. Run 'ocaml setup.ml -uninstall'
+
+OASIS
+=====
+
+OASIS is a program that generates a setup.ml file using a simple '_oasis'
+configuration file. The generated setup only depends on the standard OCaml
+installation: no additional library is required.
+
+(* OASIS_STOP *)
View
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2011 by Roman Sokolov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
38 Makefile
@@ -0,0 +1,38 @@
+# OASIS_START
+# DO NOT EDIT (digest: bc1e05bfc8b39b664f29dae8dbd3ebbb)
+
+SETUP = ocaml setup.ml
+
+build: setup.data
+ $(SETUP) -build $(BUILDFLAGS)
+
+doc: setup.data build
+ $(SETUP) -doc $(DOCFLAGS)
+
+test: setup.data build
+ $(SETUP) -test $(TESTFLAGS)
+
+all:
+ $(SETUP) -all $(ALLFLAGS)
+
+install: setup.data
+ $(SETUP) -install $(INSTALLFLAGS)
+
+uninstall: setup.data
+ $(SETUP) -uninstall $(UNINSTALLFLAGS)
+
+reinstall: setup.data
+ $(SETUP) -reinstall $(REINSTALLFLAGS)
+
+clean:
+ $(SETUP) -clean $(CLEANFLAGS)
+
+distclean:
+ $(SETUP) -distclean $(DISTCLEANFLAGS)
+
+setup.data:
+ $(SETUP) -configure $(CONFIGUREFLAGS)
+
+.PHONY: build doc test all install uninstall reinstall clean distclean configure
+
+# OASIS_STOP
View
11 README.txt
@@ -0,0 +1,11 @@
+(* OASIS_START *)
+(* DO NOT EDIT (digest: aea16b7277b728b2e59bd44c04f96520) *)
+This is the README file for the lwt_zmq distribution.
+
+zmq sockets for lwt async framewrok
+
+See the files INSTALL.txt for building and installation instructions. See the
+file LICENSE for copying conditions.
+
+
+(* OASIS_STOP *)
View
32 _oasis
@@ -0,0 +1,32 @@
+OASISFormat: 0.2
+Name: lwt_zmq
+Version: 0.0.1b
+Synopsis: zmq sockets for lwt async framewrok
+Authors: Roma Sokolov
+License: MIT
+LicenseFile: LICENSE
+Plugins: DevFiles (0.2), META (0.2), StdFiles (0.2)
+BuildTools: ocamlbuild
+
+Library "lwt-zmq"
+ Path: src
+ Modules: Lwt_zmq
+ BuildDepends: lwt, lwt.unix, ZMQ
+ NativeOpt: -w @a
+ ByteOpt: -w @a
+
+
+Executable relay
+ Path: tests
+ MainIs: relay.ml
+ NativeOpt: -w @a
+ ByteOpt: -w @a
+ BuildDepends: lwt, lwt.unix, ZMQ
+ Install: false
+ CompiledObject: byte
+
+
+SourceRepository github
+ Type: git
+ Location: git://github.com/camlunity/lwt_zmq.git
+ Browser: https://github.com/camlunity/lwt_zmq
View
23 _tags
@@ -0,0 +1,23 @@
+# OASIS_START
+# DO NOT EDIT (digest: 3b5f1a4fbcaf313664626da8e14e3006)
+# Executable relay
+"tests/relay.byte": oasis_executable_relay_byte
+<tests/*.ml{,i}>: oasis_executable_relay_byte
+"tests/relay.byte": oasis_executable_relay_native
+<tests/*.ml{,i}>: oasis_executable_relay_native
+"tests/relay.byte": pkg_lwt.unix
+"tests/relay.byte": pkg_lwt
+"tests/relay.byte": pkg_ZMQ
+<tests/*.ml{,i}>: pkg_lwt.unix
+<tests/*.ml{,i}>: pkg_lwt
+<tests/*.ml{,i}>: pkg_ZMQ
+# Library lwt-zmq
+"src": include
+<src/lwt-zmq.{cma,cmxa}>: oasis_library_lwt_zmq_byte
+<src/*.ml{,i}>: oasis_library_lwt_zmq_byte
+<src/lwt-zmq.{cma,cmxa}>: oasis_library_lwt_zmq_native
+<src/*.ml{,i}>: oasis_library_lwt_zmq_native
+<src/*.ml{,i}>: pkg_lwt.unix
+<src/*.ml{,i}>: pkg_lwt
+<src/*.ml{,i}>: pkg_ZMQ
+# OASIS_STOP
View
8 configure
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# OASIS_START
+# DO NOT EDIT (digest: ed33e59fe00e48bc31edf413bbc8b8d6)
+set -e
+
+ocaml setup.ml -configure $*
+# OASIS_STOP
View
489 myocamlbuild.ml
@@ -0,0 +1,489 @@
+(* OASIS_START *)
+(* DO NOT EDIT (digest: ab54688a685c09a9aea04ab40382ffa1) *)
+module OASISGettext = struct
+# 21 "/home/typhon/kamlo/oasis/src/oasis/OASISGettext.ml"
+
+ let ns_ str =
+ str
+
+ let s_ str =
+ str
+
+ let f_ (str : ('a, 'b, 'c, 'd) format4) =
+ str
+
+ let fn_ fmt1 fmt2 n =
+ if n = 1 then
+ fmt1^^""
+ else
+ fmt2^^""
+
+ let init =
+ []
+
+end
+
+module OASISExpr = struct
+# 21 "/home/typhon/kamlo/oasis/src/oasis/OASISExpr.ml"
+
+
+
+ open OASISGettext
+
+ type test = string
+
+ type flag = string
+
+ type t =
+ | EBool of bool
+ | ENot of t
+ | EAnd of t * t
+ | EOr of t * t
+ | EFlag of flag
+ | ETest of test * string
+
+
+ type 'a choices = (t * 'a) list
+
+ let eval var_get t =
+ let rec eval' =
+ function
+ | EBool b ->
+ b
+
+ | ENot e ->
+ not (eval' e)
+
+ | EAnd (e1, e2) ->
+ (eval' e1) && (eval' e2)
+
+ | EOr (e1, e2) ->
+ (eval' e1) || (eval' e2)
+
+ | EFlag nm ->
+ let v =
+ var_get nm
+ in
+ assert(v = "true" || v = "false");
+ (v = "true")
+
+ | ETest (nm, vl) ->
+ let v =
+ var_get nm
+ in
+ (v = vl)
+ in
+ eval' t
+
+ let choose ?printer ?name var_get lst =
+ let rec choose_aux =
+ function
+ | (cond, vl) :: tl ->
+ if eval var_get cond then
+ vl
+ else
+ choose_aux tl
+ | [] ->
+ let str_lst =
+ if lst = [] then
+ s_ "<empty>"
+ else
+ String.concat
+ (s_ ", ")
+ (List.map
+ (fun (cond, vl) ->
+ match printer with
+ | Some p -> p vl
+ | None -> s_ "<no printer>")
+ lst)
+ in
+ match name with
+ | Some nm ->
+ failwith
+ (Printf.sprintf
+ (f_ "No result for the choice list '%s': %s")
+ nm str_lst)
+ | None ->
+ failwith
+ (Printf.sprintf
+ (f_ "No result for a choice list: %s")
+ str_lst)
+ in
+ choose_aux (List.rev lst)
+
+end
+
+
+module BaseEnvLight = struct
+# 21 "/home/typhon/kamlo/oasis/src/base/BaseEnvLight.ml"
+
+ module MapString = Map.Make(String)
+
+ type t = string MapString.t
+
+ let default_filename =
+ Filename.concat
+ (Sys.getcwd ())
+ "setup.data"
+
+ let load ?(allow_empty=false) ?(filename=default_filename) () =
+ if Sys.file_exists filename then
+ begin
+ let chn =
+ open_in_bin filename
+ in
+ let st =
+ Stream.of_channel chn
+ in
+ let line =
+ ref 1
+ in
+ let st_line =
+ Stream.from
+ (fun _ ->
+ try
+ match Stream.next st with
+ | '\n' -> incr line; Some '\n'
+ | c -> Some c
+ with Stream.Failure -> None)
+ in
+ let lexer =
+ Genlex.make_lexer ["="] st_line
+ in
+ let rec read_file mp =
+ match Stream.npeek 3 lexer with
+ | [Genlex.Ident nm; Genlex.Kwd "="; Genlex.String value] ->
+ Stream.junk lexer;
+ Stream.junk lexer;
+ Stream.junk lexer;
+ read_file (MapString.add nm value mp)
+ | [] ->
+ mp
+ | _ ->
+ failwith
+ (Printf.sprintf
+ "Malformed data file '%s' line %d"
+ filename !line)
+ in
+ let mp =
+ read_file MapString.empty
+ in
+ close_in chn;
+ mp
+ end
+ else if allow_empty then
+ begin
+ MapString.empty
+ end
+ else
+ begin
+ failwith
+ (Printf.sprintf
+ "Unable to load environment, the file '%s' doesn't exist."
+ filename)
+ end
+
+ let var_get name env =
+ let rec var_expand str =
+ let buff =
+ Buffer.create ((String.length str) * 2)
+ in
+ Buffer.add_substitute
+ buff
+ (fun var ->
+ try
+ var_expand (MapString.find var env)
+ with Not_found ->
+ failwith
+ (Printf.sprintf
+ "No variable %s defined when trying to expand %S."
+ var
+ str))
+ str;
+ Buffer.contents buff
+ in
+ var_expand (MapString.find name env)
+
+ let var_choose lst env =
+ OASISExpr.choose
+ (fun nm -> var_get nm env)
+ lst
+end
+
+
+module MyOCamlbuildFindlib = struct
+# 21 "/home/typhon/kamlo/oasis/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml"
+
+ (** OCamlbuild extension, copied from
+ * http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild
+ * by N. Pouillard and others
+ *
+ * Updated on 2009/02/28
+ *
+ * Modified by Sylvain Le Gall
+ *)
+ open Ocamlbuild_plugin
+
+ (* these functions are not really officially exported *)
+ let run_and_read =
+ Ocamlbuild_pack.My_unix.run_and_read
+
+ let blank_sep_strings =
+ Ocamlbuild_pack.Lexers.blank_sep_strings
+
+ let split s ch =
+ let x =
+ ref []
+ in
+ let rec go s =
+ let pos =
+ String.index s ch
+ in
+ x := (String.before s pos)::!x;
+ go (String.after s (pos + 1))
+ in
+ try
+ go s
+ with Not_found -> !x
+
+ let split_nl s = split s '\n'
+
+ let before_space s =
+ try
+ String.before s (String.index s ' ')
+ with Not_found -> s
+
+ (* this lists all supported packages *)
+ let find_packages () =
+ List.map before_space (split_nl & run_and_read "ocamlfind list")
+
+ (* this is supposed to list available syntaxes, but I don't know how to do it. *)
+ let find_syntaxes () = ["camlp4o"; "camlp4r"]
+
+ (* ocamlfind command *)
+ let ocamlfind x = S[A"ocamlfind"; x]
+
+ let dispatch =
+ function
+ | Before_options ->
+ (* by using Before_options one let command line options have an higher priority *)
+ (* on the contrary using After_options will guarantee to have the higher priority *)
+ (* override default commands by ocamlfind ones *)
+ Options.ocamlc := ocamlfind & A"ocamlc";
+ Options.ocamlopt := ocamlfind & A"ocamlopt";
+ Options.ocamldep := ocamlfind & A"ocamldep";
+ Options.ocamldoc := ocamlfind & A"ocamldoc";
+ Options.ocamlmktop := ocamlfind & A"ocamlmktop"
+
+ | After_rules ->
+
+ (* When one link an OCaml library/binary/package, one should use -linkpkg *)
+ flag ["ocaml"; "link"; "program"] & A"-linkpkg";
+
+ (* For each ocamlfind package one inject the -package option when
+ * compiling, computing dependencies, generating documentation and
+ * linking. *)
+ List.iter
+ begin fun pkg ->
+ flag ["ocaml"; "compile"; "pkg_"^pkg] & S[A"-package"; A pkg];
+ flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S[A"-package"; A pkg];
+ flag ["ocaml"; "doc"; "pkg_"^pkg] & S[A"-package"; A pkg];
+ flag ["ocaml"; "link"; "pkg_"^pkg] & S[A"-package"; A pkg];
+ flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S[A"-package"; A pkg];
+ end
+ (find_packages ());
+
+ (* Like -package but for extensions syntax. Morover -syntax is useless
+ * when linking. *)
+ List.iter begin fun syntax ->
+ flag ["ocaml"; "compile"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
+ flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
+ flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
+ flag ["ocaml"; "infer_interface"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
+ end (find_syntaxes ());
+
+ (* The default "thread" tag is not compatible with ocamlfind.
+ * Indeed, the default rules add the "threads.cma" or "threads.cmxa"
+ * options when using this tag. When using the "-linkpkg" option with
+ * ocamlfind, this module will then be added twice on the command line.
+ *
+ * To solve this, one approach is to add the "-thread" option when using
+ * the "threads" package using the previous plugin.
+ *)
+ flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]);
+ flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
+ flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"])
+
+ | _ ->
+ ()
+
+end
+
+module MyOCamlbuildBase = struct
+# 21 "/home/typhon/kamlo/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
+
+ (** Base functions for writing myocamlbuild.ml
+ @author Sylvain Le Gall
+ *)
+
+
+
+ open Ocamlbuild_plugin
+
+ type dir = string
+ type file = string
+ type name = string
+ type tag = string
+
+# 55 "/home/typhon/kamlo/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
+
+ type t =
+ {
+ lib_ocaml: (name * dir list) list;
+ lib_c: (name * dir * file list) list;
+ flags: (tag list * (spec OASISExpr.choices)) list;
+ }
+
+ let env_filename =
+ Pathname.basename
+ BaseEnvLight.default_filename
+
+ let dispatch_combine lst =
+ fun e ->
+ List.iter
+ (fun dispatch -> dispatch e)
+ lst
+
+ let dispatch t e =
+ let env =
+ BaseEnvLight.load
+ ~filename:env_filename
+ ~allow_empty:true
+ ()
+ in
+ match e with
+ | Before_options ->
+ let no_trailing_dot s =
+ if String.length s >= 1 && s.[0] = '.' then
+ String.sub s 1 ((String.length s) - 1)
+ else
+ s
+ in
+ List.iter
+ (fun (opt, var) ->
+ try
+ opt := no_trailing_dot (BaseEnvLight.var_get var env)
+ with Not_found ->
+ Printf.eprintf "W: Cannot get variable %s" var)
+ [
+ Options.ext_obj, "ext_obj";
+ Options.ext_lib, "ext_lib";
+ Options.ext_dll, "ext_dll";
+ ]
+
+ | After_rules ->
+ (* Declare OCaml libraries *)
+ List.iter
+ (function
+ | lib, [] ->
+ ocaml_lib lib;
+ | lib, dir :: tl ->
+ ocaml_lib ~dir:dir lib;
+ List.iter
+ (fun dir ->
+ flag
+ ["ocaml"; "use_"^lib; "compile"]
+ (S[A"-I"; P dir]))
+ tl)
+ t.lib_ocaml;
+
+ (* Declare C libraries *)
+ List.iter
+ (fun (lib, dir, headers) ->
+ (* Handle C part of library *)
+ flag ["link"; "library"; "ocaml"; "byte"; "use_lib"^lib]
+ (S[A"-dllib"; A("-l"^lib); A"-cclib"; A("-l"^lib)]);
+
+ flag ["link"; "library"; "ocaml"; "native"; "use_lib"^lib]
+ (S[A"-cclib"; A("-l"^lib)]);
+
+ flag ["link"; "program"; "ocaml"; "byte"; "use_lib"^lib]
+ (S[A"-dllib"; A("dll"^lib)]);
+
+ (* When ocaml link something that use the C library, then one
+ need that file to be up to date.
+ *)
+ dep ["link"; "ocaml"; "use_lib"^lib]
+ [dir/"lib"^lib^"."^(!Options.ext_lib)];
+
+ (* TODO: be more specific about what depends on headers *)
+ (* Depends on .h files *)
+ dep ["compile"; "c"]
+ headers;
+
+ (* Setup search path for lib *)
+ flag ["link"; "ocaml"; "use_"^lib]
+ (S[A"-I"; P(dir)]);
+ )
+ t.lib_c;
+
+ (* Add flags *)
+ List.iter
+ (fun (tags, cond_specs) ->
+ let spec =
+ BaseEnvLight.var_choose cond_specs env
+ in
+ flag tags & spec)
+ t.flags
+ | _ ->
+ ()
+
+ let dispatch_default t =
+ dispatch_combine
+ [
+ dispatch t;
+ MyOCamlbuildFindlib.dispatch;
+ ]
+
+end
+
+
+open Ocamlbuild_plugin;;
+let package_default =
+ {
+ MyOCamlbuildBase.lib_ocaml = [("src/lwt-zmq", ["src"])];
+ lib_c = [];
+ flags =
+ [
+ (["oasis_executable_relay_byte"; "ocaml"; "link"; "byte"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_executable_relay_native"; "ocaml"; "link"; "native"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_executable_relay_byte"; "ocaml"; "ocamldep"; "byte"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_executable_relay_native"; "ocaml"; "ocamldep"; "native"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_executable_relay_byte"; "ocaml"; "compile"; "byte"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_executable_relay_native"; "ocaml"; "compile"; "native"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_library_lwt_zmq_byte"; "ocaml"; "link"; "byte"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_library_lwt_zmq_native"; "ocaml"; "link"; "native"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_library_lwt_zmq_byte"; "ocaml"; "ocamldep"; "byte"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_library_lwt_zmq_native"; "ocaml"; "ocamldep"; "native"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_library_lwt_zmq_byte"; "ocaml"; "compile"; "byte"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])]);
+ (["oasis_library_lwt_zmq_native"; "ocaml"; "compile"; "native"],
+ [(OASISExpr.EBool true, S [A "-w"; A "@a"])])
+ ];
+ }
+ ;;
+
+let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
+
+(* OASIS_STOP *)
+Ocamlbuild_plugin.dispatch dispatch_default;;
View
5,110 setup.ml
5,110 additions, 0 deletions not shown
Please sign in to comment.
Something went wrong with that request. Please try again.