Skip to content

Commit

Permalink
Use jbuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Gazagnaire <thomas@gazagnaire.org>
  • Loading branch information
samoht committed Apr 26, 2017
1 parent 48df477 commit 0c34c21
Show file tree
Hide file tree
Showing 63 changed files with 225 additions and 356 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,3 +10,4 @@ Datakit.app/
*.byte
bridge/github/webhook/webhook
COMMIT
.merlin
14 changes: 0 additions & 14 deletions .merlin

This file was deleted.

50 changes: 21 additions & 29 deletions Makefile
@@ -1,64 +1,56 @@
GITHUB=$(shell opam config var github:installed)
APP=Datakit.app
EXE=Datakit
PINOPTS=-y -k git

TESTS = true
BUILD=jbuilder build --dev
RUNTEST=jbuilder runtest

.PHONY: all clean test bundle COMMIT exe ci

all: datakit
@

depends:
opam pin add ${PINOPTS} datakit-client .
opam pin add ${PINOPTS} datakit-server .
opam pin add ${PINOPTS} datakit-github .
opam pin add ${PINOPTS} datakit-ci .
opam update -u datakit-client datakit-server datakit-github datakit-ci -y
all:
$(BUILD)

datakit:
ocaml pkg/pkg.ml build --tests $(TESTS) -q
ocaml pkg/pkg.ml test
$(BUILD) -n datakit
$(RUNTEST) test/datakit

client:
ocaml pkg/pkg.ml build -n datakit-client -q
$(BUILD) -p datakit-client

server:
ocaml pkg/pkg.ml build -n datakit-server -q
$(BUILD) -p datakit-server

github:
ocaml pkg/pkg.ml build -n datakit-github -q
$(BUILD) -p datakit-github

bridge-local-git:
ocaml pkg/pkg.ml build -n datakit-bridge-local-git -q
$(BUILD) -p datakit-bridge-local-git

bridge-github:
ocaml pkg/pkg.ml build -n datakit-bridge-github -q --tests true
ocaml pkg/pkg.ml test -n datakit-bridge-github
$(BUILD) -p datakit-bridge-github
$(RUNTEST) test/datakit-github-bridge

ci:
ocaml pkg/pkg.ml build -n datakit-ci -q --tests true
ocaml pkg/pkg.ml test -n datakit-ci
$(BUILD) -p datakit-ci
$(RUNTEST) ci/tests

clean:
ocaml pkg/pkg.ml clean
rm -rf _build
rm -rf $(APP) $(EXE) _tests
rm -f examples/ocaml-client/*.native
rm -f ci/skeleton/exampleCI.native
rm -f com.docker.db

test:
ocaml pkg/pkg.ml build --tests true
ocaml pkg/pkg.ml test
jbuilder runtest

bundle:
opam remove tls ssl -y
$(MAKE) clean
ocaml pkg/pkg.ml build --tests false --pinned true
$(BUILD) src/datakit/bin/main.exe
mkdir -p $(APP)/Contents/MacOS/
mkdir -p $(APP)/Contents/Resources/lib/
cp _build/src/datakit/main.native $(APP)/Contents/MacOS/com.docker.db
cp _build/default/src/datakit/bin/main.exe $(APP)/Contents/MacOS/com.docker.db
./scripts/check-dylib.sh
dylibbundler -od -b \
-x $(APP)/Contents/MacOS/com.docker.db \
Expand All @@ -72,17 +64,17 @@ COMMIT:
exe:
opam remove tls ssl -y
rm -rf _build/
ocaml pkg/pkg.ml build --tests false --pinned true
$(BUILD) src/datakit/bin/main.exe
mkdir -p $(EXE)
cp _build/src/datakit/main.native $(EXE)/datakit.exe
cp _build/debfault/src/datakit/bin/main.exe $(EXE)/datakit.exe
cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/zlib1.dll $(EXE)

REPO=../opam-repository
PACKAGES=$(REPO)/packages

# until we have https://github.com/ocaml/opam-publish/issues/38
pkg-%:
topkg opam pkg -n $*
topkg opam pkg -p $*
mkdir -p $(PACKAGES)/$*
cp -r _build/$*.* $(PACKAGES)/$*/
cd $(PACKAGES) && git add $*
Expand Down
52 changes: 0 additions & 52 deletions _tags

This file was deleted.

1 change: 0 additions & 1 deletion api/ocaml

This file was deleted.

13 changes: 13 additions & 0 deletions api/ocaml/bin/jbuild
@@ -0,0 +1,13 @@
(jbuild_version 1)

(executable
((name mount)
(public_name datakit-mount)
(package datakit-client)
(libraries (cmdliner unix))))

; TODO: generate the right version using tokpg watermarking
(rule
((targets (version.ml))
(deps (../../../src/version.ml))
(action (copy ${<} ${@}))))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions api/ocaml/jbuild
@@ -0,0 +1,7 @@
(jbuild_version 1)

