Skip to content

Commit

Permalink
Imported Upstream version 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdid committed Nov 4, 2011
1 parent 57d4bc9 commit 907ebfc
Show file tree
Hide file tree
Showing 196 changed files with 16,981 additions and 4,703 deletions.
6 changes: 6 additions & 0 deletions .gitignore
@@ -1,6 +1,7 @@
*~
_build
build/META
build/make_suite
src/batteries_config.ml
doc/batteries/html/api/
hdoc/*
Expand All @@ -11,3 +12,8 @@ man/*
*.swp
*.opt
*.run
apidocs
batteries.docdir
qtest/*_t.ml
qtest/test_mods.mllib
src/batCamomile.ml
33 changes: 32 additions & 1 deletion ChangeLog
@@ -1 +1,32 @@
Look in git log for list of changes
Look in git log for list of changes.

The command

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative

will print a nice change log showing commit ids like the following:

* 9d571fc - (HEAD, v1.4.0) Bump version to 1.4.0 (11 minutes ago)
* 0097761 - Merge in fixes from upstream camomile (8 days ago)
* a29bb96 - v1.4.0pre2 (tweaks to _oasis) (2 weeks ago)
* 1c65b81 - (github/v1.4.0) V1.4 iniital commit (2 weeks ago)
* 8926634 - (github/master) Forgot Bat prefix on substring, compile fix (3 weeks ago)

The following bash script generates a GNU-style ChangeLog file, if
that's your thing.

#!/bin/sh
# Convert git log to GNU-style ChangeLog file.
# (C) Chris
if test -d ".git"; then
git log --date-order --date=short | \
sed -e '/^commit.*$/d' | \
awk '/^Author/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' | \
sed -e 's/^Author: //g' | \
sed -e 's/>Date: \([0-9]*-[0-9]*-[0-9]*\)/>\t\1/g' | \
sed -e 's/^\(.*\) \(\)\t\(.*\)/\3 \1 \2/g' > ChangeLog
exit 0
else
echo "No git repository present."
exit 1
fi
654 changes: 465 additions & 189 deletions LICENSE

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions META.in
Expand Up @@ -34,6 +34,18 @@ package "pa_comprehension" (
)
)

package "pa_llist" (
descriptions = "lazy list syntax (container)"
version = "@VERSION@"
package "syntax" (
requires = "camlp4"
description = "lazy list syntax (syntax extension)"
version = "@VERSION@"
archive(syntax, preprocessor) = "pa_llist.cmo"
archive(syntax, toploop) = "pa_llist.cmo"
)
)

package "syntax" (
version = "@VERSION@"
description = "Standard extensions to the OCaml language, full package"
Expand All @@ -43,6 +55,6 @@ package "syntax" (
# we use a brute-force approach
requires = "camlp4, estring"
requires(toploop) = "camlp4, estring, batteries"
archive(syntax, preprocessor) = "pa_strings.cma pa_comprehension.cmo"
archive(syntax, toploop) = "pa_strings.cma pa_comprehension.cmo"
archive(syntax, preprocessor) = "pa_strings.cma pa_comprehension.cmo pa_llist.cmo"
archive(syntax, toploop) = "pa_strings.cma pa_comprehension.cmo pa_llist"
)
156 changes: 129 additions & 27 deletions Makefile
Expand Up @@ -3,72 +3,97 @@

NAME = batteries

# This is also defined in the VERSION file
VERSION := $(shell cat VERSION)
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')

# Define variables and export them for mkconf.ml
DOCROOT ?= /usr/share/doc/ocaml-batteries
export DOCROOT
BROWSER_COMMAND ?= x-www-browser %s
BROWSER_COMMAND ?= x-www-browser
export BROWSER_COMMAND

OCAMLBUILD ?= ocamlbuild
ifdef DESTDIR
OCAMLFIND_DEST += -destdir $(DESTDIR)
endif

BATTERIES_NATIVE ?= yes
BATTERIES_NATIVE_SHLIB ?= yes
OCAMLBUILD ?= ocamlbuild
OCAMLBUILDFLAGS ?= -no-links

ifeq ($(uname_S),Darwin)
BATTERIES_NATIVE ?= yes
BATTERIES_NATIVE_SHLIB ?= no
else
BATTERIES_NATIVE ?= yes
BATTERIES_NATIVE_SHLIB ?= $(BATTERIES_NATIVE)
endif

INSTALL_FILES = _build/META _build/src/*.cma \
battop.ml _build/src/*.cmi _build/src/*.mli \
_build/src/batteries_help.cmo \
_build/src/syntax/pa_comprehension/pa_comprehension.cmo \
_build/src/syntax/pa_strings/pa_strings.cma
_build/src/syntax/pa_strings/pa_strings.cma \
_build/src/syntax/pa_llist/pa_llist.cmo
NATIVE_INSTALL_FILES = _build/src/*.cmx _build/src/*.a _build/src/*.cmxa

# What to build
TARGETS = syntax.otarget byte.otarget src/batteries_help.cmo META
TEST_TARGETS = testsuite/main.byte
BENCH_TARGETS = benchsuite/bench_int.native benchsuite/bench_map.native
TEST_TARGET = test-byte

ifeq ($(BATTERIES_NATIVE_SHLIB), yes)
EXT = native
MODE = shared
TARGETS += shared.otarget
TEST_TARGETS += testsuite/main.native
TEST_TARGET = test-native
INSTALL_FILES += $(NATIVE_INSTALL_FILES) _build/src/*.cmxs
else ifeq ($(BATTERIES_NATIVE), yes)
EXT = native
MODE = native
TARGETS += native.otarget
TEST_TARGETS += testsuite/main.native
TEST-DEPS = test-native
INSTALL_FILES += $(NATIVE_INSTALL_FILES)
else
EXT = byte
MODE = bytecode
endif

.PHONY: all clean doc install uninstall reinstall test
.PHONY: all clean doc install uninstall reinstall test qtest camfail camfailunk

all:
test ! -e src/batteries_config.ml || rm src/batteries_config.ml
$(OCAMLBUILD) $(TARGETS)
all: src/batCamomile.ml
@echo "Build mode:" $(MODE)
$(OCAMLBUILD) $(OCAMLBUILDFLAGS) $(TARGETS)

clean:
rm -f apidocs
${RM} apidocs
${RM} qtest/*_t.ml qtest/test_mods.mllib
${RM} src/batteries_config.ml
${RM} src/batCamomile.ml
$(OCAMLBUILD) -clean

doc:
$(OCAMLBUILD) batteries.docdir/index.html
test -e apidocs || ln -s _build/batteries.docdir apidocs

install: all
ocamlfind install estring libs/estring/META \
install: all uninstall_packages
ocamlfind install $(OCAMLFIND_DEST) estring \
libs/estring/META \
_build/libs/estring/*.cmo \
_build/libs/estring/*.cmi \
_build/libs/estring/*.mli
ocamlfind install $(NAME) $(INSTALL_FILES)
ocamlfind install $(OCAMLFIND_DEST) $(NAME) $(INSTALL_FILES)

uninstall:
ocamlfind remove estring
ocamlfind remove $(NAME)
rm -rf $(DOCROOT)
uninstall_packages:
ocamlfind remove $(OCAMLFIND_DEST) estring
ocamlfind remove $(OCAMLFIND_DEST) $(NAME)

uninstall: uninstall_packages
${RM} -r $(DOCROOT)

install-doc: doc
mkdir -p $(DOCROOT)
cp -r doc/batteries/* $(DOCROOT)
# deal with symlink that will break
rm -f $(DOCROOT)/html/batteries_large.png
# deal with symlink that will break
${RM} $(DOCROOT)/html/batteries_large.png
cp -f doc/batteries_large.png $(DOCROOT)/html
mkdir -p $(DOCROOT)/html/api
cp apidocs/* $(DOCROOT)/html/api
Expand All @@ -78,10 +103,87 @@ reinstall:
$(MAKE) uninstall
$(MAKE) install

test:
$(OCAMLBUILD) $(TARGETS) $(TEST_TARGETS)
$(foreach TEST, $(TEST_TARGETS), _build/$(TEST); )
#List of source files that it's okay to try to test
DONTTEST=$(wildcard src/batCamomile-*.ml) src/batteries_help.ml
TESTABLE ?= $(filter-out $(DONTTEST), $(wildcard src/*.ml))

TESTDEPS = src/batCamomile.ml $(patsubst src/%.ml,qtest/%_t.ml, $(TESTABLE)) qtest/test_mods.mllib

_build/testsuite/main.byte _build/qtest/test_runner.byte: $(TESTDEPS)
$(OCAMLBUILD) $(OCAMLBUILDFLAGS) testsuite/main.byte qtest/test_runner.byte

release: test
_build/testsuite/main.native _build/qtest/test_runner.native: $(TESTDEPS)
$(OCAMLBUILD) $(OCAMLBUILDFLAGS) testsuite/main.byte qtest/test_runner.byte testsuite/main.native qtest/test_runner.native

test-byte: _build/testsuite/main.byte _build/qtest/test_runner.byte
_build/testsuite/main.byte
_build/qtest/test_runner.byte

test-native: _build/testsuite/main.native _build/qtest/test_runner.native
_build/testsuite/main.byte
_build/qtest/test_runner.byte
_build/testsuite/main.native
_build/qtest/test_runner.native

test: $(TEST_TARGET)

bench:
$(OCAMLBUILD) $(OCAMLBUILDFLAGS) $(TARGETS) $(BENCH_TARGETS)
$(foreach BENCH, $(BENCH_TARGETS), _build/$(BENCH); )

release: clean all test
git archive --format=tar --prefix=batteries-$(VERSION)/ HEAD \
| gzip > batteries-$(VERSION).tar.gz


##
## Magic to detect which version of camomile is installed
##

CAMVER=$(shell sh -c 'ocamlfind query -format %v camomile')
ifeq ($(CAMVER),0.8.2)
CAMFIX=src/batCamomile-0.8.2.ml
endif
ifeq ($(CAMVER),0.8.1)
CAMFIX=src/batCamomile-0.8.1.ml
endif
ifeq ($(CAMVER),0.7.2)
CAMFIX=src/batCamomile-0.7.ml
endif
ifeq ($(CAMVER),0.7.1)
CAMFIX=src/batCamomile-0.7.ml
endif
ifeq ($(CAMVER),)
CAMFIX=camfail
endif
ifeq ($(CAMFIX),) # Assume is compatible with the latest camomile, TODO: warn user about assumption
CAMFIX=src/batCamomile-0.8.2.ml
endif

src/batCamomile.ml: $(CAMFIX)
cp -f $< $@

camfailunk:
echo "Unknown build of camomile detected ( $(CAMVER) ), cannot auto-config batcamomile."
echo "If your camomile is more recent than 0.8.3, you can probably do"
echo " cp src/batCamomile-0.8.2.ml src/batCamomile.ml"
echo "and everything will work fine."
exit 1

##
## Magic for test target - auto-generated test files from source comments
##

_build/build/make_suite.$(EXT): build/make_suite.mll
$(OCAMLBUILD) $(OCAMLBUILDFLAGS) make_suite.$(EXT)

#convert a source file to a test suite by filtering special comments
qtest/%_t.ml: src/%.ml _build/build/make_suite.$(EXT)
_build/build/make_suite.$(EXT) $< > $@

#put all the testing modules in a library
qtest/test_mods.mllib:
/bin/echo -n "Quickcheck Tests " > $@
echo $(patsubst src/%.ml,%_t, $(TESTABLE)) >> $@

.PHONY: qtest/test_mods.mllib
77 changes: 1 addition & 76 deletions README
@@ -1,76 +1 @@
*** Welcome to Batteries Included ***

OCaml Batteries Included: the community-maintained foundation library
for your OCaml projects.


Batteries Included serves the following purposes:
* define a standard set of libraries which may be
expected on every compliant installation of OCaml
* organize these libraries into a hierarchy of modules,
with one source of documentation
* provide a consistent API for otherwise independent
libraries.

*** Building Batteries Included ***

**** Requirements ****
You will need
* OCaml >= 3.11
* Findlib >= 1.2.5 (http://projects.camlcity.org/projects/findlib.html/)
* make (optional; aids build and installation)
* Camomile >= 0.7 (http://camomile.sourceforge.net/)
* OUnit to build and run the tests

**** Configuration and installation ****

To install the full version of OCaml Batteries Included, execute

$ make all
$ make test [ optional ]
$ sudo make install

$ make doc [ optional ]
$ sudo make install-doc [ optional ]

If you want the documentation installed elsewhere, set this *before*
starting the build process (it becomes part of batteries_config.ml).

$ export DOCROOT=/path/to/new/docroot/

If you want findlib to use a -destdir argument to [ocamlfind install], set

$ export DESTDIR=/path/to/findlib/dest

To disable native compilation:

$ export BATTERIES_NATIVE=false

To disable building of native shared libraries:

$ export BATTERIES_NATIVE_SHLIB=false

*** Using Batteries ***

To get started using Batteries at the toplevel, copy the ocamlinit
file to ~/.ocamlinit:

$ cp ocamlinit ~/.ocamlinit

If you already have findlib in your ~/.ocamlinit, you only need the
last line in our ocamlinit to load batteries.

*** ExtLib Compatibility ***

If your project currently uses ExtLib, most likely you can just change
[-package extlib] to [-package batteries] and add [open Extlibcompat]
to the top of any extlib-using modules. Batteries' modules are all
named BatFoo to differentiate them from extlib's modules, so one can
use Batteries and ExtLib in the same project.

COMPATIBILITY NOTE: If you're using ExtLib's Unzip module, it does not
have a corresponding module in batteries at the moment.

*** Extending Batteries Included ***

See doc/batteries/GUIDELINES
See README.md
2 changes: 1 addition & 1 deletion README.folders
Expand Up @@ -2,7 +2,7 @@ The following directories contain:

* build/ various (old) files needed for building
* examples/ example files showing how to use various features of batteries
* hdoc/ the html documentation
* apidocs/ the html documentation
* src/ the core of Batteries Included, all the batFoo modules
* src/syntax/ several syntax extensions for OCaml
* testsuite/ a minimal testsuite for batteries
Expand Down

0 comments on commit 907ebfc

Please sign in to comment.