Skip to content

Commit

Permalink
Use (subdir ...) for vendored dependencies
Browse files Browse the repository at this point in the history
Based on a similar approach in Piaf. See

https://github.com/anmonteiro/piaf/blob/9863d1c82403cfddf5a04cfa93bbd10f8357cdfc/vendor/dune

Thanks to @anmonteiro for suggesting it.
  • Loading branch information
aantron committed Apr 28, 2021
1 parent 1569b05 commit 343e912
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 52 deletions.
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
PACKAGES := dream,gluten,gluten-lwt,gluten-lwt-unix,websocketaf,httpaf,httpaf-lwt,httpaf-lwt-unix,hpack,h2,h2-lwt,h2-lwt-unix

.PHONY : build
build :
@dune build --no-print-directory -p $(PACKAGES) @install
@dune build --no-print-directory @install

.PHONY : watch
watch :
@dune build --no-print-directory -p $(PACKAGES) -w
@dune build --no-print-directory -w

.PHONY : test
test :
Expand Down Expand Up @@ -72,7 +70,7 @@ clean : clean-coverage

.PHONY : utop
utop :
dune utop -p $(PACKAGES)
dune utop

.PHONY : todo
todo :
Expand Down
28 changes: 2 additions & 26 deletions dream.opam
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ depends: [
"mirage-crypto-rng" {>= "0.8.0"} # Signature of initialize.
"multipart-form-data" {>= "0.3.0"}
"ocaml" {>= "4.08.0"}
"opam-installer" {build}
"uri" {>= "4.2.0"}
"yojson" # ...

Expand All @@ -78,6 +77,7 @@ depends: [
# "httpaf-lwt-unix"
# "h2"
# "h2-lwt-unix"
# "hpack"
# "websocketaf"

# Dependencies of vendored packages.
Expand All @@ -95,30 +95,6 @@ depends: [
"ppx_expect" {with-test}
]

conflicts: [
"gluten"
"httpaf"
"h2"
"websocketaf"
]

build: [
["dune" "build" "-p"
"dream,gluten,gluten-lwt,gluten-lwt-unix,websocketaf,httpaf,httpaf-lwt,httpaf-lwt-unix,hpack,h2,h2-lwt,h2-lwt-unix"
"-j" jobs]
]

install: [
["opam-installer" "--prefix" prefix "dream.install"]
["opam-installer" "--prefix" prefix "src/vendor/gluten/gluten.install"]
["opam-installer" "--prefix" prefix "src/vendor/gluten/gluten-lwt.install"]
["opam-installer" "--prefix" prefix "src/vendor/gluten/gluten-lwt-unix.install"]
["opam-installer" "--prefix" prefix "src/vendor/websocketaf/websocketaf.install"]
["opam-installer" "--prefix" prefix "src/vendor/httpaf/httpaf.install"]
["opam-installer" "--prefix" prefix "src/vendor/httpaf/httpaf-lwt.install"]
["opam-installer" "--prefix" prefix "src/vendor/httpaf/httpaf-lwt-unix.install"]
["opam-installer" "--prefix" prefix "src/vendor/h2/hpack.install"]
["opam-installer" "--prefix" prefix "src/vendor/h2/h2.install"]
["opam-installer" "--prefix" prefix "src/vendor/h2/h2-lwt.install"]
["opam-installer" "--prefix" prefix "src/vendor/h2/h2-lwt-unix.install"]
["dune" "build" "-p" name "-j" jobs]
]
13 changes: 0 additions & 13 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
(lang dune 2.7)
(implicit_transitive_deps false)

; TODO LATER
; Note: implicit_transitive_deps is useful during massive development, but is
; probably best turned off when the project is in a steady state and for
; releases, because of issues like:
;
; https://github.com/ocaml/dune/issues/3569
;
; This seems like it could cause builds of Dream to break due to packaging
; details changing in upstream deps. Even if this the underlying feature is
; added to the compiler as discussed in the issue, builds of Dream with earlier
; compiler versions will still be threatened.
14 changes: 7 additions & 7 deletions src/http/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
dream.localhost
dream.middleware
dream.pure
gluten
gluten-lwt-unix
h2
h2-lwt-unix
httpaf
httpaf-lwt-unix
dream.gluten
dream.gluten-lwt-unix
dream.h2
dream.h2-lwt-unix
dream.httpaf
dream.httpaf-lwt-unix
lwt
lwt.unix
lwt_ssl
ssl
websocketaf
dream.websocketaf
)
(preprocess (pps lwt_ppx))
(instrumentation (backend bisect_ppx)))
145 changes: 145 additions & 0 deletions src/vendor/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
(data_only_dirs *)



(subdir gluten/lib
(library
(name gluten)
(public_name dream.gluten)
(libraries
bigstringaf
faraday)))

(subdir gluten/lwt
(library
(name gluten_lwt)
(public_name dream.gluten-lwt)
(libraries
dream.gluten
lwt)))

(subdir gluten/lwt-unix
(library
(name gluten_lwt_unix)
(public_name dream.gluten-lwt-unix)
(libraries
faraday-lwt-unix
dream.gluten-lwt
lwt.unix
(select
ssl_io.ml
from
(lwt_ssl -> ssl_io.real.ml)
(-> ssl_io.dummy.ml))
(select
tls_io.ml
from
(tls.lwt -> tls_io.real.ml)
(-> tls_io.dummy.ml)))
(modules gluten_lwt_unix tls_io ssl_io)))



(subdir websocketaf/lib
(library
(name websocketaf)
(public_name dream.websocketaf)
(libraries
angstrom
base64
bigstringaf
faraday
dream.gluten
httpaf
result)))



(subdir httpaf/lib
(library
(name httpaf)
(public_name dream.httpaf)
(libraries
angstrom
bigstringaf
faraday
result)))

(subdir httpaf/lwt
(library
(name httpaf_lwt)
(public_name dream.httpaf-lwt)
(libraries
dream.gluten
dream.gluten-lwt
dream.httpaf
lwt)))

(subdir httpaf/lwt-unix
(library
(name httpaf_lwt_unix)
(public_name dream.httpaf-lwt-unix)
(libraries
faraday-lwt-unix
dream.gluten-lwt-unix
dream.httpaf
dream.httpaf-lwt
lwt.unix)))



(subdir h2/hpack/util
(executables
(names gen_huffman gen_static)
(libraries
compiler-libs.common)))

(subdir h2/hpack/src
(library
(name hpack)
(public_name dream.hpack)
(libraries
angstrom
faraday))
(rule
(targets huffman_table.ml)
(deps ../util/huffman_table.txt)
(action
(with-stdout-to
%{targets}
(run ../util/gen_huffman.exe %{deps})))))

(subdir h2/lib
(library
(name h2)
(public_name dream.h2)
(libraries
angstrom
base64
bigstringaf
faraday
dream.hpack
dream.httpaf
psq
result)))

(subdir h2/lwt
(library
(name h2_lwt)
(public_name dream.h2-lwt)
(libraries
dream.gluten
dream.gluten-lwt
lwt
dream.h2)))

(subdir h2/lwt-unix
(library
(name h2_lwt_unix)
(public_name dream.h2-lwt-unix)
(libraries
faraday-lwt-unix
dream.gluten-lwt-unix
dream.h2
dream.h2-lwt
lwt.unix)))

0 comments on commit 343e912

Please sign in to comment.