Skip to content
Browse files

Added fieldlib rules and sample binary

  • Loading branch information...
1 parent 7f5b049 commit 8ba7e13b3ebb397f1bb576d615a356c1a9fab52d @adept committed Oct 21, 2011
Showing with 51 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. BIN .tup/db
  3. +11 −0 fieldslib/lib/Tupfile
  4. +3 −0 fieldslib/syntax/Tupfile
  5. +18 −0 foobar/Tupfile
  6. +13 −0 foobar/foobar.ml
  7. +2 −0 lib/Tupfile
  8. +3 −2 sexplib/lib/Tupfile
View
1 .gitignore
@@ -4,3 +4,4 @@
/sexplib/lib/lexer.ml
/sexplib/lib/parser.ml
/sexplib/lib/parser.mli
+/foobar/foobar
View
BIN .tup/db
Binary file not shown.
View
11 fieldslib/lib/Tupfile
@@ -0,0 +1,11 @@
+include_rules
+
+# Building library modules
+: field.mli |> !byte_i |>
+: field.ml | field.cmi |> !byte_o |> {cmo}
+
+# Producing library
+: {cmo} |> ocamlc -pack %f -o %o |> fieldslib.cmo | fieldslib.cmi
+: fieldslib.cmo |> ocamlc -a %f -o %o |> fieldslib.cma
+
+# Now i want to install fieldlib.cma to $(LIBDIR)/fieldlib/fieldlib.cma but dont know how
View
3 fieldslib/syntax/Tupfile
@@ -0,0 +1,3 @@
+include_rules
+: pa_fields_conv.mli |> !byte_pp |> pa_fields_conv.cmi
+: pa_fields_conv.ml | $(LIBDIR)/pa_type_conv.cmi pa_fields_conv.cmi |> !byte_pp |> pa_fields_conv.cmo
View
18 foobar/Tupfile
@@ -0,0 +1,18 @@
+include_rules
+
+# Sample binary that uses sexplib and fieldslib
+
+# I'd rather have syntax extension installed to LIBDIR, but can't do that due to circular deps(?!) which I think not really there
+OCAMLC_FLAGS += -pp 'camlp4o -I $(LIBDIR) -I $(TOP)/sexplib/syntax -I $(TOP)/fieldslib/syntax pa_type_conv.cmo pa_sexp_conv.cmo pa_fields_conv.cmo'
+
+# I'd rather install my libraries (.cma) in subdirectories under LIBDIR, but I dont know how. Until then, I'll reference them via search path
+SEXP=$(TOP)/sexplib/lib
+FLDS=$(TOP)/fieldslib/lib
+OCAMLC_FLAGS += -I $(SEXP) -I $(FLDS)
+
+# Compile binary
+: foobar.ml | $(TOP)/sexplib/syntax/pa_sexp_conv.cmo $(LIBDIR)/pa_type_conv.cmo $(TOP)/fieldslib/syntax/pa_fields_conv.cmo $(FLDS)/fieldslib.cm* $(SEXP)/sexplib.cm* |> !byte_io |> foobar.cmo
+
+# Link binary
+OCAMLC_FLAGS =
+: $(SEXP)/sexplib.cma $(FLDS)/fieldslib.cma foobar.cmo |> ocamlc -o %o /usr/lib/ocaml/bigarray.cma /usr/lib/ocaml/unix.cma /usr/lib/ocaml/nums.cma %f |> foobar
View
13 foobar/foobar.ml
@@ -0,0 +1,13 @@
+open Sexplib
+open Conv
+
+type t = {
+ a : int;
+ b : string;
+ } with sexp, fields
+
+let _ =
+ let foo = { a = 1; b="foo" } in
+ let bar = { a = 2; b="bar" } in
+ Printf.printf "foo=%s\n" (Sexp.to_string (sexp_of_t foo));
+ Printf.printf "bar=%s\n" (Sexp.to_string (sexp_of_t bar));
View
2 lib/Tupfile
@@ -6,3 +6,5 @@ include_rules
# Those cause circular dependecy - why?
#: $(TOP)/sexplib/syntax/pa_sexp_conv.cmi |> cp %f %o |> pa_sexp_conv.cmi
#: $(TOP)/sexplib/syntax/pa_sexp_conv.cmo |> cp %f %o |> pa_sexp_conv.cmo
+#: $(TOP)/fieldslib/syntax/pa_fields_conv.cmi |> cp %f %o |> pa_fields_conv.cmi
+#: $(TOP)/fieldslib/syntax/pa_fields_conv.cmo |> cp %f %o |> pa_fields_conv.cmo
View
5 sexplib/lib/Tupfile
@@ -17,7 +17,7 @@ include_rules
# It would be nice to avoid such manual management of flags and be able to set flags for one specific command only
OCAMLC_FLAGS_BAK = $(OCAMLC_FLAGS)
-OCAMLC_FLAGS += -pp cpp
+OCAMLC_FLAGS += -pp 'cpp -traditional -undef'
: pre_sexp.ml | lexer.cmi |> !byte_io |> {cmo}
OCAMLC_FLAGS = $(OCAMLC_FLAGS_BAK)
@@ -39,6 +39,7 @@ OCAMLC_FLAGS = $(OCAMLC_FLAGS_BAK)
: std.ml | conv.cmi |> !byte_io |> {cmo}
-: {cmo} |> ocamlc -a -o %o %f |> sexplib.cma
+: {cmo} | conv_error.cmi std.cmi |> ocamlc -pack %f -o %o |> sexplib.cmo | sexplib.cmi
+: sexplib.cmo |> ocamlc -a %f -o %o |> sexplib.cma
# Now I would like to "install" .cma to $(LIBDIR)/sexplib/sexplib.cma, but apparently I can't create sexplib subdir on the fly :(

0 comments on commit 8ba7e13

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