Skip to content

Commit

Permalink
Use jbuilder
Browse files Browse the repository at this point in the history
Split irmin into irmin, irmin-mem nad irmin-fs and add new opam packages.
As usual, fix wrong linking in the tests spotted by jbuilder.
  • Loading branch information
samoht committed May 11, 2017
1 parent 2c4d20f commit 2c593cd
Show file tree
Hide file tree
Showing 112 changed files with 886 additions and 822 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@ lib-http/irmin_http_static.ml
_build
*~
*.install
*.merlin
13 changes: 0 additions & 13 deletions .merlin

This file was deleted.

42 changes: 22 additions & 20 deletions Makefile
@@ -1,36 +1,38 @@
BUILD=jbuilder build --dev
RUNTEST=jbuilder runtest -j 1

all:
$(MAKE) core
$(MAKE) git
$(MAKE) http
$(MAKE) mirage
$(MAKE) unix
$(BUILD)
$(RUNTEST)

core:
ocaml pkg/pkg.ml build -n irmin -q --tests true
ocaml pkg/pkg.ml test -n irmin
$(BUILD) -p irmin

mem:
$(BUILD) -p irmin-mem
$(RUNTEST) test/irmin-mem

fs:
$(BUILD) -p irmin-fs
$(RUNTEST) test/irmin-fs

git:
ocaml pkg/pkg.ml build -n irmin-git -q --tests true
ocaml pkg/pkg.ml test -n irmin-git
$(BUILD) -p irmin-git
$(RUNTEST) test/main_git

http:
ocaml pkg/pkg.ml build -n irmin-http -q --tests true
ocaml pkg/pkg.ml test -n irmin-http
$(BUILD) -p irmin-http
$(RUNTEST) test/main_http

mirage:
ocaml pkg/pkg.ml build -n irmin-mirage -q --tests true
ocaml pkg/pkg.ml test -n irmin-mirage
$(BUILD) -p irmin-mirage

unix:
ocaml pkg/pkg.ml build -n irmin-unix -q --tests true
ocaml pkg/pkg.ml test -n irmin-unix
$(BUILD) -p irmin-unix
$(RUNTEST) test/main_unix

clean:
ocaml pkg/pkg.ml clean -n irmin
ocaml pkg/pkg.ml clean -n irmin-git
ocaml pkg/pkg.ml clean -n irmin-http
ocaml pkg/pkg.ml clean -n irmin-mirage
ocaml pkg/pkg.ml clean -n irmin-unix
rm -rf _build

REPO=../opam-repository
PACKAGES=$(REPO)/packages
Expand Down
24 changes: 0 additions & 24 deletions _tags

This file was deleted.

1 change: 1 addition & 0 deletions irmin-fs.descr
@@ -0,0 +1 @@
Generic file-system backend for Irmin
19 changes: 19 additions & 0 deletions irmin-fs.opam
@@ -0,0 +1,19 @@
opam-version: "1.2"
maintainer: "thomas@gazagnaire.org"
authors: ["Thomas Gazagnaire" "Thomas Leonard"]
license: "ISC"
homepage: "https://github.com/mirage/irmin"
bug-reports: "https://github.com/mirage/irmin/issues"
dev-repo: "https://github.com/mirage/irmin.git"
doc: "https://mirage.github.io/irmin/"

build: ["jbuilder" "build" "-p" name "-j" jobs]
build-test: ["jbuilder" "runtest" "test/irmin-fs"]

depends: [
"jbuilder" {build}
"irmin" {>= "1.2.0"}
"alcotest" {test}
"mtime" {test & < "1.0.0"}
]
available: [ocaml-version >= "4.03.0"]
16 changes: 5 additions & 11 deletions irmin-git.opam
Expand Up @@ -7,19 +7,13 @@ bug-reports: "https://github.com/mirage/irmin/issues"
dev-repo: "https://github.com/mirage/irmin.git"
doc: "https://mirage.github.io/irmin/"

