Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added installer

  • Loading branch information...
commit 060dac35085c01eacc2d9eb769be53e555b6fd45 1 parent d205ff1
Ryland Degnan authored
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
9 README.md
@@ -18,14 +18,15 @@ Pretty docs [here](http://metadave.github.com/riak-ocaml-client/).
## Installation
```
-cd src
+./configure
make
+make install
+
# To test, run this:
+./configure --enable-tests
export RIAK_OCAML_TEST_IP="127.0.0.1"
export RIAK_OCAML_TEST_PORT=8087
-./RiakTests
-
-sudo make install
+make test
```
**Note**: Testing requires a running instance of Riak 1.2+. By default, it tries to connect to Riak on 127.0.0.1, port 8081. To override these values, simply export the following two environment variables:
View
26 _oasis
@@ -0,0 +1,26 @@
+OASISFormat: 0.3
+Name: riak
+Version: 0.9
+Synopsis: Riak OCaml Client
+Authors: Dave Parfitt
+License: Apache-2.0
+Plugins: META (0.3), DevFiles (0.3)
+PreBuildCommand: make -C src piqi
+
+Library riak
+ Path: src
+ BuildTools: ocamlbuild
+ Modules: Riak
+ BuildDepends: unix, piqi.runtime
+
+Executable test
+ Path: test
+ BuildTools: ocamlbuild
+ MainIs: test.ml
+ BuildDepends: unix, piqi.runtime, oUnit, riak
+ Install: false
+ Build$: flag(tests)
+
+Test main
+ Run$: flag(tests)
+ Command: $test
View
29 _tags
@@ -0,0 +1,29 @@
+# OASIS_START
+# DO NOT EDIT (digest: 69cf658f5ccb75e8806408cf016fc80e)
+# Ignore VCS directories, you can use the same kind of rule outside
+# OASIS_START/STOP if you want to exclude directories that contains
+# useless stuff for the build process
+<**/.svn>: -traverse
+<**/.svn>: not_hygienic
+".bzr": -traverse
+".bzr": not_hygienic
+".hg": -traverse
+".hg": not_hygienic
+".git": -traverse
+".git": not_hygienic
+"_darcs": -traverse
+"_darcs": not_hygienic
+# Library riak
+"src/riak.cmxs": use_riak
+<src/*.ml{,i}>: pkg_unix
+<src/*.ml{,i}>: pkg_piqi.runtime
+# Executable test
+"test/test.byte": use_riak
+"test/test.byte": pkg_unix
+"test/test.byte": pkg_piqi.runtime
+"test/test.byte": pkg_oUnit
+<test/*.ml{,i}>: use_riak
+<test/*.ml{,i}>: pkg_unix
+<test/*.ml{,i}>: pkg_piqi.runtime
+<test/*.ml{,i}>: pkg_oUnit
+# OASIS_STOP
View
27 configure
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# OASIS_START
+# DO NOT EDIT (digest: 425187ed8bfdbdd207fd76392dd243a7)
+set -e
+
+FST=true
+for i in "$@"; do
+ if $FST; then
+ set --
+ FST=false
+ fi
+
+ case $i in
+ --*=*)
+ ARG=${i%%=*}
+ VAL=${i##*=}
+ set -- "$@" "$ARG" "$VAL"
+ ;;
+ *)
+ set -- "$@" "$i"
+ ;;
+ esac
+done
+
+ocaml setup.ml -configure "$@"
+# OASIS_STOP
View
493 myocamlbuild.ml
@@ -0,0 +1,493 @@
+(* OASIS_START *)
+(* DO NOT EDIT (digest: d80de5b5ecc197b2ee95eed3f2ae70bc) *)
+module OASISGettext = struct
+# 21 "/Users/rdegnan/workspace/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 "/Users/rdegnan/workspace/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
+
+
+# 117 "myocamlbuild.ml"
+module BaseEnvLight = struct
+# 21 "/Users/rdegnan/workspace/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
+
+
+# 215 "myocamlbuild.ml"
+module MyOCamlbuildFindlib = struct
+# 21 "/Users/rdegnan/workspace/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 buf = Buffer.create 13 in
+ let x = ref [] in
+ let flush () =
+ x := (Buffer.contents buf) :: !x;
+ Buffer.clear buf
+ in
+ String.iter
+ (fun c ->
+ if c = ch then
+ flush ()
+ else
+ Buffer.add_char buf c)
+ s;
+ flush ();
+ List.rev !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"; "doc"] (S[A "-I"; A "+threads"]);
+ flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
+ flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"])
+
+ | _ ->
+ ()
+
+end
+
+module MyOCamlbuildBase = struct
+# 21 "/Users/rdegnan/workspace/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
+
+ (** Base functions for writing myocamlbuild.ml
+ @author Sylvain Le Gall
+ *)
+
+
+
+ open Ocamlbuild_plugin
+ module OC = Ocamlbuild_pack.Ocaml_compiler
+
+ type dir = string
+ type file = string
+ type name = string
+ type tag = string
+
+# 56 "/Users/rdegnan/workspace/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;
+ (* Replace the 'dir: include' from _tags by a precise interdepends in
+ * directory.
+ *)
+ includes: (dir * dir list) list;
+ }
+
+ let env_filename =
+ Pathname.basename
+ BaseEnvLight.default_filename
+
+ let dispatch_combine lst =
+ fun e ->
+ List.iter
+ (fun dispatch -> dispatch e)
+ lst
+
+ let tag_libstubs nm =
+ "use_lib"^nm^"_stubs"
+
+ let nm_libstubs nm =
+ nm^"_stubs"
+
+ 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
+ | nm, [] ->
+ ocaml_lib nm
+ | nm, dir :: tl ->
+ ocaml_lib ~dir:dir (dir^"/"^nm);
+ List.iter
+ (fun dir ->
+ List.iter
+ (fun str ->
+ flag ["ocaml"; "use_"^nm; str] (S[A"-I"; P dir]))
+ ["compile"; "infer_interface"; "doc"])
+ tl)
+ t.lib_ocaml;
+
+ (* Declare directories dependencies, replace "include" in _tags. *)
+ List.iter
+ (fun (dir, include_dirs) ->
+ Pathname.define_context dir include_dirs)
+ t.includes;
+
+ (* Declare C libraries *)
+ List.iter
+ (fun (lib, dir, headers) ->
+ (* Handle C part of library *)
+ flag ["link"; "library"; "ocaml"; "byte"; tag_libstubs lib]
+ (S[A"-dllib"; A("-l"^(nm_libstubs lib)); A"-cclib";
+ A("-l"^(nm_libstubs lib))]);
+
+ flag ["link"; "library"; "ocaml"; "native"; tag_libstubs lib]
+ (S[A"-cclib"; A("-l"^(nm_libstubs lib))]);
+
+ flag ["link"; "program"; "ocaml"; "byte"; tag_libstubs lib]
+ (S[A"-dllib"; A("dll"^(nm_libstubs lib))]);
+
+ (* When ocaml link something that use the C library, then one
+ need that file to be up to date.
+ *)
+ dep ["link"; "ocaml"; "program"; tag_libstubs lib]
+ [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
+
+ dep ["compile"; "ocaml"; "program"; tag_libstubs lib]
+ [dir/"lib"^(nm_libstubs 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
+
+
+# 478 "myocamlbuild.ml"
+open Ocamlbuild_plugin;;
+let package_default =
+ {
+ MyOCamlbuildBase.lib_ocaml = [("riak", ["src"])];
+ lib_c = [];
+ flags = [];
+ includes = [("test", ["src"])];
+ }
+ ;;
+
+let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
+
+# 492 "myocamlbuild.ml"
+(* OASIS_STOP *)
+Ocamlbuild_plugin.dispatch dispatch_default;;
View
6,168 setup.ml
6,168 additions, 0 deletions not shown
View
6 src/META
@@ -1,8 +1,12 @@
+# OASIS_START
+# DO NOT EDIT (digest: 70a652218dba687aef22dc6087ccad5c)
version = "0.9"
description = "Riak OCaml Client"
-requires = "unix"
+requires = "unix piqi.runtime"
archive(byte) = "riak.cma"
archive(byte, plugin) = "riak.cma"
archive(native) = "riak.cmxa"
archive(native, plugin) = "riak.cmxs"
exists_if = "riak.cma"
+# OASIS_STOP
+
View
52 src/Makefile
@@ -1,60 +1,8 @@
-all: piqi nonnative test
- @echo "Build complete"
-
-nonnative:
- ocamlfind ocamlc -a -package piqi.runtime riak_piqi.ml -o riak_piqi.cma
- ocamlfind ocamlc -a -package piqi.runtime riak_kv_piqi.ml -o riak_kv_piqi.cma
- ocamlfind ocamlc -a -package piqi.runtime riak_search_piqi.ml -o riak_search_piqi.cma
- ocamlfind ocamlc -c -package Unix -package piqi.runtime riak_piqi.cma riak_kv_piqi.cma riak_search_piqi.cma Riak.mli -o Riak.cmi
- ocamlfind ocamlc -a -package Unix -package piqi.runtime riak_piqi.cma riak_kv_piqi.cma riak_search_piqi.cma Riak.ml -o Riak.cma
-
-# Hey, sorry. Native doesn't compile right now. I don't feel like messing with the OCaml build system right
-# now. Please send me a pull request to fix this if you end up using native. Cheers, Dave.
-#native:
-# ocamlfind ocamlopt -a -package piqi.runtime riak_piqi.ml -o riak_piqi.cmxa
-# ocamlfind ocamlopt -a -package piqi.runtime riak_kv_piqi.ml -o riak_kv_piqi.cmxa
-# ocamlfind ocamlopt -a -package piqi.runtime riak_search_piqi.ml -o riak_search_piqi.cmxa
-# ocamlfind ocamlopt -c -package Unix -package piqi.runtime riak_piqi.cmxa riak_kv_piqi.cmxa riak_search_piqi.cmxa Riak.mli -o Riak.cmi
-# ocamlfind ocamlopt -a -package Unix -package piqi.runtime riak_piqi.cmxa riak_kv_piqi.cmxa riak_search_piqi.cmxa Riak.ml -o Riak.cmxa
-
-#ocamlfind ocamlopt -package Unix -package piqi.runtime riak_piqi.cmx riak_kv_piqi.cmx riak_search_piqi.cmx -c riak.ml
-
piqi:
piqi of-proto riak.proto
piqi of-proto riak_kv.proto
piqi of-proto riak_search.proto
cat riak.piqi.additions >> riak.proto.piqi
- # rename done to isdone. "done" is a keyword in OCaml
- # Note: the author of Piqi explained a different way to do this that I need
- # to apply
- # https://gist.github.com/3195858
- sed -i.orig -e"s/\.name done/\.name isdone \.proto-name \"done\""/ riak_kv.proto.piqi
piqic ocaml --pp riak.proto.piqi
piqic ocaml --pp riak_kv.proto.piqi
piqic ocaml --pp riak_search.proto.piqi
-
-test:
- ocamlfind ocamlc -o RiakTests -package Unix -package oUnit -package piqi.runtime \
- -linkpkg riak_piqi.cma riak_kv_piqi.cma riak_search_piqi.cma Riak.cma Test.ml
- @echo "You should now have a RiakTests executable in the src directory."
- @echo "To run the tests, export the following 2 variables to a running instance of Riak:"
- @echo "RIAK_OCAML_TEST_IP"
- @echo "RIAK_OCAML_TEST_PORT"
- @echo "Then run the RiakTest program"
-install:
- ocamlfind install riak META Riak.cmi Riak.cma Riak.mli riak_piqi.cma riak_kv_piqi.cma riak_search_piqi.cma
-
-install-test:
- ocamlfind ocamlc -o RiakTests -package Unix -package oUnit -package piqi.runtime -package riak -linkpkg Test.ml
-
-
-clean:
- rm -f *.cmo
- rm -f *.cma
- rm -f *.cmi
- rm -f *.cmx
- rm -f *.o
- rm -f *.proto.piqi
- rm -f riak_kv_piqi.ml
- rm -f riak_piqi.ml
- rm -f riak_search_piqi.ml
View
0  src/Test.ml → test/test.ml
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.