From 140a0fe0b2d76425ee664c4cada1ff00f85822f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 11:33:05 +0100 Subject: [PATCH 01/16] Temporary debug prints for build-and-package failure --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc95f2f4b..08275dfc8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,8 +25,8 @@ dont-merge-to-master: # To run in sequence and save CPU usage, use stage: build_and_package_binaries stage: test script: - - $build_binary_script "$target_os_family" "$target_os" "$target_os_version" - - $package_binary_script "$target_os_family" "$target_os" "$target_os_version" + - $build_binary_script "$target_os_family" "$target_os" "$target_os_version" || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) + - $package_binary_script "$target_os_family" "$target_os" "$target_os_version" || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) artifacts: paths: - dist/package/**/* @@ -46,12 +46,12 @@ dont-merge-to-master: - eval $(opam config env) - scripts/setup_switch.sh - eval $(opam config env) - - scripts/setup_repos.sh + - scripts/setup_repos.sh || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) # install deps for internal documentation - - scripts/install_vendors_deps.sh + - scripts/install_vendors_deps.sh || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) - opam install -y odoc - - scripts/build_ligo_local.sh + - scripts/build_ligo_local.sh || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) # build with odoc - dune build @doc From 3969df5a5d17538c03faf9d95ca62a35ee4e4282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 11:35:05 +0100 Subject: [PATCH 02/16] Fixes in SH scripts --- scripts/build_docker_image.sh | 2 +- scripts/distribution/generic/build.sh | 1 + scripts/distribution/generic/package.sh | 1 + scripts/distribution/generic/parameters.sh | 11 +++++++---- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/build_docker_image.sh b/scripts/build_docker_image.sh index 260a530c7..0aaefe8c8 100755 --- a/scripts/build_docker_image.sh +++ b/scripts/build_docker_image.sh @@ -1,3 +1,3 @@ #!/bin/sh set -e -docker build -t "${LIGO_REGISTRY_IMAGE_BUILD:-ligolang/ligo}:next" -f ./docker/distribution/debian/distribute.Dockerfile . \ No newline at end of file +docker build -t "${LIGO_REGISTRY_IMAGE_BUILD:-ligolang/ligo}:next" -f ./docker/distribution/debian/distribute.Dockerfile . diff --git a/scripts/distribution/generic/build.sh b/scripts/distribution/generic/build.sh index 49aba15e1..48971962a 100755 --- a/scripts/distribution/generic/build.sh +++ b/scripts/distribution/generic/build.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -e dockerfile_name="build" # Generic dockerfile diff --git a/scripts/distribution/generic/package.sh b/scripts/distribution/generic/package.sh index 79be37d41..266678ec4 100755 --- a/scripts/distribution/generic/package.sh +++ b/scripts/distribution/generic/package.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -e dockerfile_name="package" dockerfile="" diff --git a/scripts/distribution/generic/parameters.sh b/scripts/distribution/generic/parameters.sh index 3899711d8..98e35e20c 100644 --- a/scripts/distribution/generic/parameters.sh +++ b/scripts/distribution/generic/parameters.sh @@ -1,11 +1,14 @@ +#!/bin/sh +set -e + # This script accepts three arguments, os family, os and its version, # which are subsequently used to fetch the respective docker # image from the ocaml/infrastructure project. # # https://github.com/ocaml/infrastructure/wiki/Containers#selecting-linux-distributions -target_os_family=$1 -target_os=$2 -target_os_version=$3 +target_os_family="$1" +target_os="$2" +target_os_version="$3" # Variables configured at the CI level dist="$LIGO_DIST_DIR" @@ -29,4 +32,4 @@ fi target_os_specific_dockerfile="./docker/distribution/$target_os_family/$target_os/$dockerfile_name.Dockerfile" if test -f "$target_os_specific_dockerfile"; then dockerfile="$target_os_specific_dockerfile" -fi \ No newline at end of file +fi From 8f03d45ec3abfead4c990e6a09c653c667a26ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 11:35:31 +0100 Subject: [PATCH 03/16] Make more scripts print their commands, to help debug issues in GitLab --- scripts/build_docker_image.sh | 1 + scripts/build_ligo_local.sh | 1 + scripts/distribution/generic/build.sh | 1 + scripts/distribution/generic/package.sh | 1 + scripts/distribution/generic/parameters.sh | 1 + scripts/install_native_dependencies.sh | 1 + scripts/install_vendors_deps.sh | 1 + 7 files changed, 7 insertions(+) diff --git a/scripts/build_docker_image.sh b/scripts/build_docker_image.sh index 0aaefe8c8..f342b424f 100755 --- a/scripts/build_docker_image.sh +++ b/scripts/build_docker_image.sh @@ -1,3 +1,4 @@ #!/bin/sh set -e +set -x docker build -t "${LIGO_REGISTRY_IMAGE_BUILD:-ligolang/ligo}:next" -f ./docker/distribution/debian/distribute.Dockerfile . diff --git a/scripts/build_ligo_local.sh b/scripts/build_ligo_local.sh index b78e4ffd6..fb556805a 100755 --- a/scripts/build_ligo_local.sh +++ b/scripts/build_ligo_local.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e +set -x eval $(opam config env) dune build -p ligo diff --git a/scripts/distribution/generic/build.sh b/scripts/distribution/generic/build.sh index 48971962a..968f55a21 100755 --- a/scripts/distribution/generic/build.sh +++ b/scripts/distribution/generic/build.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e +set -x dockerfile_name="build" # Generic dockerfile diff --git a/scripts/distribution/generic/package.sh b/scripts/distribution/generic/package.sh index 266678ec4..d9d047e6d 100755 --- a/scripts/distribution/generic/package.sh +++ b/scripts/distribution/generic/package.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e +set -x dockerfile_name="package" dockerfile="" diff --git a/scripts/distribution/generic/parameters.sh b/scripts/distribution/generic/parameters.sh index 98e35e20c..2241b9fb0 100644 --- a/scripts/distribution/generic/parameters.sh +++ b/scripts/distribution/generic/parameters.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e +set -x # This script accepts three arguments, os family, os and its version, # which are subsequently used to fetch the respective docker diff --git a/scripts/install_native_dependencies.sh b/scripts/install_native_dependencies.sh index 2a0e56903..191ae5502 100755 --- a/scripts/install_native_dependencies.sh +++ b/scripts/install_native_dependencies.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e +set -x . /etc/os-release if [ $ID = arch ] diff --git a/scripts/install_vendors_deps.sh b/scripts/install_vendors_deps.sh index 15f9b47d4..5c870ffdc 100755 --- a/scripts/install_vendors_deps.sh +++ b/scripts/install_vendors_deps.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e +set -x # Install local dependencies opam install -y --deps-only --with-test ./ligo.opam $(find vendors -name \*.opam) From 35815ce5b41c371227fcf5fe23c69bcc8a217b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 11:39:31 +0100 Subject: [PATCH 04/16] Removed vendors/UnionFind/UnionFind.install which is a generated file that was .gitignored but had been added by accident --- vendors/UnionFind/UnionFind.install | 36 ----------------------------- 1 file changed, 36 deletions(-) delete mode 100644 vendors/UnionFind/UnionFind.install diff --git a/vendors/UnionFind/UnionFind.install b/vendors/UnionFind/UnionFind.install deleted file mode 100644 index 692984e20..000000000 --- a/vendors/UnionFind/UnionFind.install +++ /dev/null @@ -1,36 +0,0 @@ -lib: [ - "_build/install/default/lib/UnionFind/META" - "_build/install/default/lib/UnionFind/Partition.cmi" - "_build/install/default/lib/UnionFind/Partition.cmti" - "_build/install/default/lib/UnionFind/Partition.mli" - "_build/install/default/lib/UnionFind/Partition0.cmi" - "_build/install/default/lib/UnionFind/Partition0.cmt" - "_build/install/default/lib/UnionFind/Partition0.cmx" - "_build/install/default/lib/UnionFind/Partition0.ml" - "_build/install/default/lib/UnionFind/Partition1.cmi" - "_build/install/default/lib/UnionFind/Partition1.cmt" - "_build/install/default/lib/UnionFind/Partition1.cmx" - "_build/install/default/lib/UnionFind/Partition1.ml" - "_build/install/default/lib/UnionFind/Partition2.cmi" - "_build/install/default/lib/UnionFind/Partition2.cmt" - "_build/install/default/lib/UnionFind/Partition2.cmx" - "_build/install/default/lib/UnionFind/Partition2.ml" - "_build/install/default/lib/UnionFind/Partition3.cmi" - "_build/install/default/lib/UnionFind/Partition3.cmt" - "_build/install/default/lib/UnionFind/Partition3.cmx" - "_build/install/default/lib/UnionFind/Partition3.ml" - "_build/install/default/lib/UnionFind/UnionFind.a" - "_build/install/default/lib/UnionFind/UnionFind.cma" - "_build/install/default/lib/UnionFind/UnionFind.cmxa" - "_build/install/default/lib/UnionFind/UnionFind.cmxs" - "_build/install/default/lib/UnionFind/dune-package" - "_build/install/default/lib/UnionFind/opam" - "_build/install/default/lib/UnionFind/unionFind.cmi" - "_build/install/default/lib/UnionFind/unionFind.cmt" - "_build/install/default/lib/UnionFind/unionFind.cmx" - "_build/install/default/lib/UnionFind/unionFind.ml" -] -doc: [ - "_build/install/default/doc/UnionFind/LICENSE" - "_build/install/default/doc/UnionFind/README.md" -] From 42699256e5bdb936b2653c9d8b491daff5931b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 11:50:28 +0100 Subject: [PATCH 05/16] Run adt_generator.exe as part of dune runtest --- src/stages/adt_generator/dune | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/stages/adt_generator/dune b/src/stages/adt_generator/dune index 4a52c6088..b47ce3191 100644 --- a/src/stages/adt_generator/dune +++ b/src/stages/adt_generator/dune @@ -16,3 +16,8 @@ (libraries ) ) + +(alias + (name runtest) + (action (run ./adt_generator.exe)) +) From 76ad9c47ec724e03d218ab688a1f366db9de6c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 11:42:32 +0100 Subject: [PATCH 06/16] cleanup --- src/passes/4-typer-old/typer.ml | 1 - src/stages/adt_generator/README | 4 ++-- src/stages/ast_typed/types.ml | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/passes/4-typer-old/typer.ml b/src/passes/4-typer-old/typer.ml index 87f4b2477..7c1cd41a4 100644 --- a/src/passes/4-typer-old/typer.ml +++ b/src/passes/4-typer-old/typer.ml @@ -649,7 +649,6 @@ and type_expression' : environment -> ?tv_opt:O.type_expression -> I.expression let wtype = Format.asprintf "Loops over collections expect lists, sets or maps, got type %a" O.PP.type_expression tv_col in fail @@ simple_error wtype in - let lname = lname in let e' = Environment.add_ez_binder lname input_type e in let%bind body = type_expression' ?tv_opt:(Some tv_out) e' result in let output_type = body.type_expression in diff --git a/src/stages/adt_generator/README b/src/stages/adt_generator/README index 20ecdfd43..2d1b53c3d 100644 --- a/src/stages/adt_generator/README +++ b/src/stages/adt_generator/README @@ -1,6 +1,6 @@ -Build with: +Build & test with: - dune build adt_generator.a + dune build adt_generator.exe && ../../../_build/default/src/stages/adt_generator/adt_generator.exe Run with diff --git a/src/stages/ast_typed/types.ml b/src/stages/ast_typed/types.ml index 5aa323c9b..8804e49e7 100644 --- a/src/stages/ast_typed/types.ml +++ b/src/stages/ast_typed/types.ml @@ -95,7 +95,6 @@ and matching = and ascription = {anno_expr: expression; type_annotation: type_expression} - and environment_element_definition = | ED_binder | ED_declaration of (expression * free_variables) From c3b1c1ac0f2182392ef3947a8c092f10791e6fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 11:49:13 +0100 Subject: [PATCH 07/16] Removed promote-until-clean because it moves the file out of _build instead of copying it, which causes issues for the gitlab build --- src/stages/adt_generator/dune | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stages/adt_generator/dune b/src/stages/adt_generator/dune index b47ce3191..1729a9aba 100644 --- a/src/stages/adt_generator/dune +++ b/src/stages/adt_generator/dune @@ -2,7 +2,8 @@ (target fold.ml) (deps generator.py) (action (with-stdout-to fold.ml (run python3 ./generator.py))) - (mode (promote (until-clean)))) +; (mode (promote (until-clean))) ; If this is uncommented, then "dune build -p ligo" can't find the file (but "dune build" can) +) ; (library ; (name adt_generator) ; (public_name ligo.adt_generator) From 2588de23951ee90102c3b453451ba56ec71acbd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 11:49:54 +0100 Subject: [PATCH 08/16] Remove generated file fold.ml --- src/stages/adt_generator/.gitignore | 2 + src/stages/adt_generator/dune | 4 +- src/stages/adt_generator/fold.ml | 185 +--------------------------- 3 files changed, 5 insertions(+), 186 deletions(-) create mode 100644 src/stages/adt_generator/.gitignore diff --git a/src/stages/adt_generator/.gitignore b/src/stages/adt_generator/.gitignore new file mode 100644 index 000000000..9ec2ad34e --- /dev/null +++ b/src/stages/adt_generator/.gitignore @@ -0,0 +1,2 @@ +# This is an auto-generated test file +/generated_fold.ml diff --git a/src/stages/adt_generator/dune b/src/stages/adt_generator/dune index 1729a9aba..d70d8647e 100644 --- a/src/stages/adt_generator/dune +++ b/src/stages/adt_generator/dune @@ -1,7 +1,7 @@ (rule - (target fold.ml) + (target generated_fold.ml) (deps generator.py) - (action (with-stdout-to fold.ml (run python3 ./generator.py))) + (action (with-stdout-to generated_fold.ml (run python3 ./generator.py))) ; (mode (promote (until-clean))) ; If this is uncommented, then "dune build -p ligo" can't find the file (but "dune build" can) ) ; (library diff --git a/src/stages/adt_generator/fold.ml b/src/stages/adt_generator/fold.ml index 4e4c41357..271974820 100644 --- a/src/stages/adt_generator/fold.ml +++ b/src/stages/adt_generator/fold.ml @@ -1,184 +1 @@ -open A - -type root' = - | A' of a' - | B' of int - | C' of string -and a' = - { - a1' : ta1' ; - a2' : ta2' ; - } -and ta1' = - | X' of root' - | Y' of ta2' -and ta2' = - | Z' of ta2' - | W' of unit - -type 'state continue_fold = - { - root : root -> 'state -> (root' * 'state) ; - root_A : a -> 'state -> (a' * 'state) ; - root_B : int -> 'state -> (int * 'state) ; - root_C : string -> 'state -> (string * 'state) ; - a : a -> 'state -> (a' * 'state) ; - a_a1 : ta1 -> 'state -> (ta1' * 'state) ; - a_a2 : ta2 -> 'state -> (ta2' * 'state) ; - ta1 : ta1 -> 'state -> (ta1' * 'state) ; - ta1_X : root -> 'state -> (root' * 'state) ; - ta1_Y : ta2 -> 'state -> (ta2' * 'state) ; - ta2 : ta2 -> 'state -> (ta2' * 'state) ; - ta2_Z : ta2 -> 'state -> (ta2' * 'state) ; - ta2_W : unit -> 'state -> (unit * 'state) ; - } - -type 'state fold_config = - { - root : root -> 'state -> ('state continue_fold) -> (root' * 'state) ; - root_pre_state : root -> 'state -> 'state ; - root_post_state : root -> root' -> 'state -> 'state ; - root_A : a -> 'state -> ('state continue_fold) -> (a' * 'state) ; - root_B : int -> 'state -> ('state continue_fold) -> (int * 'state) ; - root_C : string -> 'state -> ('state continue_fold) -> (string * 'state) ; - a : a -> 'state -> ('state continue_fold) -> (a' * 'state) ; - a_pre_state : a -> 'state -> 'state ; - a_post_state : a -> a' -> 'state -> 'state ; - a_a1 : ta1 -> 'state -> ('state continue_fold) -> (ta1' * 'state) ; - a_a2 : ta2 -> 'state -> ('state continue_fold) -> (ta2' * 'state) ; - ta1 : ta1 -> 'state -> ('state continue_fold) -> (ta1' * 'state) ; - ta1_pre_state : ta1 -> 'state -> 'state ; - ta1_post_state : ta1 -> ta1' -> 'state -> 'state ; - ta1_X : root -> 'state -> ('state continue_fold) -> (root' * 'state) ; - ta1_Y : ta2 -> 'state -> ('state continue_fold) -> (ta2' * 'state) ; - ta2 : ta2 -> 'state -> ('state continue_fold) -> (ta2' * 'state) ; - ta2_pre_state : ta2 -> 'state -> 'state ; - ta2_post_state : ta2 -> ta2' -> 'state -> 'state ; - ta2_Z : ta2 -> 'state -> ('state continue_fold) -> (ta2' * 'state) ; - ta2_W : unit -> 'state -> ('state continue_fold) -> (unit * 'state) ; - } - -(* Curries the "visitor" argument to the folds (non-customizable traversal functions). *) -let rec mk_continue_fold : type state . state fold_config -> state continue_fold = fun visitor -> - { - root = fold_root visitor ; - root_A = fold_root_A visitor ; - root_B = fold_root_B visitor ; - root_C = fold_root_C visitor ; - a = fold_a visitor ; - a_a1 = fold_a_a1 visitor ; - a_a2 = fold_a_a2 visitor ; - ta1 = fold_ta1 visitor ; - ta1_X = fold_ta1_X visitor ; - ta1_Y = fold_ta1_Y visitor ; - ta2 = fold_ta2 visitor ; - ta2_Z = fold_ta2_Z visitor ; - ta2_W = fold_ta2_W visitor ; -} - -and fold_root : type state . state fold_config -> root -> state -> (root' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - let state = visitor.root_pre_state x state in - let (new_x, state) = visitor.root x state continue_fold in - let state = visitor.root_post_state x new_x state in - (new_x, state) - -and fold_root_A : type state . state fold_config -> a -> state -> (a' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - visitor.root_A x state continue_fold - -and fold_root_B : type state . state fold_config -> int -> state -> (int * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - visitor.root_B x state continue_fold - -and fold_root_C : type state . state fold_config -> string -> state -> (string * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - visitor.root_C x state continue_fold - -and fold_a : type state . state fold_config -> a -> state -> (a' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - let state = visitor.a_pre_state x state in - let (new_x, state) = visitor.a x state continue_fold in - let state = visitor.a_post_state x new_x state in - (new_x, state) - -and fold_a_a1 : type state . state fold_config -> ta1 -> state -> (ta1' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - visitor.a_a1 x state continue_fold - -and fold_a_a2 : type state . state fold_config -> ta2 -> state -> (ta2' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - visitor.a_a2 x state continue_fold - -and fold_ta1 : type state . state fold_config -> ta1 -> state -> (ta1' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - let state = visitor.ta1_pre_state x state in - let (new_x, state) = visitor.ta1 x state continue_fold in - let state = visitor.ta1_post_state x new_x state in - (new_x, state) - -and fold_ta1_X : type state . state fold_config -> root -> state -> (root' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - visitor.ta1_X x state continue_fold - -and fold_ta1_Y : type state . state fold_config -> ta2 -> state -> (ta2' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - visitor.ta1_Y x state continue_fold - -and fold_ta2 : type state . state fold_config -> ta2 -> state -> (ta2' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - let state = visitor.ta2_pre_state x state in - let (new_x, state) = visitor.ta2 x state continue_fold in - let state = visitor.ta2_post_state x new_x state in - (new_x, state) - -and fold_ta2_Z : type state . state fold_config -> ta2 -> state -> (ta2' * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - visitor.ta2_Z x state continue_fold - -and fold_ta2_W : type state . state fold_config -> unit -> state -> (unit * state) = fun visitor x state -> - let continue_fold : state continue_fold = mk_continue_fold visitor in - visitor.ta2_W x state continue_fold - -let no_op : 'a fold_config = { - root = (fun v state continue -> - match v with - | A v -> let (v, state) = continue.root_A v state in (A' v, state) - | B v -> let (v, state) = continue.root_B v state in (B' v, state) - | C v -> let (v, state) = continue.root_C v state in (C' v, state) - ); - root_pre_state = (fun v state -> ignore v; state) ; - root_post_state = (fun v new_v state -> ignore (v, new_v); state) ; - root_A = (fun v state continue -> continue.a v state ) ; - root_B = (fun v state continue -> ignore continue; (v, state) ) ; - root_C = (fun v state continue -> ignore continue; (v, state) ) ; - a = (fun v state continue -> - match v with - { a1; a2; } -> - let (a1', state) = continue.a_a1 a1 state in - let (a2', state) = continue.a_a2 a2 state in - ({ a1'; a2'; }, state) - ); - a_pre_state = (fun v state -> ignore v; state) ; - a_post_state = (fun v new_v state -> ignore (v, new_v); state) ; - a_a1 = (fun v state continue -> continue.ta1 v state ) ; - a_a2 = (fun v state continue -> continue.ta2 v state ) ; - ta1 = (fun v state continue -> - match v with - | X v -> let (v, state) = continue.ta1_X v state in (X' v, state) - | Y v -> let (v, state) = continue.ta1_Y v state in (Y' v, state) - ); - ta1_pre_state = (fun v state -> ignore v; state) ; - ta1_post_state = (fun v new_v state -> ignore (v, new_v); state) ; - ta1_X = (fun v state continue -> continue.root v state ) ; - ta1_Y = (fun v state continue -> continue.ta2 v state ) ; - ta2 = (fun v state continue -> - match v with - | Z v -> let (v, state) = continue.ta2_Z v state in (Z' v, state) - | W v -> let (v, state) = continue.ta2_W v state in (W' v, state) - ); - ta2_pre_state = (fun v state -> ignore v; state) ; - ta2_post_state = (fun v new_v state -> ignore (v, new_v); state) ; - ta2_Z = (fun v state continue -> continue.ta2 v state ) ; - ta2_W = (fun v state continue -> ignore continue; (v, state) ) ; -} +include Generated_fold From 5151a0fd92586af5d899b4ce1d889380aa5b3fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 11:45:44 +0100 Subject: [PATCH 09/16] =?UTF-8?q?ADT=20generator:=20polymorphic=20types=20?= =?UTF-8?q?(list,=20option=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stages/adt_generator/a.ml | 21 +++++++++- src/stages/adt_generator/generator.py | 58 +++++++++++++++++++------- src/stages/adt_generator/use_a_fold.ml | 6 +-- 3 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/stages/adt_generator/a.ml b/src/stages/adt_generator/a.ml index f1d8b2fb1..34b611dc1 100644 --- a/src/stages/adt_generator/a.ml +++ b/src/stages/adt_generator/a.ml @@ -1,6 +1,6 @@ type root = -| A of a -| B of int +| A of rootA +| B of rootB | C of string and a = { @@ -15,3 +15,20 @@ and ta1 = and ta2 = | Z of ta2 | W of unit + +and rootA = + a list + +and rootB = + int list + +let fold_list v state continue = + let aux = fun (lst', state) elt -> + let (elt', state) = continue elt state in + (elt' :: lst' , state) in + List.fold_left aux ([], state) v + +let fold_option v state continue = + match v with + Some x -> continue x state + | None -> None diff --git a/src/stages/adt_generator/generator.py b/src/stages/adt_generator/generator.py index 65fe21878..48b8c5fd4 100644 --- a/src/stages/adt_generator/generator.py +++ b/src/stages/adt_generator/generator.py @@ -1,34 +1,49 @@ moduleName = "A" +variant="_ _variant" +record="_ _record" +def poly(x): return x adts = [ - # typename, variant?, fields_or_ctors - ("root", True, [ - # ctor, builtin, type - ("A", False, "a"), - ("B", True, "int"), + # typename, kind, fields_or_ctors + ("root", variant, [ + # ctor, builtin?, type + ("A", False, "rootA"), + ("B", False, "rootB"), ("C", True, "string"), ]), - ("a", False, [ + ("a", record, [ + # field, builtin?, type ("a1", False, "ta1"), ("a2", False, "ta2"), ]), - ("ta1", True, [ + ("ta1", variant, [ ("X", False, "root"), ("Y", False, "ta2"), ]), - ("ta2", True, [ + ("ta2", variant, [ ("Z", False, "ta2"), ("W", True, "unit"), ]), + # polymorphic type + ("rootA", poly("list"), + [ + # Position (0..n-1), builtin?, type argument + (0, False, "a") + ]), + ("rootB", poly("list"), + [ + # Position (0..n-1), builtin?, type argument + (0, True, "int") + ]), ] from collections import namedtuple -adt = namedtuple('adt', ['name', 'newName', 'isVariant', 'ctorsOrFields']) +adt = namedtuple('adt', ['name', 'newName', 'kind', 'ctorsOrFields']) ctorOrField = namedtuple('ctorOrField', ['name', 'newName', 'isBuiltin', 'type_', 'newType']) adts = [ adt( name = name, newName = f"{name}'", - isVariant = isVariant, + kind = kind, ctorsOrFields = [ ctorOrField( name = cf, @@ -40,23 +55,32 @@ adts = [ for (cf, isBuiltin, type_) in ctors ], ) - for (name, isVariant, ctors) in adts + for (name, kind, ctors) in adts ] +print("(* This is an auto-generated file. Do not edit. *)") + +print("") print("open %s" % moduleName) print("") for (index, t) in enumerate(adts): typeOrAnd = "type" if index == 0 else "and" print(f"{typeOrAnd} {t.newName} =") - if t.isVariant: + if t.kind == variant: for c in t.ctorsOrFields: print(f" | {c.newName} of {c.newType}") - else: + elif t.kind == record: print(" {") for f in t.ctorsOrFields: print(f" {f.newName} : {f.newType} ;") print(" }") + else: + print(" ", end='') + for a in t.ctorsOrFields: + print(f"{a.newType}", end=' ') + print(t.kind, end='') + print("") print("") print(f"type 'state continue_fold =") @@ -107,10 +131,10 @@ print("let no_op : 'a fold_config = {") for t in adts: print(f" {t.name} = (fun v state continue ->") print(" match v with") - if t.isVariant: + if t.kind == variant: for c in t.ctorsOrFields: print(f" | {c.name} v -> let (v, state) = continue.{t.name}_{c.name} v state in ({c.newName} v, state)") - else: + elif t.kind == record: print(" {", end=' ') for f in t.ctorsOrFields: print(f"{f.name};", end=' ') @@ -121,6 +145,10 @@ for t in adts: for f in t.ctorsOrFields: print(f"{f.newName};", end=' ') print("}, state)") + else: + print(f" v -> fold_{t.kind} v state (", end=' ') + print(", ".join([f"continue.{t.name}_{f.name}" for f in t.ctorsOrFields]), end='') + print(" )") print(" );") print(f" {t.name}_pre_state = (fun v state -> ignore v; state) ;") print(f" {t.name}_post_state = (fun v new_v state -> ignore (v, new_v); state) ;") diff --git a/src/stages/adt_generator/use_a_fold.ml b/src/stages/adt_generator/use_a_fold.ml index 6a73f4782..0fe476d42 100644 --- a/src/stages/adt_generator/use_a_fold.ml +++ b/src/stages/adt_generator/use_a_fold.ml @@ -4,7 +4,7 @@ open Fold (* TODO: how should we plug these into our test framework? *) let () = - let some_root : root = A { a1 = X (A { a1 = X (B 1) ; a2 = W () ; }) ; a2 = Z (W ()) ; } in + let some_root : root = A [{ a1 = X (A [{ a1 = X (B [1;2;3]) ; a2 = W () ; }]) ; a2 = Z (W ()) ; }] in let op = { no_op with a = fun the_a state continue_fold -> @@ -23,7 +23,7 @@ let () = () let () = - let some_root : root = A { a1 = X (A { a1 = X (B 1) ; a2 = W () ; }) ; a2 = Z (W ()) ; } in + let some_root : root = A [{ a1 = X (A [{ a1 = X (B [1;2;3]) ; a2 = W () ; }]) ; a2 = Z (W ()) ; }] in let op = { no_op with a_pre_state = fun _the_a state -> state + 1 } in let state = 0 in let (_, state) = fold_root op some_root state in @@ -33,7 +33,7 @@ let () = () let () = - let some_root : root = A { a1 = X (A { a1 = X (B 1) ; a2 = W () ; }) ; a2 = Z (W ()) ; } in + let some_root : root = A [{ a1 = X (A [{ a1 = X (B [1;2;3]) ; a2 = W () ; }]) ; a2 = Z (W ()) ; }] in let op = { no_op with a_post_state = fun _the_a _new_a state -> state + 1 } in let state = 0 in let (_, state) = fold_root op some_root state in From c71e47f252d9238007a7584b8050e1159fabde5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 19:01:26 +0100 Subject: [PATCH 10/16] Make menhir less verbose, to see error messages in gitlab. --- src/passes/1-parser/cameligo/dune | 2 +- src/passes/1-parser/pascaligo/dune | 2 +- src/passes/1-parser/reasonligo/dune | 2 +- vendors/Preproc/build.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/passes/1-parser/cameligo/dune b/src/passes/1-parser/cameligo/dune index 8824fdcd4..4e6829f1e 100644 --- a/src/passes/1-parser/cameligo/dune +++ b/src/passes/1-parser/cameligo/dune @@ -7,7 +7,7 @@ (menhir (merge_into Parser) (modules ParToken Parser) - (flags -la 1 --table --strict --explain --external-tokens LexToken)) + (flags --table --strict --external-tokens LexToken)) ;; Build of the parser as a library diff --git a/src/passes/1-parser/pascaligo/dune b/src/passes/1-parser/pascaligo/dune index d0d43f02f..e7b9a9a73 100644 --- a/src/passes/1-parser/pascaligo/dune +++ b/src/passes/1-parser/pascaligo/dune @@ -7,7 +7,7 @@ (menhir (merge_into Parser) (modules ParToken Parser) - (flags -la 1 --table --strict --explain --external-tokens LexToken)) + (flags --table --strict --external-tokens LexToken)) ;; Build of the parser as a library diff --git a/src/passes/1-parser/reasonligo/dune b/src/passes/1-parser/reasonligo/dune index 6eb7304b8..a1408af91 100644 --- a/src/passes/1-parser/reasonligo/dune +++ b/src/passes/1-parser/reasonligo/dune @@ -7,7 +7,7 @@ (menhir (merge_into Parser) (modules ParToken Parser) - (flags -la 1 --table --strict --explain --external-tokens LexToken)) + (flags --table --strict --external-tokens LexToken)) ;; Build of the parser as a library diff --git a/vendors/Preproc/build.sh b/vendors/Preproc/build.sh index e9d6546be..30e3ba705 100755 --- a/vendors/Preproc/build.sh +++ b/vendors/Preproc/build.sh @@ -2,7 +2,7 @@ set -x ocamllex.opt Escan.mll ocamllex.opt Preproc.mll -menhir -la 1 Eparser.mly +menhir Eparser.mly ocamlfind ocamlopt -strict-sequence -w +A-48-4 -c Etree.ml ocamlfind ocamlopt -strict-sequence -w +A-48-4 -c Error.ml ocamlfind ocamlopt -strict-sequence -w +A-48-4 -c Etree.ml From e84b739fbc21e87ba1f30588ccb85c537aa18c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 19:07:39 +0100 Subject: [PATCH 11/16] try to debug inside docker --- docker/distribution/generic/build.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/distribution/generic/build.Dockerfile b/docker/distribution/generic/build.Dockerfile index f6c9358e9..bd1ee920a 100644 --- a/docker/distribution/generic/build.Dockerfile +++ b/docker/distribution/generic/build.Dockerfile @@ -29,7 +29,7 @@ RUN opam update # Install ligo RUN sh scripts/install_vendors_deps.sh -RUN opam install -y . +RUN opam install -y . || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) # Use the ligo binary as a default command ENTRYPOINT [ "/home/opam/.opam/4.07/bin/ligo" ] From 7bad718135d1bac1cec162904d6f4430dde22088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 19:42:35 +0100 Subject: [PATCH 12/16] Add missing dependency on Python 3 --- scripts/install_build_environment.sh | 3 +++ scripts/install_native_dependencies.sh | 2 ++ tools/webide/Dockerfile | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/install_build_environment.sh b/scripts/install_build_environment.sh index 0dd33f068..628235e70 100755 --- a/scripts/install_build_environment.sh +++ b/scripts/install_build_environment.sh @@ -22,6 +22,7 @@ echo "Installing dependencies.." if [ -n "`uname -a | grep -i arch`" ] then sudo pacman -Sy --noconfirm \ + python \ make \ m4 \ gcc \ @@ -34,6 +35,8 @@ fi if [ -n "`uname -a | grep -i ubuntu`" ] then sudo apt-get install -y make \ + python3 \ + make \ m4 \ gcc \ patch \ diff --git a/scripts/install_native_dependencies.sh b/scripts/install_native_dependencies.sh index 191ae5502..f12e76cb2 100755 --- a/scripts/install_native_dependencies.sh +++ b/scripts/install_native_dependencies.sh @@ -7,6 +7,7 @@ if [ $ID = arch ] then pacman -Sy sudo pacman -S --noconfirm \ + python \ libevdev \ perl \ pkg-config \ @@ -21,6 +22,7 @@ then else apt-get update -qq apt-get -y -qq install \ + python3 \ libev-dev \ perl \ pkg-config \ diff --git a/tools/webide/Dockerfile b/tools/webide/Dockerfile index 4dfa9963a..212b12130 100644 --- a/tools/webide/Dockerfile +++ b/tools/webide/Dockerfile @@ -17,7 +17,7 @@ FROM node:12-buster WORKDIR /app -RUN apt-get update && apt-get -y install libev-dev perl pkg-config libgmp-dev libhidapi-dev m4 libcap-dev bubblewrap rsync +RUN apt-get update && apt-get -y install python3 libev-dev perl pkg-config libgmp-dev libhidapi-dev m4 libcap-dev bubblewrap rsync COPY ligo_deb10.deb /tmp/ligo_deb10.deb RUN dpkg -i /tmp/ligo_deb10.deb && rm /tmp/ligo_deb10.deb From e6dbe60c2cb6e41906eb1884cc51ee59a79771e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 19:54:26 +0100 Subject: [PATCH 13/16] Revert "try to debug inside docker" This reverts commit 37daa934d5e7ba60614a92cf0dfa9d4ebfac59d2. --- docker/distribution/generic/build.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/distribution/generic/build.Dockerfile b/docker/distribution/generic/build.Dockerfile index bd1ee920a..f6c9358e9 100644 --- a/docker/distribution/generic/build.Dockerfile +++ b/docker/distribution/generic/build.Dockerfile @@ -29,7 +29,7 @@ RUN opam update # Install ligo RUN sh scripts/install_vendors_deps.sh -RUN opam install -y . || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) +RUN opam install -y . # Use the ligo binary as a default command ENTRYPOINT [ "/home/opam/.opam/4.07/bin/ligo" ] From 76fa4b0549906960b134ca0ac0524120fd850c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 19:54:35 +0100 Subject: [PATCH 14/16] Revert "Make menhir less verbose, to see error messages in gitlab." This reverts commit b5f3ae76b049d4e712bd539b39d771191bc8978b. --- src/passes/1-parser/cameligo/dune | 2 +- src/passes/1-parser/pascaligo/dune | 2 +- src/passes/1-parser/reasonligo/dune | 2 +- vendors/Preproc/build.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/passes/1-parser/cameligo/dune b/src/passes/1-parser/cameligo/dune index 4e6829f1e..8824fdcd4 100644 --- a/src/passes/1-parser/cameligo/dune +++ b/src/passes/1-parser/cameligo/dune @@ -7,7 +7,7 @@ (menhir (merge_into Parser) (modules ParToken Parser) - (flags --table --strict --external-tokens LexToken)) + (flags -la 1 --table --strict --explain --external-tokens LexToken)) ;; Build of the parser as a library diff --git a/src/passes/1-parser/pascaligo/dune b/src/passes/1-parser/pascaligo/dune index e7b9a9a73..d0d43f02f 100644 --- a/src/passes/1-parser/pascaligo/dune +++ b/src/passes/1-parser/pascaligo/dune @@ -7,7 +7,7 @@ (menhir (merge_into Parser) (modules ParToken Parser) - (flags --table --strict --external-tokens LexToken)) + (flags -la 1 --table --strict --explain --external-tokens LexToken)) ;; Build of the parser as a library diff --git a/src/passes/1-parser/reasonligo/dune b/src/passes/1-parser/reasonligo/dune index a1408af91..6eb7304b8 100644 --- a/src/passes/1-parser/reasonligo/dune +++ b/src/passes/1-parser/reasonligo/dune @@ -7,7 +7,7 @@ (menhir (merge_into Parser) (modules ParToken Parser) - (flags --table --strict --external-tokens LexToken)) + (flags -la 1 --table --strict --explain --external-tokens LexToken)) ;; Build of the parser as a library diff --git a/vendors/Preproc/build.sh b/vendors/Preproc/build.sh index 30e3ba705..e9d6546be 100755 --- a/vendors/Preproc/build.sh +++ b/vendors/Preproc/build.sh @@ -2,7 +2,7 @@ set -x ocamllex.opt Escan.mll ocamllex.opt Preproc.mll -menhir Eparser.mly +menhir -la 1 Eparser.mly ocamlfind ocamlopt -strict-sequence -w +A-48-4 -c Etree.ml ocamlfind ocamlopt -strict-sequence -w +A-48-4 -c Error.ml ocamlfind ocamlopt -strict-sequence -w +A-48-4 -c Etree.ml From 0e5002fbeba508e947df119c3ce41732fdb00ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 20:03:47 +0100 Subject: [PATCH 15/16] Revert "Temporary debug prints for build-and-package failure" This reverts commit 81690394b0a6d5194b3f8603a1b066ce856ebfae. --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 08275dfc8..fc95f2f4b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,8 +25,8 @@ dont-merge-to-master: # To run in sequence and save CPU usage, use stage: build_and_package_binaries stage: test script: - - $build_binary_script "$target_os_family" "$target_os" "$target_os_version" || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) - - $package_binary_script "$target_os_family" "$target_os" "$target_os_version" || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) + - $build_binary_script "$target_os_family" "$target_os" "$target_os_version" + - $package_binary_script "$target_os_family" "$target_os" "$target_os_version" artifacts: paths: - dist/package/**/* @@ -46,12 +46,12 @@ dont-merge-to-master: - eval $(opam config env) - scripts/setup_switch.sh - eval $(opam config env) - - scripts/setup_repos.sh || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) + - scripts/setup_repos.sh # install deps for internal documentation - - scripts/install_vendors_deps.sh || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) + - scripts/install_vendors_deps.sh - opam install -y odoc - - scripts/build_ligo_local.sh || (cat _build/log || true; find || true; tail -n +1 ~/.opam/log/* || true; false) + - scripts/build_ligo_local.sh # build with odoc - dune build @doc From e86f15e5daa4e8a862a36cacad1eeae6cd2f88e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Mon, 10 Feb 2020 20:10:34 +0100 Subject: [PATCH 16/16] Show OPAM logs in case of failure inside of Docker --- docker/distribution/generic/build.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/distribution/generic/build.Dockerfile b/docker/distribution/generic/build.Dockerfile index f6c9358e9..ba01c043c 100644 --- a/docker/distribution/generic/build.Dockerfile +++ b/docker/distribution/generic/build.Dockerfile @@ -29,7 +29,7 @@ RUN opam update # Install ligo RUN sh scripts/install_vendors_deps.sh -RUN opam install -y . +RUN opam install -y . || (tail -n +1 ~/.opam/log/* ; false) # Use the ligo binary as a default command ENTRYPOINT [ "/home/opam/.opam/4.07/bin/ligo" ]