From 590ddb750fe6c68b2e91449b715a87b2abb9bfcd Mon Sep 17 00:00:00 2001 From: Pierre Chambart Date: Thu, 18 Jan 2018 16:18:55 +0100 Subject: [PATCH] Change compiler's requested version --- Makefile | 7 ++ docs/introduction/howto.rst | 4 +- scripts/ci/create_docker_image.opam.sh | 2 +- .../ci/create_opam_repository.tezos_deps.sh | 2 +- scripts/opam-pin.sh | 1 + scripts/opam-unpin.sh | 2 +- scripts/version.sh | 4 +- src/lib_base/cli_entries.ml | 7 +- src/lib_client_base_unix/client_main_run.ml | 4 +- .../tezos-protocol-compiler.opam | 2 +- src/lib_protocol_environment/sigs/v1/map.mli | 74 +++++++++++++++++++ src/lib_protocol_environment/sigs/v1/set.mli | 60 +++++++++++++++ 12 files changed, 156 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 71b1de33c..05104e2da 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,13 @@ DEV ?= --dev PACKAGES:=$(patsubst %.opam,%,$(notdir $(shell find -name *.opam))) +current_ocaml_version := $(shell ocamlc -version) +include scripts/version.sh + +ifneq (${current_ocaml_version},${ocaml_version}) +$(error Unexpected ocaml version (found: ${current_ocaml_version}, expected: ${ocaml_version})) +endif + all: @jbuilder build ${DEV} \ src/bin_node/main.exe \ diff --git a/docs/introduction/howto.rst b/docs/introduction/howto.rst index 994c87caa..267d1b972 100644 --- a/docs/introduction/howto.rst +++ b/docs/introduction/howto.rst @@ -4,7 +4,7 @@ How to build and run Build instructions ------------------ -To compile Tezos, you need an OCaml compiler (version 4.04.2) and all +To compile Tezos, you need an OCaml compiler (version 4.06.0) and all the libraries listed in the various ``tezos-*.opam`` files. The best way to install all dependencies is by first installing @@ -19,7 +19,7 @@ projects or other versions of Tezos. :: opam update - opam switch "tezos" --alias-of 4.04.2 + opam switch "tezos" --alias-of 4.06.0 Note that if you previously created a switch named ``tezos`` but with an older OCaml version you need to remove the switch with diff --git a/scripts/ci/create_docker_image.opam.sh b/scripts/ci/create_docker_image.opam.sh index 2fd7ab252..60eb49527 100755 --- a/scripts/ci/create_docker_image.opam.sh +++ b/scripts/ci/create_docker_image.opam.sh @@ -74,7 +74,7 @@ RUN mkdir ~/.ssh && \ git config --global user.name "Tezos CI" && \ opam init --bare --no-setup --yes \ tezos_deps /home/opam/opam-repository-tezos_deps && \ - opam switch create --yes tezos ocaml-base-compiler.4.04.2 + opam switch create --yes tezos ocaml-base-compiler.${ocaml_version} RUN opam install --yes opam-depext diff --git a/scripts/ci/create_opam_repository.tezos_deps.sh b/scripts/ci/create_opam_repository.tezos_deps.sh index f8e8d95a0..5f2d3abef 100755 --- a/scripts/ci/create_opam_repository.tezos_deps.sh +++ b/scripts/ci/create_opam_repository.tezos_deps.sh @@ -77,7 +77,7 @@ COPY opam-repository-master opam-repository-master COPY opam /usr/local/bin/opam RUN apk add --no-cache ocaml build-base m4 tar xz bzip2 curl perl rsync RUN cd ./opam-repository-master/compilers && \ - ( ls -1 | grep -v \$(ocamlc --version) | xargs rm -r ) + ( ls -1 | grep -v ${ocaml_version} | xargs rm -r ) RUN opam init --no-setup --yes default ./opam-repository-master RUN opam install --yes opam-bundle COPY opam-repository-tezos opam-repository-tezos diff --git a/scripts/opam-pin.sh b/scripts/opam-pin.sh index 695c7a1c5..bd387cd6c 100755 --- a/scripts/opam-pin.sh +++ b/scripts/opam-pin.sh @@ -10,6 +10,7 @@ export OPAMYES=yes ### Temporary HACK ## Should be in sync with `opam-unpin.sh` +opam pin add --no-action leveldb git://github.com/chambart/ocaml-leveldb.git#update_4.06 opam pin add --no-action --dev-repo ocplib-json-typed ## Unpin package we used to pin... diff --git a/scripts/opam-unpin.sh b/scripts/opam-unpin.sh index c52f32c55..29e72466a 100755 --- a/scripts/opam-unpin.sh +++ b/scripts/opam-unpin.sh @@ -12,7 +12,7 @@ opam pin remove $packages ### Temporary HACK ## Should be in sync with `opam-pin.sh` -opam pin remove --no-action sodium +opam pin remove --no-action leveldb opam pin remove --no-action ocplib-json-typed ### End of temporary HACK diff --git a/scripts/version.sh b/scripts/version.sh index 71a66183f..3129f08f3 100644 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -1,10 +1,10 @@ #! /bin/sh -## `ocaml-verions` should be in sync with +## `ocaml-version` should be in sync with `README.rst` and ## `lib.protocol-compiler/tezos-protocol-compiler.opam` alpine_version=3.6 -ocaml_version=4.04.2 +ocaml_version=4.06.1 leveldb_version=1.18 opam_version=2.0.0~rc opam_tag=2.0.0-rc diff --git a/src/lib_base/cli_entries.ml b/src/lib_base/cli_entries.ml index 190d35d8b..612dee283 100644 --- a/src/lib_base/cli_entries.ml +++ b/src/lib_base/cli_entries.ml @@ -293,7 +293,7 @@ let setup_formatter ppf format verbosity = Format.pp_get_formatter_tag_functions ppf (), Format.pp_get_print_tags ppf () in begin - Format.pp_flush_formatter ppf ; + Format.pp_print_flush ppf () ; Format.pp_set_formatter_out_functions ppf { out_string = (fun s b a -> @@ -302,7 +302,8 @@ let setup_formatter ppf format verbosity = else if not !skip then orig_out_functions.out_string s b a) ; out_spaces = (fun n -> if not !skip then orig_out_functions.out_spaces n) ; out_newline = (fun () -> if not !skip then orig_out_functions.out_newline ()) ; - out_flush = (fun () -> if not !skip then orig_out_functions.out_flush ()) } ; + out_flush = (fun () -> if not !skip then orig_out_functions.out_flush ()) ; + out_indent = orig_out_functions.out_indent } ; let levels = ref [] in let setup_level (level, op) = if op level verbosity then @@ -499,7 +500,7 @@ let setup_formatter ppf format verbosity = orig_state let restore_formatter ppf (out_functions, tag_functions, tags) = - Format.pp_flush_formatter ppf ; + Format.pp_print_flush ppf () ; Format.pp_set_formatter_out_functions ppf out_functions ; Format.pp_set_formatter_tag_functions ppf tag_functions ; Format.pp_set_print_tags ppf tags diff --git a/src/lib_client_base_unix/client_main_run.ml b/src/lib_client_base_unix/client_main_run.ml index 0d2429b92..cea5cdf28 100644 --- a/src/lib_client_base_unix/client_main_run.ml +++ b/src/lib_client_base_unix/client_main_run.ml @@ -120,8 +120,8 @@ let main select_commands = Format.printf "@{@{Fatal error@}@} %s." (Printexc.to_string exn) ; Lwt.return 1 end >>= fun retcode -> - Format.pp_flush_formatter Format.std_formatter ; - Format.pp_flush_formatter Format.err_formatter ; + Format.pp_print_flush Format.err_formatter () ; + Format.pp_print_flush Format.std_formatter () ; Lwt.return retcode (* Where all the user friendliness starts *) diff --git a/src/lib_protocol_compiler/tezos-protocol-compiler.opam b/src/lib_protocol_compiler/tezos-protocol-compiler.opam index eccc78a64..9ecae6fa8 100644 --- a/src/lib_protocol_compiler/tezos-protocol-compiler.opam +++ b/src/lib_protocol_compiler/tezos-protocol-compiler.opam @@ -23,4 +23,4 @@ build-test: [ [ "jbuilder" "runtest" "-p" name "-j" jobs ] ] ## ocaml-version should be in sync with `script/version.sh` -available: [ ocaml-version = "4.04.2" ] \ No newline at end of file +available: [ ocaml-version = "4.06.1" ] \ No newline at end of file diff --git a/src/lib_protocol_environment/sigs/v1/map.mli b/src/lib_protocol_environment/sigs/v1/map.mli index 842c049bc..d36d2e9d9 100644 --- a/src/lib_protocol_environment/sigs/v1/map.mli +++ b/src/lib_protocol_environment/sigs/v1/map.mli @@ -86,6 +86,19 @@ sig of [x] in [m] disappears. @before 4.03 Physical equality was not ensured. *) + val update: key -> ('a option -> 'a option) -> 'a t -> 'a t + (** [update x f m] returns a map containing the same bindings as + [m], except for the binding of [x]. Depending on the value of + [y] where [y] is [f (find_opt x m)], the binding of [x] is + added, removed or updated. If [y] is [None], the binding is + removed if it exists; otherwise, if [y] is [Some z] then [x] + is associated to [z] in the resulting map. If [x] was already + bound in [m] to a value that is physically equal to [z], [m] + is returned unchanged (the result of the function is then + physically equal to [m]). + @since 4.06.0 + *) + val singleton: key -> 'a -> 'a t (** [singleton x y] returns the one-element map that contains a binding [y] for [x]. @@ -184,12 +197,25 @@ sig @since 3.12.0 *) + val min_binding_opt: 'a t -> (key * 'a) option + (** Return the smallest binding of the given map + (with respect to the [Ord.compare] ordering), or [None] + if the map is empty. + @since 4.05 + *) + val max_binding: 'a t -> (key * 'a) (** Same as {!Map.S.min_binding}, but returns the largest binding of the given map. @since 3.12.0 *) + val max_binding_opt: 'a t -> (key * 'a) option + (** Same as {!Map.S.min_binding_opt}, but returns the largest binding + of the given map. + @since 4.05 + *) + val choose: 'a t -> (key * 'a) (** Return one binding of the given map, or raise [Not_found] if the map is empty. Which binding is chosen is unspecified, @@ -197,6 +223,13 @@ sig @since 3.12.0 *) + val choose_opt: 'a t -> (key * 'a) option + (** Return one binding of the given map, or [None] if + the map is empty. Which binding is chosen is unspecified, + but equal bindings will be chosen for equal maps. + @since 4.05 + *) + val split: key -> 'a t -> 'a t * 'a option * 'a t (** [split x m] returns a triple [(l, data, r)], where [l] is the map with all the bindings of [m] whose key @@ -212,6 +245,47 @@ sig (** [find x m] returns the current binding of [x] in [m], or raises [Not_found] if no such binding exists. *) + + val find_opt: key -> 'a t -> 'a option + (** [find_opt x m] returns [Some v] if the current binding of [x] + in [m] is [v], or [None] if no such binding exists. + @since 4.05 + *) + + val find_first: (key -> bool) -> 'a t -> key * 'a + (** [find_first f m], where [f] is a monotonically increasing function, + returns the binding of [m] with the lowest key [k] such that [f k], + or raises [Not_found] if no such key exists. + + For example, [find_first (fun k -> Ord.compare k x >= 0) m] will return + the first binding [k, v] of [m] where [Ord.compare k x >= 0] + (intuitively: [k >= x]), or raise [Not_found] if [x] is greater than any + element of [m]. + + @since 4.05 + *) + + val find_first_opt: (key -> bool) -> 'a t -> (key * 'a) option + (** [find_first_opt f m], where [f] is a monotonically increasing function, + returns an option containing the binding of [m] with the lowest key [k] + such that [f k], or [None] if no such key exists. + @since 4.05 + *) + + val find_last: (key -> bool) -> 'a t -> key * 'a + (** [find_last f m], where [f] is a monotonically decreasing function, + returns the binding of [m] with the highest key [k] such that [f k], + or raises [Not_found] if no such key exists. + @since 4.05 + *) + + val find_last_opt: (key -> bool) -> 'a t -> (key * 'a) option + (** [find_last_opt f m], where [f] is a monotonically decreasing function, + returns an option containing the binding of [m] with the highest key [k] + such that [f k], or [None] if no such key exists. + @since 4.05 + *) + val map: ('a -> 'b) -> 'a t -> 'b t (** [map f m] returns a map with same domain as [m], where the associated value [a] of all bindings of [m] has been diff --git a/src/lib_protocol_environment/sigs/v1/set.mli b/src/lib_protocol_environment/sigs/v1/set.mli index a44c6ee95..90dd25ab0 100644 --- a/src/lib_protocol_environment/sigs/v1/set.mli +++ b/src/lib_protocol_environment/sigs/v1/set.mli @@ -168,15 +168,35 @@ sig (with respect to the [Ord.compare] ordering), or raise [Not_found] if the set is empty. *) + val min_elt_opt: t -> elt option + (** Return the smallest element of the given set + (with respect to the [Ord.compare] ordering), or [None] + if the set is empty. + @since 4.05 + *) + val max_elt: t -> elt (** Same as {!Set.S.min_elt}, but returns the largest element of the given set. *) + val max_elt_opt: t -> elt option + (** Same as {!Set.S.min_elt_opt}, but returns the largest element of the + given set. + @since 4.05 + *) + val choose: t -> elt (** Return one element of the given set, or raise [Not_found] if the set is empty. Which element is chosen is unspecified, but equal elements will be chosen for equal sets. *) + val choose_opt: t -> elt option + (** Return one element of the given set, or [None] if + the set is empty. Which element is chosen is unspecified, + but equal elements will be chosen for equal sets. + @since 4.05 + *) + val split: elt -> t -> t * bool * t (** [split x s] returns a triple [(l, present, r)], where [l] is the set of elements of [s] that are @@ -192,6 +212,46 @@ sig exists. @since 4.01.0 *) + val find_opt: elt -> t -> elt option + (** [find_opt x s] returns the element of [s] equal to [x] (according + to [Ord.compare]), or [None] if no such element + exists. + @since 4.05 *) + + val find_first: (elt -> bool) -> t -> elt + (** [find_first f s], where [f] is a monotonically increasing function, + returns the lowest element [e] of [s] such that [f e], + or raises [Not_found] if no such element exists. + + For example, [find_first (fun e -> Ord.compare e x >= 0) s] will return + the first element [e] of [s] where [Ord.compare e x >= 0] (intuitively: + [e >= x]), or raise [Not_found] if [x] is greater than any element of + [s]. + + @since 4.05 + *) + + val find_first_opt: (elt -> bool) -> t -> elt option + (** [find_first_opt f s], where [f] is a monotonically increasing function, + returns an option containing the lowest element [e] of [s] such that + [f e], or [None] if no such element exists. + @since 4.05 + *) + + val find_last: (elt -> bool) -> t -> elt + (** [find_last f s], where [f] is a monotonically decreasing function, + returns the highest element [e] of [s] such that [f e], + or raises [Not_found] if no such element exists. + @since 4.05 + *) + + val find_last_opt: (elt -> bool) -> t -> elt option + (** [find_last_opt f s], where [f] is a monotonically decreasing function, + returns an option containing the highest element [e] of [s] such that + [f e], or [None] if no such element exists. + @since 4.05 + *) + val of_list: elt list -> t (** [of_list l] creates a set from a list of elements. This is usually more efficient than folding [add] over the list,