(library
((name datakit_client)
(public_name datakit-client)
(wrapped false)
(libraries (fmt lwt cstruct astring protocol-9p.unix))))
15 changes: 0 additions & 15 deletions bridge/github/_tags

This file was deleted.

23 changes: 23 additions & 0 deletions bridge/github/jbuild
@@ -0,0 +1,23 @@
(jbuild_version 1)

(library
((name datakit_bridge_github)
(wrapped false)
(modules (:standard \ main \ version))
(libraries (github-hooks.unix github.unix datakit-github datakit-server))
))

(executable
((name main)
(modules (main version))
(package datakit-bridge-github)
(public_name datakit-bridge-github)
(libraries (datakit_bridge_github protocol-9p.unix prometheus-app.unix
datakit_log fmt.cli fmt.tty github.unix))
))

; TODO: generate the right version using topkg watermarking
(rule
((targets (version.ml))
(deps (../../src/version.ml))
(action (copy ${<} ${@}))))
4 changes: 0 additions & 4 deletions bridge/local/_tags

This file was deleted.

2 changes: 0 additions & 2 deletions bridge/local/datakit-bridge-local-git.mllib

This file was deleted.

9 changes: 9 additions & 0 deletions bridge/local/jbuild
@@ -0,0 +1,9 @@
(jbuild_version 1)

(executable
((name main)
(package datakit-bridge-local-git)
(public_name datakit-bridge-local-git)
(libraries (irmin datakit-client datakit-github irmin-unix cmdliner
protocol-9p.unix fmt.cli logs.cli fmt.tty))
))
5 changes: 0 additions & 5 deletions ci/.merlin

This file was deleted.

13 changes: 0 additions & 13 deletions ci/_tags

This file was deleted.

4 changes: 4 additions & 0 deletions ci/src/cI_static.mli
@@ -1 +1,5 @@
val read : string -> string option

(* to avoid warning 32 *)
val file_list: string list
val size: string -> int64 option
4 changes: 2 additions & 2 deletions ci/src/cI_utils.ml
Expand Up @@ -36,8 +36,8 @@ let pp_exn f = function
| ex -> Fmt.string f (Printexc.to_string ex)

let pp_duration f d =
if d < 120. then Fmt.pf f "%.f seconds" d
else Fmt.pf f "%.f minutes" (d /. 60.)
if d < 120. then Fmt.pf f "%.2f seconds" d
else Fmt.pf f "%.2f minutes" (d /. 60.)

let with_switch fn =
let switch = Lwt_switch.create () in
Expand Down
27 changes: 0 additions & 27 deletions ci/src/datakit-ci.mllib

This file was deleted.

18 changes: 18 additions & 0 deletions ci/src/jbuild
@@ -0,0 +1,18 @@
(jbuild_version 1)

(library
((name datakit_ci)
(public_name datakit-ci)
(wrapped false)
(libraries (datakit-github yojson cmdliner tyxml multipart-form-data
prometheus-app.unix webmachine redis.lwt session pbkdf
github protocol-9p.unix logs.cli session.redis-lwt
session.webmachine github.unix fmt.cli fmt.tty))
(preprocess (per_file
((pps (ppx_sexp_conv)) (cI_secrets cI_web_utils))))
))

(rule
((targets (cI_static.ml))
(deps ((files_recursively_in ../static/)))
(action (run ocaml-crunch --mode=plain -o ${@} ../static))))
12 changes: 12 additions & 0 deletions ci/tests/jbuild
@@ -0,0 +1,12 @@
(jbuild_version 1)

(executable
((name test_ci)
(package datakit-ci)
(libraries (datakit-github datakit-ci alcotest datakit_io datakit))
))

(alias
((name runtest)
(deps (test_ci.exe))
(action (run ${exe:test_ci.exe} -q))))
14 changes: 3 additions & 11 deletions datakit-bridge-github.opam
Expand Up @@ -8,19 +8,11 @@ bug-reports: "https://github.com/moby/datakit/issues"
dev-repo: "https://github.com/moby/datakit.git"
doc: "https://docker.github.io/datakit/"

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" "tests/%{name}%"]

depends: [
"ocamlfind" {build}
"ocamlbuild" {build}
"topkg" {build}
"jbuilder" {build}
"cmdliner"
"lwt" {>= "2.7.1"}
"datakit-github"
Expand Down
8 changes: 2 additions & 6 deletions datakit-bridge-local-git.opam
Expand Up @@ -7,14 +7,10 @@ bug-reports: "https://github.com/moby/datakit/issues"
dev-repo: "https://github.com/moby/datakit.git"
doc: "https://docker.github.io/datakit/"

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

depends: [
"ocamlfind" {build}
"ocamlbuild" {build}
"topkg" {build}
"jbuilder" {build}
"cmdliner"
"irmin-watcher"
"irmin" {>= "1.1.0"}
Expand Down

0 comments on commit 0c34c21

Please sign in to comment.