Makefile: praise the return of utop.

The Makefile is really hackish...
This commit is contained in:
Grégoire Henry 2017-02-24 17:10:19 +01:00
parent bc16b027c2
commit 09dcb59c14
4 changed files with 83 additions and 62 deletions

2
.gitignore vendored
View File

@ -5,6 +5,8 @@
/tezos-webclient /tezos-webclient
/tezos-attacker /tezos-attacker
/src/.ocamlinit.utils
/src/.ocamlinit.node
/src/Makefile.local /src/Makefile.local
/src/webclient_static.ml /src/webclient_static.ml

View File

@ -65,6 +65,8 @@ node/updater/proto_environment.cmi: \
@echo OCAMLOPT ${TARGET} $@ @echo OCAMLOPT ${TARGET} $@
@$(OCAMLOPT) -nopervasives -nostdlib -opaque -I tmp -I node/updater -c $< @$(OCAMLOPT) -nopervasives -nostdlib -opaque -I tmp -I node/updater -c $<
node/updater/protocol.cmi: node/updater/protocol.cmx
partial-clean:: partial-clean::
rm -f node/updater/proto_environment.mli rm -f node/updater/proto_environment.mli
rm -f node/updater/environment_gen rm -f node/updater/environment_gen
@ -190,6 +192,7 @@ UTILS_PACKAGES := \
calendar \ calendar \
ezjsonm \ ezjsonm \
ipaddr.unix \ ipaddr.unix \
lwt.unix \
mtime.os \ mtime.os \
nocrypto \ nocrypto \
sodium \ sodium \
@ -208,6 +211,12 @@ utils.cmxa: ${UTILS_LIB_IMPLS:.ml=.cmx}
@echo LINK $(notdir $@) @echo LINK $(notdir $@)
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^ @${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
utils.top: DEVFLAGS=
utils.top:
( $(patsubst %, echo "#require \"%\";;" ; ,${UTILS_PACKAGES}) ) > .ocamlinit.utils
( $(patsubst %, echo "#mod_use \"%\";;" ; ,${MINUTILS_LIB_IMPLS} ${UTILS_LIB_IMPLS}) ) >> .ocamlinit.utils
utop -init .ocamlinit.utils ${OCAMLFLAGS}
############################################################################ ############################################################################
## Node protocol compiler (also embedded in the main program) ## Node protocol compiler (also embedded in the main program)
############################################################################ ############################################################################
@ -280,7 +289,6 @@ NODE_LIB_INTFS := \
node/db/store.mli \ node/db/store.mli \
node/db/db_proxy.mli \ node/db/db_proxy.mli \
\ \
node/updater/protocol.mli \
node/updater/updater.mli \ node/updater/updater.mli \
node/updater/proto_environment.mli \ node/updater/proto_environment.mli \
node/updater/register.mli \ node/updater/register.mli \
@ -319,6 +327,7 @@ NODE_LIB_IMPLS := \
node/db/context.ml \ node/db/context.ml \
node/db/db_proxy.ml \ node/db/db_proxy.ml \
\ \
node/updater/protocol.ml \
node/updater/updater.ml \ node/updater/updater.ml \
node/updater/environment.ml \ node/updater/environment.ml \
node/updater/proto_environment.ml \ node/updater/proto_environment.ml \
@ -390,6 +399,14 @@ ${TZNODE}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa ${EMBEDDED_NODE_PROT
partial-clean:: partial-clean::
-rm -f proto/*.cm* proto/*.a -rm -f proto/*.cm* proto/*.a
node.top: DEVFLAGS=
node.top: ${MINUTILS_LIB_IMPLS} ${UTILS_LIB_IMPLS} ${COMPILER_LIB_IMPLS} ${NODE_LIB_IMPLS}
( $(patsubst %, echo "#require \"%\";;" ; ,${NODE_PACKAGES}) ) > .ocamlinit.node
( $(patsubst %, echo "#mod_use \"%\";;" ; ,${MINUTILS_LIB_IMPLS} ${UTILS_LIB_IMPLS}) ) >> .ocamlinit.node
( $(patsubst %, echo "open %;;" ; ,Error_monad Hash Utils) ) >> .ocamlinit.node
( $(patsubst %, echo "#mod_use \"%\";;" ; ,${COMPILER_LIB_IMPLS} ${NODE_LIB_IMPLS}) ) >> .ocamlinit.node
utop -init .ocamlinit.node ${OCAMLFLAGS}
## Embedded protocol modules ## Embedded protocol modules
.SECONDEXPANSION: .SECONDEXPANSION:

View File

@ -95,6 +95,7 @@ type template = Lwt_log.template
let default_template = "$(date) - $(section): $(message)" let default_template = "$(date) - $(section): $(message)"
module Output = struct module Output = struct
type t = type t =
| Null | Null
| Stdout | Stdout
@ -102,10 +103,7 @@ module Output = struct
| File of string | File of string
| Syslog of Lwt_log.syslog_facility | Syslog of Lwt_log.syslog_facility
let encoding = let to_string : t -> string = function
let open Data_encoding in
conv
(function
| Null -> "/dev/null" | Null -> "/dev/null"
| Stdout -> "stdout" | Stdout -> "stdout"
| Stderr -> "stderr" | Stderr -> "stderr"
@ -132,8 +130,9 @@ module Output = struct
| Syslog `UUCP -> "syslog:uucp" | Syslog `UUCP -> "syslog:uucp"
| Syslog `NTP -> "syslog:ntp" | Syslog `NTP -> "syslog:ntp"
| Syslog `Security -> "syslog:security" | Syslog `Security -> "syslog:security"
| Syslog `Console -> "syslog:console") | Syslog `Console -> "syslog:console"
(function
let of_string : string -> t = function
| "/dev/null" | "null" -> Null | "/dev/null" | "null" -> Null
| "stdout" -> Stdout | "stdout" -> Stdout
| "stderr" -> Stderr | "stderr" -> Stderr
@ -163,8 +162,11 @@ module Output = struct
(* | s when start_with "syslog:" FIXME error or warning. *) (* | s when start_with "syslog:" FIXME error or warning. *)
| fp -> | fp ->
(* TODO check absolute path *) (* TODO check absolute path *)
File fp) File fp
string
let encoding =
let open Data_encoding in
conv to_string of_string string
let of_string str = let of_string str =
try try