move to jbuilder (closes #165)

This commit is contained in:
Simon Cruanes 2018-01-14 17:15:40 -06:00
parent 2c9a1d70c9
commit 8f46fdb6d2
25 changed files with 218 additions and 573 deletions

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ TAGS
setup.* setup.*
qtest* qtest*
*.html *.html
.merlin

23
.merlin
View file

@ -1,23 +0,0 @@
S src/core
S src/data/
S src/iter/
S src/sexp/
S src/threads/
S src/string
S src/monomorphic
S benchs
S examples
S tests
B _build/src/**
B _build/benchs
B _build/examples
B _build/tests
PKG oUnit
PKG benchmark
PKG result
PKG threads
PKG threads.posix
PKG lwt
PKG qcheck
FLG -w +a-4-44-48-60@8
FLG -open CCMonomorphic

137
Makefile
View file

@ -1,135 +1,34 @@
# OASIS_START # OASIS_START
# DO NOT EDIT (digest: 4c293511860bb966e727ba6f0ecc8197) # DO NOT EDIT (digest: 4c293511860bb966e727ba6f0ecc8197)
SETUP = ./setup.exe all: build test
build: setup.data $(SETUP) build:
$(SETUP) -build $(BUILDFLAGS) jbuilder build @install
doc: setup.data $(SETUP) build test:
$(SETUP) -doc $(DOCFLAGS) jbuilder runtest --no-buffer
test: setup.data $(SETUP) build clean:
$(SETUP) -test $(TESTFLAGS) jbuilder clean
all: $(SETUP) doc:
$(SETUP) -all $(ALLFLAGS) jbuilder build @doc
install: setup.data $(SETUP) BENCH_TARGETS=run_benchs.exe run_bench_hash.exe
$(SETUP) -install $(INSTALLFLAGS)
uninstall: setup.data $(SETUP) benchs:
$(SETUP) -uninstall $(UNINSTALLFLAGS) jbuilder build $(addprefix bench/, $(BENCH_TARGETS))
reinstall: setup.data $(SETUP) examples:
$(SETUP) -reinstall $(REINSTALLFLAGS) jbuilder build examples/id_sexp.exe
clean: $(SETUP) VERSION=$(shell awk '/^version:/ {print $$2}' containers.opam)
$(SETUP) -clean $(CLEANFLAGS)
distclean: $(SETUP)
$(SETUP) -distclean $(DISTCLEANFLAGS)
$(RM) $(SETUP)
setup.data: $(SETUP)
$(SETUP) -configure $(CONFIGUREFLAGS)
configure: $(SETUP)
$(SETUP) -configure $(CONFIGUREFLAGS)
setup.exe: setup.ml _oasis
ocamlfind ocamlopt -o $@ -linkpkg -package oasis.dynrun setup.ml || ocamlfind ocamlc -o $@ -linkpkg -package oasis.dynrun setup.ml || true
$(RM) setup.cmi setup.cmo setup.cmx setup.o
.PHONY: build doc test all install uninstall reinstall clean distclean configure
# OASIS_STOP
EXAMPLES = examples/mem_size.native examples/collatz.native \
examples/bencode_write.native # examples/crawl.native
OPTIONS = -use-ocamlfind -I _build
examples: all
ocamlbuild $(OPTIONS) -package unix -I . $(EXAMPLES)
push_doc: doc
rsync -tavu containers.docdir/* cedeela.fr:~/simon/root/software/containers/
push_doc_gh: doc
git checkout gh-pages && \
rm -rf dev/ && \
mkdir -p dev && \
cp -r containers.docdir/* dev/ && \
git add --all dev
DONTTEST=myocamlbuild.ml setup.ml $(wildcard src/**/*.cppo.*) $(wildcard src/**/*Labels*)
QTESTABLE=$(filter-out $(DONTTEST), \
$(wildcard src/core/*.ml) \
$(wildcard src/core/*.mli) \
$(wildcard src/data/*.ml) \
$(wildcard src/data/*.mli) \
$(wildcard src/string/*.ml) \
$(wildcard src/string/*.mli) \
$(wildcard src/unix/*.ml) \
$(wildcard src/unix/*.mli) \
$(wildcard src/sexp/*.ml) \
$(wildcard src/sexp/*.mli) \
$(wildcard src/iter/*.ml) \
$(wildcard src/iter/*.mli) \
$(wildcard src/bigarray/*.ml) \
$(wildcard src/bigarray/*.mli) \
$(wildcard src/threads/*.ml) \
$(wildcard src/threads/*.mli) \
)
qtest-clean:
@rm -rf qtest/
QTEST_PREAMBLE='open CCFun;; '
#qtest-build: qtest-clean build
# @mkdir -p qtest
# @qtest extract --preamble $(QTEST_PREAMBLE) \
# -o qtest/qtest_all.ml \
# $(QTESTABLE) 2> /dev/null
# @ocamlbuild $(OPTIONS) -pkg oUnit,QTest2Lib,ocamlbuildlib \
# -I core -I misc -I string \
# qtest/qtest_all.native
qtest-gen:
@mkdir -p qtest
@if which qtest > /dev/null ; then \
qtest extract --preamble $(QTEST_PREAMBLE) \
-o qtest/run_qtest.ml \
$(QTESTABLE) 2> /dev/null ; \
else touch qtest/run_qtest.ml ; \
fi
push-stable:
git checkout stable
git merge master -m 'merge from master'
oasis setup
git commit -a -m 'oasis files'
git push origin
git checkout master
clean-generated:
rm **/*.{mldylib,mlpack,mllib} myocamlbuild.ml -f
tags:
otags *.ml *.mli
VERSION=$(shell awk '/^Version:/ {print $$2}' _oasis)
update_next_tag: update_next_tag:
@echo "update version to $(VERSION)..." @echo "update version to $(VERSION)..."
zsh -c 'sed -i "s/NEXT_VERSION/$(VERSION)/g" **/*.ml **/*.mli' sed -i "s/NEXT_VERSION/$(VERSION)/g" src/*.ml src/*.mli
zsh -c 'sed -i "s/NEXT_RELEASE/$(VERSION)/g" **/*.ml **/*.mli' sed -i "s/NEXT_RELEASE/$(VERSION)/g" src/*.ml src/*.mli
devel:
./configure --enable-bench --enable-tests --enable-unix \
--enable-thread
make all
watch: watch:
while find src/ benchs/ -print0 | xargs -0 inotifywait -e delete_self -e modify ; do \ while find src/ benchs/ -print0 | xargs -0 inotifywait -e delete_self -e modify ; do \
@ -142,4 +41,4 @@ reindent:
@find src '(' -name '*.ml' -or -name '*.mli' ')' -type f -print0 | xargs -0 echo "reindenting: " @find src '(' -name '*.ml' -or -name '*.mli' ')' -type f -print0 | xargs -0 echo "reindenting: "
@find src '(' -name '*.ml' -or -name '*.mli' ')' -type f -print0 | xargs -0 ocp-indent -i @find src '(' -name '*.ml' -or -name '*.mli' ')' -type f -print0 | xargs -0 ocp-indent -i
.PHONY: examples push_doc tags qtest-gen qtest-clean devel update_next_tag .PHONY: all test clean build doc update_next_tag watch

169
_oasis
View file

@ -1,169 +0,0 @@
OASISFormat: 0.4
Name: containers
Version: 1.5.2
Homepage: https://github.com/c-cube/ocaml-containers
Authors: Simon Cruanes
License: BSD-2-clause
LicenseFile: LICENSE
Plugins: META (0.3), DevFiles (0.3)
OCamlVersion: >= 4.00.1
BuildTools: ocamlbuild
AlphaFeatures: compiled_setup_ml, ocamlbuild_more_args
# cygwin fails with anything else
XOCamlbuildExtraArgs: "-j 1"
Synopsis: A modular standard library focused on data structures.
Description:
Containers is a standard library (BSD license) focused on data structures,
combinators and iterators, without dependencies on unix. Every module is
independent and is prefixed with 'CC' in the global namespace. Some modules
extend the stdlib (e.g. CCList provides safe map/fold_right/append, and
additional functions on lists).
It also features optional libraries for dealing with strings, and
helpers for unix and threads.
Flag "unix"
Description: Build the containers.unix library (depends on Unix)
Default: true
Flag "thread"
Description: Build modules that depend on threads
Default: true
Flag "bench"
Description: Build and run benchmarks
Default: true
Library "containers"
Path: src/core
Modules: CCVector, CCHeap, CCList, CCOpt, CCPair,
CCFun, CCHash, CCInt, CCBool, CCFloat, CCArray, CCRef, CCSet,
CCOrd, CCRandom, CCString, CCHashtbl, CCMap, CCFormat, CCIO,
CCInt64, CCChar, CCResult, CCParse, CCArray_slice,
CCListLabels, CCArrayLabels, CCEqual,
Containers
BuildDepends: bytes, result, containers.monomorphic
# BuildDepends: bytes, bisect_ppx
Library "containers_monomorphic"
Path: src/monomorphic
Modules: CCMonomorphic
FindlibParent: containers
FindlibName: monomorphic
Library "containers_unix"
Path: src/unix
Modules: CCUnix
BuildDepends: bytes, result, unix, containers.monomorphic
FindlibParent: containers
FindlibName: unix
Library "containers_sexp"
Path: src/sexp
Modules: CCSexp, CCSexp_lex
BuildDepends: bytes, result, containers.monomorphic
FindlibParent: containers
FindlibName: sexp
Library "containers_data"
Path: src/data
Modules: CCMultiMap, CCMultiSet, CCTrie, CCFlatHashtbl, CCCache,
CCPersistentHashtbl, CCDeque, CCFQueue, CCBV, CCMixtbl,
CCMixmap, CCRingBuffer, CCIntMap, CCPersistentArray,
CCMixset, CCGraph, CCHashSet, CCBitField,
CCHashTrie, CCWBTree, CCRAL, CCSimple_queue,
CCImmutArray, CCHet, CCZipper
BuildDepends: bytes, containers.monomorphic
# BuildDepends: bytes, bisect_ppx
FindlibParent: containers
FindlibName: data
Library "containers_iter"
Path: src/iter
Modules: CCKTree, CCKList, CCLazy_list
BuildDepends: containers.monomorphic
FindlibParent: containers
FindlibName: iter
Library "containers_thread"
Path: src/threads/
Modules: CCPool, CCLock, CCSemaphore, CCThread, CCBlockingQueue,
CCTimer
FindlibName: thread
FindlibParent: containers
Build$: flag(thread)
Install$: flag(thread)
BuildDepends: containers, threads
XMETARequires: containers, threads
Library "containers_top"
Path: src/top/
Modules: Containers_top
FindlibName: top
FindlibParent: containers
BuildDepends: compiler-libs.common, containers, containers.data,
containers.unix, containers.sexp, containers.iter
Document containers
Title: Containers docs
Type: ocamlbuild (0.3)
BuildTools+: ocamldoc
Build$: flag(docs) && flag(unix)
Install: true
XOCamlbuildPath: .
XOCamlbuildExtraArgs:
"-docflags '-colorize-code -short-functors -charset utf-8'"
XOCamlbuildLibraries:
containers, containers.iter, containers.data,
containers.thread, containers.unix, containers.sexp
Executable run_benchs
Path: benchs/
Install: false
CompiledObject: best
Build$: flag(bench)
MainIs: run_benchs.ml
BuildDepends: containers, qcheck,
containers.data, containers.iter, containers.thread,
containers.monomorphic,
sequence, gen, benchmark
Executable run_bench_hash
Path: benchs/
Install: false
CompiledObject: best
Build$: flag(bench)
MainIs: run_bench_hash.ml
BuildDepends: containers
PreBuildCommand: make qtest-gen
Executable run_qtest
Path: qtest/
Install: false
CompiledObject: best
MainIs: run_qtest.ml
Build$: flag(tests) && flag(unix)
BuildDepends: containers, containers.iter,
containers.sexp, containers.unix, containers.thread,
containers.data,
sequence, gen, unix, oUnit, qcheck
Test all
Command: ./run_qtest.native
TestTools: run_qtest
Run$: flag(tests) && flag(unix)
Executable id_sexp
Path: examples/
Install: false
CompiledObject: best
MainIs: id_sexp.ml
BuildDepends: containers.sexp
SourceRepository head
Type: git
Location: https://github.com/c-cube/ocaml-containers
Browser: https://github.com/c-cube/ocaml-containers/tree/master/src

164
_tags
View file

@ -1,164 +0,0 @@
# OASIS_START
# DO NOT EDIT (digest: 1681c391580688c2463b8457d464cf03)
# 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
true: annot, bin_annot
<**/.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 containers
"src/core/containers.cmxs": use_containers
<src/core/*.ml{,i,y}>: package(bytes)
<src/core/*.ml{,i,y}>: package(result)
# Library containers_io
"src/io/containers_io.cmxs": use_containers_io
<src/io/*.ml{,i,y}>: package(bytes)
# Library containers_unix
"src/unix/containers_unix.cmxs": use_containers_unix
<src/unix/*.ml{,i,y}>: package(bytes)
<src/unix/*.ml{,i,y}>: package(unix)
# Library containers_sexp
"src/sexp/containers_sexp.cmxs": use_containers_sexp
<src/sexp/*.ml{,i,y}>: package(bytes)
# Library containers_data
"src/data/containers_data.cmxs": use_containers_data
<src/data/*.ml{,i,y}>: package(bytes)
# Library containers_iter
"src/iter/containers_iter.cmxs": use_containers_iter
# Library containers_string
"src/string/containers_string.cmxs": use_containers_string
<src/string/*.ml{,i,y}>: package(bytes)
# Library containers_advanced
"src/advanced/containers_advanced.cmxs": use_containers_advanced
<src/advanced/*.ml{,i,y}>: package(bytes)
<src/advanced/*.ml{,i,y}>: package(result)
<src/advanced/*.ml{,i,y}>: package(sequence)
<src/advanced/*.ml{,i,y}>: use_containers
# Library containers_bigarray
"src/bigarray/containers_bigarray.cmxs": use_containers_bigarray
<src/bigarray/*.ml{,i,y}>: package(bigarray)
<src/bigarray/*.ml{,i,y}>: package(bytes)
<src/bigarray/*.ml{,i,y}>: package(result)
<src/bigarray/*.ml{,i,y}>: use_containers
# Library containers_thread
"src/threads/containers_thread.cmxs": use_containers_thread
<src/threads/*.ml{,i,y}>: package(bytes)
<src/threads/*.ml{,i,y}>: package(result)
<src/threads/*.ml{,i,y}>: package(threads)
<src/threads/*.ml{,i,y}>: use_containers
# Library containers_top
"src/top/containers_top.cmxs": use_containers_top
<src/top/*.ml{,i,y}>: package(bigarray)
<src/top/*.ml{,i,y}>: package(bytes)
<src/top/*.ml{,i,y}>: package(compiler-libs.common)
<src/top/*.ml{,i,y}>: package(result)
<src/top/*.ml{,i,y}>: package(unix)
<src/top/*.ml{,i,y}>: use_containers
<src/top/*.ml{,i,y}>: use_containers_bigarray
<src/top/*.ml{,i,y}>: use_containers_data
<src/top/*.ml{,i,y}>: use_containers_iter
<src/top/*.ml{,i,y}>: use_containers_sexp
<src/top/*.ml{,i,y}>: use_containers_string
<src/top/*.ml{,i,y}>: use_containers_unix
# Executable run_benchs
<benchs/run_benchs.{native,byte}>: package(benchmark)
<benchs/run_benchs.{native,byte}>: package(bytes)
<benchs/run_benchs.{native,byte}>: package(gen)
<benchs/run_benchs.{native,byte}>: package(hamt)
<benchs/run_benchs.{native,byte}>: package(result)
<benchs/run_benchs.{native,byte}>: package(sequence)
<benchs/run_benchs.{native,byte}>: package(threads)
<benchs/run_benchs.{native,byte}>: use_containers
<benchs/run_benchs.{native,byte}>: use_containers_advanced
<benchs/run_benchs.{native,byte}>: use_containers_data
<benchs/run_benchs.{native,byte}>: use_containers_iter
<benchs/run_benchs.{native,byte}>: use_containers_string
<benchs/run_benchs.{native,byte}>: use_containers_thread
<benchs/*.ml{,i,y}>: package(benchmark)
<benchs/*.ml{,i,y}>: package(gen)
<benchs/*.ml{,i,y}>: package(threads)
<benchs/*.ml{,i,y}>: use_containers_advanced
<benchs/*.ml{,i,y}>: use_containers_iter
<benchs/*.ml{,i,y}>: use_containers_string
<benchs/*.ml{,i,y}>: use_containers_thread
# Executable run_bench_hash
<benchs/run_bench_hash.{native,byte}>: package(bytes)
<benchs/run_bench_hash.{native,byte}>: package(result)
<benchs/run_bench_hash.{native,byte}>: use_containers
# Executable run_qtest
<qtest/run_qtest.{native,byte}>: package(QTest2Lib)
<qtest/run_qtest.{native,byte}>: package(bigarray)
<qtest/run_qtest.{native,byte}>: package(bytes)
<qtest/run_qtest.{native,byte}>: package(gen)
<qtest/run_qtest.{native,byte}>: package(oUnit)
<qtest/run_qtest.{native,byte}>: package(result)
<qtest/run_qtest.{native,byte}>: package(sequence)
<qtest/run_qtest.{native,byte}>: package(threads)
<qtest/run_qtest.{native,byte}>: package(unix)
<qtest/run_qtest.{native,byte}>: use_containers
<qtest/run_qtest.{native,byte}>: use_containers_advanced
<qtest/run_qtest.{native,byte}>: use_containers_bigarray
<qtest/run_qtest.{native,byte}>: use_containers_data
<qtest/run_qtest.{native,byte}>: use_containers_io
<qtest/run_qtest.{native,byte}>: use_containers_iter
<qtest/run_qtest.{native,byte}>: use_containers_sexp
<qtest/run_qtest.{native,byte}>: use_containers_string
<qtest/run_qtest.{native,byte}>: use_containers_thread
<qtest/run_qtest.{native,byte}>: use_containers_unix
<qtest/*.ml{,i,y}>: package(QTest2Lib)
<qtest/*.ml{,i,y}>: package(bigarray)
<qtest/*.ml{,i,y}>: package(bytes)
<qtest/*.ml{,i,y}>: package(gen)
<qtest/*.ml{,i,y}>: package(oUnit)
<qtest/*.ml{,i,y}>: package(result)
<qtest/*.ml{,i,y}>: package(sequence)
<qtest/*.ml{,i,y}>: package(threads)
<qtest/*.ml{,i,y}>: package(unix)
<qtest/*.ml{,i,y}>: use_containers
<qtest/*.ml{,i,y}>: use_containers_advanced
<qtest/*.ml{,i,y}>: use_containers_bigarray
<qtest/*.ml{,i,y}>: use_containers_data
<qtest/*.ml{,i,y}>: use_containers_io
<qtest/*.ml{,i,y}>: use_containers_iter
<qtest/*.ml{,i,y}>: use_containers_sexp
<qtest/*.ml{,i,y}>: use_containers_string
<qtest/*.ml{,i,y}>: use_containers_thread
<qtest/*.ml{,i,y}>: use_containers_unix
# Executable mem_measure
"benchs/mem_measure.native": package(bytes)
"benchs/mem_measure.native": package(hamt)
"benchs/mem_measure.native": package(result)
"benchs/mem_measure.native": package(sequence)
"benchs/mem_measure.native": package(unix)
"benchs/mem_measure.native": use_containers
"benchs/mem_measure.native": use_containers_data
<benchs/*.ml{,i,y}>: package(bytes)
<benchs/*.ml{,i,y}>: package(hamt)
<benchs/*.ml{,i,y}>: package(result)
<benchs/*.ml{,i,y}>: package(sequence)
<benchs/*.ml{,i,y}>: package(unix)
<benchs/*.ml{,i,y}>: use_containers
<benchs/*.ml{,i,y}>: use_containers_data
# Executable id_sexp
<examples/id_sexp.{native,byte}>: package(bytes)
<examples/id_sexp.{native,byte}>: use_containers_sexp
<examples/*.ml{,i,y}>: package(bytes)
<examples/*.ml{,i,y}>: use_containers_sexp
# OASIS_STOP
<tests/*.ml{,i}>: thread
<src/threads/*.ml{,i}>: thread
<src/core/CCVector.cmx> or <src/core/CCString.cmx>: inline(25)
<src/data/CCFlatHashtbl.cm*> or <src/data/CCHashTrie.cm*> or <src/data/CCPersistent*>: inline(15)
<src/core/CCMap.*> or <src/core/CCSet.*> or <src/core/CCList.*>: warn(-32)
<src/**/*.ml> and not <src/misc/*.ml>: warn(+a-4-44-58-60@8)
true: no_alias_deps, safe_string, short_paths, color(always)
<src/**/*Labels.cm*>: nolabels
not (<src/monomorphic/CCMonomorphic.*> or <qtest/*>): open(CCMonomorphic)

10
benchs/jbuild Normal file
View file

@ -0,0 +1,10 @@
(executables
((names (run_benchs run_bench_hash))
(libraries (containers containers.data containers.iter
containers.thread benchmark gen sequence))
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
))

31
configure vendored
View file

@ -1,31 +0,0 @@
#!/bin/sh
# OASIS_START
# DO NOT EDIT (digest: 7577949ceda6f9dbd4983aea8db9275b)
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
if [ ! -e setup.exe ] || [ _oasis -nt setup.exe ] || [ setup.ml -nt setup.exe ] || [ configure -nt setup.exe ]; then
ocamlfind ocamlopt -o setup.exe -linkpkg -package oasis.dynrun setup.ml || ocamlfind ocamlc -o setup.exe -linkpkg -package oasis.dynrun setup.ml || exit 1
rm -f setup.cmi setup.cmo setup.cmx setup.o
fi
./setup.exe -configure "$@"
# OASIS_STOP

View file

@ -23,10 +23,9 @@ remove: [
] ]
depends: [ depends: [
"ocamlfind" {build} "ocamlfind" {build}
"oasis" {build} "jbuilder" {build}
"base-bytes" "base-bytes"
"result" "result"
"ocamlbuild" {build}
] ]
depopts: [ depopts: [
"base-unix" "base-unix"

10
examples/jbuild Normal file
View file

@ -0,0 +1,10 @@
(executables
((names (id_sexp))
(libraries (containers.sexp))
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
))

31
qtest/Makefile Normal file
View file

@ -0,0 +1,31 @@
QTEST_PREAMBLE='open CCFun;;'
DONTTEST=$(wildcard ../src/**/*.cppo.*) $(wildcard ../src/**/*Labels*)
QTESTABLE=$(filter-out $(DONTTEST), \
$(wildcard ../src/core/*.ml) \
$(wildcard ../src/core/*.mli) \
$(wildcard ../src/data/*.ml) \
$(wildcard ../src/data/*.mli) \
$(wildcard ../src/string/*.ml) \
$(wildcard ../src/string/*.mli) \
$(wildcard ../src/unix/*.ml) \
$(wildcard ../src/unix/*.mli) \
$(wildcard ../src/sexp/*.ml) \
$(wildcard ../src/sexp/*.mli) \
$(wildcard ../src/iter/*.ml) \
$(wildcard ../src/iter/*.mli) \
$(wildcard ../src/bigarray/*.ml) \
$(wildcard ../src/bigarray/*.mli) \
$(wildcard ../src/threads/*.ml) \
$(wildcard ../src/threads/*.mli) \
)
qtest-gen:
@if which qtest > /dev/null ; then \
echo "generate qtest"; \
qtest extract --preamble $(QTEST_PREAMBLE) \
-o run_qtest.ml \
$(QTESTABLE) 2> /dev/null ; \
else touch qtest/run_qtest.ml ; \
fi

23
qtest/jbuild Normal file
View file

@ -0,0 +1,23 @@
(rule
((targets (run_qtest.ml))
(deps ((file Makefile)))
(fallback)
;(libraries (qtest qcheck))
(action
(run make qtest-gen))
))
(executable
((name run_qtest)
(libraries (sequence gen qcheck containers containers.unix
containers.data containers.thread containers.iter
containers.sexp))
))
(alias
((name runtest)
(deps (run_qtest.exe))
(action (run ${<}))
))

View file

@ -1,32 +0,0 @@
(* setup.ml generated for the first time by OASIS v0.4.4 *)
(* OASIS_START *)
(* DO NOT EDIT (digest: 1bc19e72587da58c1e1f99f847b509aa) *)
(******************************************************************************)
(* OASIS: architecture for building OCaml libraries and applications *)
(* *)
(* Copyright (C) 2011-2016, Sylvain Le Gall *)
(* Copyright (C) 2008-2011, OCamlCore SARL *)
(* *)
(* This library is free software; you can redistribute it and/or modify it *)
(* under the terms of the GNU Lesser General Public License as published by *)
(* the Free Software Foundation; either version 2.1 of the License, or (at *)
(* your option) any later version, with the OCaml static compilation *)
(* exception. *)
(* *)
(* This library is distributed in the hope that it will be useful, but *)
(* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *)
(* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *)
(* details. *)
(* *)
(* You should have received a copy of the GNU Lesser General Public License *)
(* along with this library; if not, write to the Free Software Foundation, *)
(* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *)
(******************************************************************************)
open OASISDynRun
let setup_t = BaseCompat.Compat_0_4.adapt_setup_t setup_t
open BaseCompat.Compat_0_4
(* OASIS_STOP *)
let () = setup ();;

View file

@ -570,9 +570,9 @@ let sorted_merge ~cmp l1 l2 =
recurse cmp [] l1 l2 recurse cmp [] l1 l2
(*$T (*$T
List.sort Pervasives.compare ([(( * )2); ((+)1)] <*> [10;100]) \ equal CCInt.equal (List.sort CCInt.compare ([(( * )2); ((+)1)] <*> [10;100])) \
= [11; 20; 101; 200] [11; 20; 101; 200]
sorted_merge ~cmp:CCInt.compare [1;1;2] [1;2;3] = [1;1;1;2;2;3] equal CCInt.equal (sorted_merge ~cmp:CCInt.compare [1;1;2] [1;2;3]) [1;1;1;2;2;3]
*) *)
(*$Q (*$Q

View file

@ -86,7 +86,7 @@ let fail_ ~err st msg =
let next st ~ok ~err = let next st ~ok ~err =
if st.i = String.length st.str if st.i = String.length st.str
then fail_ st ~err (const_ "unexpected end of input") then fail_ ~err st (const_ "unexpected end of input")
else ( else (
let c = st.str.[st.i] in let c = st.str.[st.i] in
st.i <- st.i + 1; st.i <- st.i + 1;
@ -110,24 +110,24 @@ type 'a t = state -> ok:('a -> unit) -> err:(exn -> unit) -> unit
let return : 'a -> 'a t = fun x _st ~ok ~err:_ -> ok x let return : 'a -> 'a t = fun x _st ~ok ~err:_ -> ok x
let pure = return let pure = return
let (>|=) : 'a t -> ('a -> 'b) -> 'b t let (>|=) : 'a t -> ('a -> 'b) -> 'b t
= fun p f st ~ok ~err -> p st ~err ~ok:(fun x -> ok (f x)) = fun p f st ~ok ~err -> p st ~ok:(fun x -> ok (f x)) ~err
let (>>=) : 'a t -> ('a -> 'b t) -> 'b t let (>>=) : 'a t -> ('a -> 'b t) -> 'b t
= fun p f st ~ok ~err -> p st ~err ~ok:(fun x -> f x st ~err ~ok) = fun p f st ~ok ~err -> p st ~ok:(fun x -> f x st ~ok ~err) ~err
let (<*>) : ('a -> 'b) t -> 'a t -> 'b t let (<*>) : ('a -> 'b) t -> 'a t -> 'b t
= fun f x st ~ok ~err -> = fun f x st ~ok ~err ->
f st ~err ~ok:(fun f' -> x st ~err ~ok:(fun x' -> ok (f' x'))) f st ~ok:(fun f' -> x st ~ok:(fun x' -> ok (f' x')) ~err) ~err
let (<* ) : 'a t -> _ t -> 'a t let (<* ) : 'a t -> _ t -> 'a t
= fun x y st ~ok ~err -> = fun x y st ~ok ~err ->
x st ~err ~ok:(fun res -> y st ~err ~ok:(fun _ -> ok res)) x st ~ok:(fun res -> y st ~ok:(fun _ -> ok res) ~err) ~err
let ( *>) : _ t -> 'a t -> 'a t let ( *>) : _ t -> 'a t -> 'a t
= fun x y st ~ok ~err -> = fun x y st ~ok ~err ->
x st ~err ~ok:(fun _ -> y st ~err ~ok) x st ~ok:(fun _ -> y st ~ok ~err) ~err
let map f x = x >|= f let map f x = x >|= f
let map2 f x y = pure f <*> x <*> y let map2 f x y = pure f <*> x <*> y
let map3 f x y z = pure f <*> x <*> y <*> z let map3 f x y z = pure f <*> x <*> y <*> z
let junk_ st = next st ~err:(fun _ -> assert false) ~ok:ignore let junk_ st = next st ~ok:ignore ~err:(fun _ -> assert false)
let eoi st ~ok ~err = let eoi st ~ok ~err =
if is_done st if is_done st
@ -148,15 +148,15 @@ let nop _ ~ok ~err:_ = ok()
let char c = let char c =
let msg = Printf.sprintf "expected '%c'" c in let msg = Printf.sprintf "expected '%c'" c in
fun st ~ok ~err -> fun st ~ok ~err ->
next st ~err next st
~ok:(fun c' -> if char_equal c c' then ok c else fail_ ~err st (const_ msg)) ~ok:(fun c' -> if char_equal c c' then ok c else fail_ ~err st (const_ msg)) ~err
let char_if p st ~ok ~err = let char_if p st ~ok ~err =
next st ~err next st
~ok:(fun c -> ~ok:(fun c ->
if p c then ok c if p c then ok c
else fail_ ~err st (fun () -> Printf.sprintf "unexpected char '%c'" c) else fail_ ~err st (fun () -> Printf.sprintf "unexpected char '%c'" c)
) ) ~err
let chars_if p st ~ok ~err:_ = let chars_if p st ~ok ~err:_ =
let i = st.i in let i = st.i in
@ -165,11 +165,12 @@ let chars_if p st ~ok ~err:_ =
ok (String.sub st.str i !len) ok (String.sub st.str i !len)
let chars1_if p st ~ok ~err = let chars1_if p st ~ok ~err =
chars_if p st ~err chars_if p st
~ok:(fun s -> ~ok:(fun s ->
if string_equal s "" if string_equal s ""
then fail_ ~err st (const_ "unexpected sequence of chars") then fail_ ~err st (const_ "unexpected sequence of chars")
else ok s) else ok s)
~err
let rec skip_chars p st ~ok ~err = let rec skip_chars p st ~ok ~err =
if not (is_done st) && p (cur st) then ( if not (is_done st) && p (cur st) then (
@ -191,10 +192,11 @@ let space = char_if is_space
let white = char_if is_white let white = char_if is_white
let endline st ~ok ~err = let endline st ~ok ~err =
next st ~err next st
~ok:(function ~ok:(function
| '\n' as c -> ok c | '\n' as c -> ok c
| _ -> fail_ ~err st (const_ "expected end-of-line")) | _ -> fail_ ~err st (const_ "expected end-of-line"))
~err
let skip_space = skip_chars is_space let skip_space = skip_chars is_space
let skip_white = skip_chars is_white let skip_white = skip_chars is_white
@ -232,32 +234,33 @@ let string s st ~ok ~err =
let rec check i = let rec check i =
if i = String.length s then ok s if i = String.length s then ok s
else else
next st ~err next st
~ok:(fun c -> ~ok:(fun c ->
if char_equal c s.[i] if char_equal c s.[i]
then check (i+1) then check (i+1)
else fail_ ~err st (fun () -> Printf.sprintf "expected \"%s\"" s)) else fail_ ~err st (fun () -> Printf.sprintf "expected \"%s\"" s))
~err
in in
check 0 check 0
let rec many_rec : 'a t -> 'a list -> 'a list t = fun p acc st ~ok ~err -> let rec many_rec : 'a t -> 'a list -> 'a list t = fun p acc st ~ok ~err ->
if is_done st then ok(List.rev acc) if is_done st then ok(List.rev acc)
else else
p st ~err p st
~ok:(fun x -> ~ok:(fun x ->
let i = pos st in let i = pos st in
many_rec p (x :: acc) st ~ok many_rec p (x :: acc) st ~ok
~err:(fun _ -> ~err:(fun _ ->
backtrack st i; backtrack st i;
ok(List.rev acc)) ok(List.rev acc))
) ) ~err
let many : 'a t -> 'a list t let many : 'a t -> 'a list t
= fun p st ~ok ~err -> many_rec p [] st ~ok ~err = fun p st ~ok ~err -> many_rec p [] st ~ok ~err
let many1 : 'a t -> 'a list t = let many1 : 'a t -> 'a list t =
fun p st ~ok ~err -> fun p st ~ok ~err ->
p st ~err ~ok:(fun x -> many_rec p [x] st ~err ~ok) p st ~ok:(fun x -> many_rec p [x] st ~ok ~err) ~err
let rec skip p st ~ok ~err = let rec skip p st ~ok ~err =
let i = pos st in let i = pos st in
@ -306,12 +309,12 @@ let memo (type a) (p:a t):a t =
with Not_found -> with Not_found ->
(* parse, and save *) (* parse, and save *)
p st p st
~err:(fun e ->
MemoTbl.H.replace tbl (i,id) (fun () -> r := Some (MemoTbl.Fail e));
err e)
~ok:(fun x -> ~ok:(fun x ->
MemoTbl.H.replace tbl (i,id) (fun () -> r := Some (MemoTbl.Ok x)); MemoTbl.H.replace tbl (i,id) (fun () -> r := Some (MemoTbl.Ok x));
ok x) ok x)
~err:(fun e ->
MemoTbl.H.replace tbl (i,id) (fun () -> r := Some (MemoTbl.Fail e));
err e)
let fix_memo f = let fix_memo f =
let rec p = let rec p =

View file

@ -117,10 +117,10 @@ let _diff_list ~last l =
_k y_k = _k (x_{k+1} - x_k ) = x_{len} - x_0 = i. *) _k y_k = _k (x_{k+1} - x_k ) = x_{len} - x_0 = i. *)
let split_list i ~len st = let split_list i ~len st =
if len <= 1 then invalid_arg "Random.split_list"; if len <= 1 then invalid_arg "Random.split_list";
if i >= len then if i >= len then (
let xs = sample_without_replacement ~compare (len-1) (int_range 1 (i-1)) st in let xs = sample_without_replacement ~compare (len-1) (int_range 1 (i-1)) st in
_diff_list ( 0::xs ) ~last:i _diff_list ~last:i (0::xs)
else ) else
None None
(*$Q (*$Q

View file

@ -257,14 +257,14 @@ end
let find ?(start=0) ~sub = let find ?(start=0) ~sub =
let pattern = Find.compile sub in let pattern = Find.compile sub in
fun s -> Find.find ~pattern s ~start fun s -> Find.find ~start ~pattern s
let find_all ?(start=0) ~sub = let find_all ?(start=0) ~sub =
let pattern = Find.compile sub in let pattern = Find.compile sub in
fun s -> fun s ->
let i = ref start in let i = ref start in
fun () -> fun () ->
let res = Find.find ~pattern s ~start:!i in let res = Find.find ~start:!i ~pattern s in
if res = ~-1 then None if res = ~-1 then None
else ( else (
i := res + 1; (* possible overlap *) i := res + 1; (* possible overlap *)
@ -282,7 +282,7 @@ let mem ?start ~sub s = find ?start ~sub s >= 0
let rfind ~sub = let rfind ~sub =
let pattern = Find.rcompile sub in let pattern = Find.rcompile sub in
fun s -> Find.rfind ~pattern s ~start:(String.length s-1) fun s -> Find.rfind ~start:(String.length s-1) ~pattern s
(* Replace substring [s.[pos]....s.[pos+len-1]] by [by] in [s] *) (* Replace substring [s.[pos]....s.[pos+len-1]] by [by] in [s] *)
let replace_at_ ~pos ~len ~by s = let replace_at_ ~pos ~len ~by s =
@ -296,7 +296,7 @@ let replace ?(which=`All) ~sub ~by s =
if is_empty sub then invalid_arg "CCString.replace"; if is_empty sub then invalid_arg "CCString.replace";
match which with match which with
| `Left -> | `Left ->
let i = find ~sub s ~start:0 in let i = find ~start:0 ~sub s in
if i>=0 then replace_at_ ~pos:i ~len:(String.length sub) ~by s else s if i>=0 then replace_at_ ~pos:i ~len:(String.length sub) ~by s else s
| `Right -> | `Right ->
let i = rfind ~sub s in let i = rfind ~sub s in
@ -307,7 +307,7 @@ let replace ?(which=`All) ~sub ~by s =
let b = Buffer.create (String.length s) in let b = Buffer.create (String.length s) in
let start = ref 0 in let start = ref 0 in
while !start < String.length s do while !start < String.length s do
let i = Find.find ~pattern s ~start:!start in let i = Find.find ~start:!start ~pattern s in
if i>=0 then ( if i>=0 then (
(* between last and cur occurrences *) (* between last and cur occurrences *)
Buffer.add_substring b s !start (i- !start); Buffer.add_substring b s !start (i- !start);
@ -339,7 +339,7 @@ module Split = struct
| SplitAt prev -> _split_search ~by s prev | SplitAt prev -> _split_search ~by s prev
and _split_search ~by s prev = and _split_search ~by s prev =
let j = Find.find ~pattern:by s ~start:prev in let j = Find.find ~start:prev ~pattern:by s in
if j < 0 if j < 0
then Some (SplitStop, prev, String.length s - prev) then Some (SplitStop, prev, String.length s - prev)
else Some (SplitAt (j+Find.pattern_length by), prev, j-prev) else Some (SplitAt (j+Find.pattern_length by), prev, j-prev)

10
src/core/jbuild Normal file
View file

@ -0,0 +1,10 @@
(library
((name containers)
(public_name containers)
(wrapped false)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always -nolabels -open CCMonomorphic))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
(libraries (bytes result containers.monomorphic))
))

10
src/data/jbuild Normal file
View file

@ -0,0 +1,10 @@
(library
((name containers_data)
(public_name containers.data)
(wrapped false)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
(libraries (bytes result))
))

10
src/iter/jbuild Normal file
View file

@ -0,0 +1,10 @@
(library
((name containers_iter)
(public_name containers.iter)
(wrapped false)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
(libraries (bytes result))
))

10
src/monomorphic/jbuild Normal file
View file

@ -0,0 +1,10 @@
(library
((name containers_monomorphic)
(public_name containers.monomorphic)
(wrapped false)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
(libraries ())
))

12
src/sexp/jbuild Normal file
View file

@ -0,0 +1,12 @@
(library
((name containers_sexp)
(public_name containers.sexp)
(wrapped false)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
(libraries (bytes result))
))
(ocamllex (CCSexp_lex))

11
src/threads/jbuild Normal file
View file

@ -0,0 +1,11 @@
(library
((name containers_thread)
(public_name containers.thread)
(wrapped false)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
(libraries (containers threads))
))

12
src/top/jbuild Normal file
View file

@ -0,0 +1,12 @@
(library
((name containers_top)
(public_name containers.top)
(wrapped false)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
(libraries (compiler-libs.common containers containers.data
containers.unix containers.sexp containers.iter))
))

View file

@ -1,2 +1,5 @@
B ../../_build/default/src/unix
FLG -w -40 -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always
PKG bytes
PKG result
PKG unix PKG unix
REC

10
src/unix/jbuild Normal file
View file

@ -0,0 +1,10 @@
(library
((name containers_unix)
(public_name containers.unix)
(wrapped false)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
(ocamlopt_flags (:standard -O3 -color always
-unbox-closures -unbox-closures-factor 20))
(libraries (bytes result unix))
))