Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

do.ml → oasis: all features transferred.

  • Loading branch information...
commit fd40b22f39f4a46113fab96d76a8055d2fccebef 1 parent 054d176
@Chris00 Chris00 authored
View
2  .gitignore
@@ -12,8 +12,6 @@ setup.log
.#*
#*
TAGS
-_tags
-Makefile
configure
src/lib/META
src/lib/doclib.odocl
View
70 Makefile
@@ -0,0 +1,70 @@
+# 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
+
+.PHONE: pre-distclean
+distclean: pre-distclean
+
+pre-distclean:
+ $(RM) setup.data setup.log
+ $(RM) configure
+ $(RM) src/lib/META
+ $(RM) src/lib/libbiocaml_stubs.clib
+ $(RM) src/lib/doclib.odocl
+ $(RM) src/lib/biocaml.mllib
+ $(RM) TAGS
+
+TAGS:
+ otags -o TAGS `find src -regex ".*\.ml"`
+
+CURR_DIR=$(shell basename $(CURDIR))
+PKG=biocaml
+VERSION=$(shell grep Version _oasis | cut -d' ' -f6)
+PKG_VERSION=$(PKG)-$(VERSION)
+INSTALL_FILES=Changes INSTALL LICENSE Makefile README.md TAGS _oasis _tags configure myocamlbuild.ml setup.ml doc src
+.PHONY: dist
+dist:
+ oasis setup
+ perl -pi -e 's#$(HOME)##g' myocamlbuild.ml setup.ml
+ make doc
+ mkdir doc
+ mv _build/src/lib/doclib.docdir doc/html
+ make TAGS
+ cd .. ; mv $(CURR_DIR) $(PKG_VERSION); tar czf $(PKG_VERSION).tgz $(patsubst %,$(PKG_VERSION)/%,$(INSTALL_FILES)); mv $(PKG_VERSION) $(CURR_DIR)
+ cd .. ; md5sum $(PKG_VERSION).tgz > $(PKG_VERSION).tgz.md5
+ rm -rf doc
View
4 _tags
@@ -0,0 +1,4 @@
+# OASIS_START
+# OASIS_STOP
+
+true: annot
View
136 do.ml
@@ -1,136 +0,0 @@
-#! /usr/bin/env ocaml
-
-#use "topfind"
-#thread
-#require "core_extended"
-open Core.Std
-
-open Printf
-
-let command fmt =
- let f x =
- printf "Running %S\n%!" x;
- ignore (Sys.command x)
- in
- ksprintf f fmt
-
-let command_stdout fmt =
- let f x =
- printf "Running %S\n%!" x;
- let res = Core_extended.Shell.sh_full ~echo:false "%s" x in
- res
- in
- ksprintf f fmt
-
-let remove file =
- match Sys.file_exists file with
- | `Yes ->
- Sys.remove file;
- printf "Removed %s\n%!" file;
- | `No | `Unknown ->
- printf "No %s to remove\n%!" file
-
-let rec keep_until last = function
- | [] | [_] -> []
- | a :: tl -> if a = last then [a] else a :: keep_until last tl
-
-
-let usage ch =
- fprintf ch "usage: %s {-help,-h,help,<cmd>}\n" Sys.argv.(0)
-
-let help_commands = ref []
-let add_help name descr = help_commands := (name, descr) :: !help_commands
-let help () =
- usage stdout;
- printf "where cmd is:\n";
- List.iter (List.rev !help_commands) (fun (name, descr) ->
- printf " %s\n " name;
- String.iter ~f:(function '\n' -> printf " \n" | c -> printf "%c" c) descr;
- printf "\n"
- );
- ()
-
-let check_cwd () =
- if Sys.file_exists "src/lib/biocaml.ml" = `No then
- failwith "Wrong working directory: There is no src/lib/biocaml.ml file"
-
-let setup_clean () =
- check_cwd ();
- command "oasis setup-clean";
- remove "setup.data";
- remove "setup.log";
- remove "_tags";
- remove "Makefile";
- remove "configure";
- remove "src/lib/META";
- remove "src/lib/libbiocaml_stubs.clib";
- remove "src/lib/doclib.odocl";
- remove "src/lib/biocaml.mllib";
- remove "setup.ml";
- remove "_oasis";
- remove "TAGS"
-
-
-let camlzip_findlib_name() =
- match command_stdout "ocamlfind list | grep zip" with
- | s when String.is_prefix s ~prefix:"zip" -> "zip"
- | s when String.is_prefix s ~prefix:"camlzip" -> "camlzip"
- | any -> failwithf "Cannot find Camlzip findlib name: %S" any ()
-
-let setup () =
- check_cwd ();
- setup_clean ();
- command "sed 's/camlzip_findlib/%s/' src/etc/oasis.in > _oasis"
- (camlzip_findlib_name());
- command "oasis setup";
- command "echo 'true: annot' >> _tags";
- command "cat src/etc/Makefile.post >> Makefile";
- let myocamlbuild = keep_until "(* OASIS_STOP *)"
- (In_channel.read_lines "myocamlbuild.ml") in
- let myocamlbuild_post = In_channel.read_lines "src/etc/myocamlbuild.post.ml" in
- Out_channel.write_lines "myocamlbuild.ml" (myocamlbuild @ myocamlbuild_post)
-
-let ocaml_toplevel () =
- let tmp = Filename.temp_file "ocamlinit" ".ml" in
- let o = open_out tmp in
- fprintf o "
-#use \"topfind\";;
-#thread;;
-#require \"core, %s, sqlite3, unix, batteries, xmlm\"
-#directory \"_build/src/lib\";;
-#load \"biocaml.cma\";;
-open Core.Std;;
-" (camlzip_findlib_name());
- close_out o;
- command "ocaml -init %s" tmp
-
-let () =
- add_help "setup" "Run oasis setup + customizations";
- add_help "setup-clean" "Really clean oasis-generated files";
- add_help "clean all" "Run make clean and setup-clean";
- add_help "configure [ARGS]" "Run ocaml setup.ml -configure ARGS";
- add_help "{build,make} [ARGS]" "Run make ARGS";
- add_help "install" "Force re-installation";
- add_help "top" "Run a toplevel with the latest built biocaml.cma";
- add_help "{test,tests}" "Run the tests\n";
- match List.tl_exn (Array.to_list Sys.argv) with
- | [] -> usage stdout
- | "-help" :: _ | "--help" :: _ | "-h" :: _ | "help" :: _ -> help ()
- | "setup" :: [] -> setup ()
- | "setup-clean" :: [] -> setup_clean ()
- | "clean" :: "all" :: [] -> command "make clean"; setup_clean ()
- | "configure" :: l ->
- command "ocaml setup.ml -configure %s"
- (String.concat ~sep:" " (List.map l (sprintf "%S")))
- | "build" :: args
- | "make" :: args ->
- command "make %s" (String.concat ~sep:" " (List.map args (sprintf "%S")))
- | "doc" :: args ->
- command "make doc%s" (String.concat ~sep:"" (List.map args (sprintf " %S")))
- | "install" :: [] ->
- command "ocamlfind remove biocaml";
- command "ocaml setup.ml -reinstall";
- | "top" :: [] -> ocaml_toplevel ()
- | "test" :: [] | "tests" :: [] -> command "ocaml setup.ml -test"
- | h :: _ -> eprintf "Cannot understand %s\n" h; usage stderr
-
View
23 src/etc/Makefile.post
@@ -1,23 +0,0 @@
-
-# Following content from Makefile.post file. Do not modify unless you
-# are in that file directly.
-
-TAGS:
- otags -o TAGS `find src -regex ".*\.ml"`
-
-CURR_DIR=$(shell basename $(CURDIR))
-PKG=biocaml
-VERSION=$(shell grep Version _oasis | cut -d' ' -f6)
-PKG_VERSION=$(PKG)-$(VERSION)
-INSTALL_FILES=Changes INSTALL LICENSE Makefile README.md TAGS _oasis _tags configure myocamlbuild.ml setup.ml doc src
-.PHONY: dist
-dist:
- oasis setup
- perl -pi -e 's#$(HOME)##g' myocamlbuild.ml setup.ml
- make doc
- mkdir doc
- mv _build/src/lib/doclib.docdir doc/html
- make TAGS
- cd .. ; mv $(CURR_DIR) $(PKG_VERSION); tar czf $(PKG_VERSION).tgz $(patsubst %,$(PKG_VERSION)/%,$(INSTALL_FILES)); mv $(PKG_VERSION) $(CURR_DIR)
- cd .. ; md5sum $(PKG_VERSION).tgz > $(PKG_VERSION).tgz.md5
- rm -rf doc
View
52 toplevel.ml
@@ -0,0 +1,52 @@
+#! /usr/bin/env ocaml
+
+#use "topfind"
+#thread
+#require "core"
+open Core.Std
+open Printf
+
+let setup_data_fn = "setup.data"
+let biocaml_dir = "_build/src/lib"
+
+let command fmt =
+ let f x =
+ printf "Running %S\n%!" x;
+ ignore (Sys.command x)
+ in
+ ksprintf f fmt
+
+let start_with s p =
+ let len_p = String.length p in
+ String.length s >= len_p && String.sub s 0 len_p = p
+
+let camlzip_findlib_name =
+ if Sys.file_exists setup_data_fn = `No then (
+ printf "%S not found. Run \"ocaml setup.ml -configure\" first.\n"
+ setup_data_fn;
+ exit 1
+ );
+ let data = In_channel.read_lines setup_data_fn in
+ let is_zip = List.exists data (fun l -> start_with l "pkg_zip") in
+ if is_zip then "zip" else "camlzip"
+
+
+let () =
+ let lib = Filename.concat biocaml_dir "biocaml.cma" in
+ if Sys.file_exists lib = `No then (
+ printf "%S not found. Please compile the library first.\n" lib;
+ exit 1
+ );
+ let tmp = Filename.temp_file "ocamlinit" ".ml" in
+ let o = open_out tmp in
+ fprintf o "
+#use \"topfind\";;
+#thread;;
+#require \"core, %s, sqlite3, unix, batteries, xmlm\"
+#directory %S;;
+#load \"biocaml.cma\";;
+open Core.Std;;
+" camlzip_findlib_name biocaml_dir;
+ close_out o;
+ command "ocaml -init %s" tmp;
+ Sys.remove tmp
Please sign in to comment.
Something went wrong with that request. Please try again.