build: ["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "-n" name]

build-test: [
["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "-n" name "--tests" "true"]
["ocaml" "pkg/pkg.ml" "test" "-n" name]
]
build: ["jbuilder" "build" "-p" name "-j" jobs]
build-test: ["jbuilder" "runtest" "test/irmin-git"]

depends: [
"ocamlbuild" {build}
"ocamlfind" {build}
"topkg" {build & >= "0.9.0"}
"irmin" {>= "1.1.0"}
"git" {>= "1.10.0"}
"jbuilder" {build}
"irmin" {>= "1.1.0"}
"git" {>= "1.10.0"}
"alcotest" {test}
"git-unix" {test & >= "1.10.0"}
]
Expand Down
12 changes: 3 additions & 9 deletions irmin-http.opam
Expand Up @@ -7,17 +7,11 @@ bug-reports: "https://github.com/mirage/irmin/issues"
dev-repo: "https://github.com/mirage/irmin.git"
doc: "https://mirage.github.io/irmin/"

build:
["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "-n" name "--tests" "false"]
build: ["jbuilder" "build" "-p" name "-j" jobs]
build-test: ["jbuilder" "runtest" "test/irmin-mem"]

build-test: [
["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "-n" name "--tests" "true"]
["ocaml" "pkg/pkg.ml" "test" "-n" name]
]
depends: [
"ocamlbuild" {build}
"ocamlfind" {build}
"topkg" {build & >= "0.9.0"}
"jbuilder" {build}
"crunch"
"webmachine" {>= "0.3.2"}
"irmin" {>= "1.0.0"}
Expand Down
1 change: 1 addition & 0 deletions irmin-mem.descr
@@ -0,0 +1 @@
In-memory backend for Irmin
19 changes: 19 additions & 0 deletions irmin-mem.opam
@@ -0,0 +1,19 @@
opam-version: "1.2"
maintainer: "thomas@gazagnaire.org"
authors: ["Thomas Gazagnaire" "Thomas Leonard"]
license: "ISC"
homepage: "https://github.com/mirage/irmin"
bug-reports: "https://github.com/mirage/irmin/issues"
dev-repo: "https://github.com/mirage/irmin.git"
doc: "https://mirage.github.io/irmin/"

build: ["jbuilder" "build" "-p" name "-j" jobs]
build-test: ["jbuilder" "runtest" "test/irmin-mem"]

depends: [
"jbuilder" {build}
"irmin" {>= "1.2.0"}
"alcotest" {test}
"mtime" {test & < "1.0.0"}
]
available: [ocaml-version >= "4.03.0"]
6 changes: 2 additions & 4 deletions irmin-mirage.opam
Expand Up @@ -6,12 +6,10 @@ homepage: "https://github.com/mirage/irmin"
bug-reports: "https://github.com/mirage/irmin/issues"
dev-repo: "https://github.com/mirage/irmin.git"

build: ["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "-n" name]
build: ["jbuilder" "build" "-p" name "-j" jobs]

depends: [
"ocamlbuild" {build}
"ocamlfind" {build}
"topkg" {build & >= "0.9.0"}
"jbuilder" {build}
"irmin" {>= "1.0.0"}
"irmin-git" {>= "1.0.0"}
"git-mirage" {>= "1.10.0"}
Expand Down
13 changes: 3 additions & 10 deletions irmin-unix.opam
Expand Up @@ -7,18 +7,11 @@ bug-reports: "https://github.com/mirage/irmin/issues"
dev-repo: "https://github.com/mirage/irmin.git"
doc: "https://mirage.github.io/irmin/"

build: [
"ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "-n" name "--tests" "false"
]
build-test: [
["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "-n" name "--tests" "true"]
["ocaml" "pkg/pkg.ml" "test" "-n" name]
]
build: ["jbuilder" "build" "-p" name "-j" jobs]
build-test: ["jbuilder" "runtest" "test/irmin-mem"]

depends: [
"ocamlbuild" {build}
"ocamlfind" {build}
"topkg" {build & >= "0.9.0"}
"jbuilder" {build}
"irmin" {>= "1.1.0"}
"irmin-git" {>= "1.1.0"}
"irmin-http" {>= "1.0.0"}
Expand Down
24 changes: 8 additions & 16 deletions irmin.opam
Expand Up @@ -7,27 +7,19 @@ bug-reports: "https://github.com/mirage/irmin/issues"
dev-repo: "https://github.com/mirage/irmin.git"
doc: "https://mirage.github.io/irmin/"

build:
["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "-n" name "--tests" "false"]

build-test: [
["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "-n" name "--tests" "true"]
["ocaml" "pkg/pkg.ml" "test" "-n" name]
]
build: ["jbuilder" "build" "-p" name "-j" jobs]

depends: [
"ocamlbuild" {build}
"ocamlfind" {build}
"topkg" {build & >= "0.9.0"}
"jbuilder" {build}
"result"
"fmt"
"ocamlgraph"
"lwt" {>= "2.4.7"}
"logs" {>= "0.5.0"}
"uri" {>= "1.3.12"}
"cstruct" {>= "1.6.0"}
"jsonm" {>= "1.0.0"}
"uri" {>= "1.3.12"}
"astring"
"lwt" {>= "2.4.7"}
"ocamlgraph"
"hex"
"alcotest" {test}
"logs" {>= "0.5.0"}
"astring"
]
available: [ocaml-version >= "4.03.0"]
102 changes: 1 addition & 101 deletions pkg/pkg.ml
@@ -1,103 +1,3 @@
#!/usr/bin/env ocaml
#use "topfind"
#require "topkg"
open Topkg

let includes = function
| "irmin" -> ["src"]
| "irmin-git" -> ["src-git"]
| "irmin-mirage" -> ["src-mirage"]
| "irmin-http" -> ["src-http"]
| "irmin-unix" -> ["src-unix"]
| x -> failwith ("Unknown includes for package: " ^ x)

let extra_deps c = match Conf.pkg_name c with
| "irmin" -> []
| "irmin-git" -> ["irmin"]
| "irmin-mirage" -> ["irmin"; "irmin-git"]
| "irmin-http" -> ["irmin"]@if Conf.build_tests c then ["irmin-git"] else []
| "irmin-unix" -> ["irmin-git"; "irmin-http"]
| x -> failwith ("Unknown includes for package: " ^ x)

let build =
let cmd c os =
let includes = match includes (Conf.pkg_name c) with
| [] -> Cmd.empty
| is -> Cmd.(v "-Is" % String.concat "," is)
in
let extra_deps = match extra_deps c with
| [] -> Cmd.empty
| ed -> Cmd.(v "-package" % String.concat "," ed)
in
Cmd.(Pkg.build_cmd c os %% includes %% extra_deps)
in
let cmd c os files = OS.Cmd.run @@ Cmd.(cmd c os %% of_list files) in
Pkg.build ~cmd ()

let metas = [
Pkg.meta_file ~install:false "pkg/META";
Pkg.meta_file ~install:false "pkg/META.http";
Pkg.meta_file ~install:false "pkg/META.unix";
Pkg.meta_file ~install:false "pkg/META.mirage";
]

let opams =
let opam name =
Pkg.opam_file ~lint_deps_excluding:None ~install:false name
in
[
opam "irmin.opam";
opam "irmin-git.opam";
opam "irmin-http.opam";
opam "irmin-unix.opam";
opam "irmin-mirage.opam";
]

let example x = Pkg.test ~run:false ("examples/" ^ x)

let () =
Pkg.describe ~build ~opams ~metas "irmin" @@ fun c ->
match Conf.pkg_name c with
| "irmin" ->
Ok [
Pkg.lib "pkg/META";
Pkg.lib "irmin.opam" ~dst:"opam";
Pkg.mllib ~api:["Irmin"; "Irmin_mem"; "Irmin_fs"] "src/irmin.mllib";
Pkg.test ~dir:"_build" "test/main" ~args:Cmd.(v "-e" % "-q");
]
| "irmin-git" ->
Ok [
Pkg.lib "pkg/META.git" ~dst:"META";
Pkg.lib "irmin-git.opam" ~dst:"opam";
Pkg.mllib "src-git/irmin-git.mllib";
Pkg.test ~dir:"_build" "test/main_git" ~args:Cmd.(v "-e" % "-q");
]
| "irmin-mirage" ->
Ok [
Pkg.lib "pkg/META.mirage" ~dst:"META";
Pkg.lib "irmin-mirage.opam" ~dst:"opam";
Pkg.mllib "src-mirage/irmin-mirage.mllib";
]
| "irmin-http" ->
Ok [
Pkg.lib "pkg/META.http" ~dst:"META";
Pkg.lib "irmin-http.opam" ~dst:"opam";
Pkg.mllib ~api:["Irmin_http";"Irmin_http_server"]
"src-http/irmin-http.mllib";
Pkg.test ~dir:"_build" "test/main_http" ~args:Cmd.(v "-e" % "-q");
]
| "irmin-unix" ->
Ok [
Pkg.lib "pkg/META.unix" ~dst:"META";
Pkg.lib "irmin-unix.opam" ~dst:"opam";
Pkg.mllib "src-unix/irmin-unix.mllib";
Pkg.bin "bin/main" ~dst:"irmin";
Pkg.test ~dir:"_build" "test/main_unix" ~args:Cmd.(v "-e" % "-q");
example "deploy";
example "custom_merge";
example "process";
example "views";
example "sync";
example "irmin_git_store";
]
| other -> R.error_msgf "unknown package name: %s" other
#require "topkg-jbuilder.auto"
1 change: 0 additions & 1 deletion src-git/irmin-git.mllib

This file was deleted.

3 changes: 0 additions & 3 deletions src-http/irmin-http.mllib

This file was deleted.

1 change: 0 additions & 1 deletion src-mirage/irmin-mirage.mllib

This file was deleted.

1 change: 0 additions & 1 deletion src-unix/irmin-unix.mllib

This file was deleted.

0 comments on commit 2c593cd

Please sign in to comment.