Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
mebsout committed Oct 16, 2017
2 parents 6567525 + a96bd46 commit b9ea7cb
Show file tree
Hide file tree
Showing 99 changed files with 4,440 additions and 1,795 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*~
_obuild
/tezos
/tests/*.cm?
/tests/*/*.cm?
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# branches:
# only:
# - master
dist: trusty
language: ocaml
sudo: required

before_install:
- sh travis-scripts/prepare-trusty.sh

install:
- sh travis-scripts/prepare-opam.sh

script:
- export OPAMYES=1
- opam sw 4.05.0
- eval `opam config env`
- make clone-tezos
- make
- make tests-mini
- make tests
- make rev-tests

# TODO > how to compile and test with tezos (I.e. with a fully compiled version of tezos)?
23 changes: 6 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

all: build

tezos/Makefile:
git clone git@gitlab.com:tezos/tezos.git
clone-tezos:
git clone -b alphanet https://github.com/tezos/tezos.git # clone with https

build: _obuild tezos/Makefile
build: _obuild
ocp-build build

install: _obuild
Expand All @@ -14,18 +14,7 @@ _obuild: Makefile
ocp-build init

clean-tests:
rm -f tests/*.liq.tz \
tests/*.liq.debug \
tests/*.liq.tz.liq \
tests/*.pdf \
tests/*.dot \
tests/*.syntax \
tests/*.typed \
tests/*.mic \
tests/*.normal \
tests/*.pre \
tests/others/*.*.*
rm -f *~ tests/*~ tests/others/*~
$(MAKE) -C tests clean

clean-sources:
rm -f tools/*/*~ libs/*/*~
Expand All @@ -38,12 +27,12 @@ distclean: clean

# All of these tests must be run with with_tezos=true

NTESTS=18
NTESTS=20
SIMPLE_TESTS= `seq -f 'test%.0f' 0 $(NTESTS)`
MORE_TESTS=test_ifcons test_if test_loop test_option test_transfer test_left \
test_extfun test_left_constr test_closure test_closure2 test_closure3 \
test_map test_rev test_reduce_closure test_map_closure test_mapreduce_closure \
test_mapmap_closure test_setreduce_closure
test_mapmap_closure test_setreduce_closure test_left_match
OTHER_TESTS=others/broker others/demo others/auction
REV_TESTS=`seq -f 'test%.0f' 0 5`

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
next | master
------------ | -------------
[![Travis-CI Build Status](https://travis-ci.org/OCamlPro/liquidity.svg?branch=next)](https://travis-ci.org/OCamlPro/liquidity) | [![Travis-CI Build Status](https://travis-ci.org/OCamlPro/liquidity.svg?branch=master)](https://travis-ci.org/OCamlPro/liquidity)


Liquidity: a Smart Contract Language for Tezos
==============================================

Expand Down
9 changes: 8 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ You need the following dependencies to be installed to compile `liquidity`:
Compilation and installation
----------------------------

In the top-directory, use `make` and `make install`
In the top-directory, use:
* `make clone-tezos`
* `make`
* `make install`

If you want limited features, you can pass the first step, you will
only get a program `liquidity-mini` with only compilation features,
no decompilation.

You can also use `make clean` to clean the directories,
and `make tests` to run the compiler on examples in the
Expand Down
21 changes: 16 additions & 5 deletions build.ocp2
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
(* Version of the Liquidity compiler *)

version = "1.0";

(* Disable to compile without the sources of Tezos.
The following features with be disabled:
* Decompilation of Michelson files
* Execution of Michelson contracts
*)

Sys = module("ocp-build:Sys", "1.0");

(* This value is used if with_tezos is not set before *)
default_with_tezos = true;
default_with_tezos = Sys.file_exists("tezos/README.md");

try { with_tezos = with_tezos; }
catch("unknown-variable",x){ with_tezos = default_with_tezos; }

(* By default, liquidity will contain some version information
(Git commit, build date, etc.). However, during development, it
makes recompilation slower, so you can create a file DEVEL here
to tell ocp-build not to include version information.
The flag can also be controled in an inclusing project by using
the 'with_version' option.
*)

default_with_version = !Sys.file_exists("DEVEL");

try { with_version = with_version; }
catch("unknown-variable",x){ with_version = default_with_version; }
18 changes: 14 additions & 4 deletions check-mini.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#!/bin/sh

DEFAULT='\033[0m'
RED='\033[0;31m'

test=$1
echo $test
echo "\n[check-mini.sh] test = $test"

LIQUIDITY=liquidity

./_obuild/${LIQUIDITY}-mini/${LIQUIDITY}-mini.asm tests/$test.liq || exit 2

./tezos/_obuild/tezos-client/tezos-client.asm typecheck program tests/$test.liq.tz

if [ -f ./tezos/_obuild/tezos-client/tezos-client.asm ] ; then
./tezos/_obuild/tezos-client/tezos-client.asm typecheck program tests/$test.liq.tz
else
echo "\n${RED}./tezos/_obuild/tezos-client/tezos-client.asm not present ! typechecking of tests/$test.liq.tz skipped${DEFAULT}\n"
fi

./_obuild/${LIQUIDITY}/${LIQUIDITY}.asm tests/$test.liq.tz || exit 2

./_obuild/${LIQUIDITY}-mini/${LIQUIDITY}-mini.asm tests/$test.liq.tz.liq || exit 2

./tezos/_obuild/tezos-client/tezos-client.asm typecheck program tests/$test.liq.tz.liq.tz
if [ -f ./tezos/_obuild/tezos-client/tezos-client.asm ] ; then
./tezos/_obuild/tezos-client/tezos-client.asm typecheck program tests/$test.liq.tz.liq.tz
else
echo "\n${RED}./tezos/_obuild/tezos-client/tezos-client.asm not present ! typechecking of tests/$test.liq.tz.liq.tz skipped${DEFAULT}\n"
fi
22 changes: 17 additions & 5 deletions check-rev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,33 @@
echo '============================================================='
echo

DEFAULT='\033[0m'
RED='\033[0;31m'

TESTDIR=$1
test=$2
echo $test

echo "Testing $test.tz ---------------------------------------------"
./tezos/_obuild/tezos-client/tezos-client.asm typecheck program $TESTDIR/$test.tz
echo "\n[check-rev.sh] test = $test, TESTDIR = $TESTDIR"

if [ -f ./tezos/_obuild/tezos-client/tezos-client.asm ] ; then
echo "Testing $test.tz ---------------------------------------------"
./tezos/_obuild/tezos-client/tezos-client.asm typecheck program $TESTDIR/$test.tz
else
echo "\n${RED}./tezos/_obuild/tezos-client/tezos-client.asm not present ! typechecking of $TESTDIR/$test.tz skipped${DEFAULT}\n"
fi

echo "Generating $test.tz.liq --------------------------------------"
./_obuild/liquidity/liquidity.asm $TESTDIR/$test.tz || exit 2

echo "Compiling $test.tz.liq ---------------------------------------"
./_obuild/liquidity/liquidity.asm $TESTDIR/$test.tz.liq || exit 2

echo "Testing $test.tz.liq.tz --------------------------------------"
./tezos/_obuild/tezos-client/tezos-client.asm typecheck program $TESTDIR/$test.tz.liq.tz || exit 2
if [ -f ./tezos/_obuild/tezos-client/tezos-client.asm ] ; then
echo "Testing $test.tz.liq.tz --------------------------------------"
./tezos/_obuild/tezos-client/tezos-client.asm typecheck program $TESTDIR/$test.tz.liq.tz || exit 2
else
echo "\n${RED}./tezos/_obuild/tezos-client/tezos-client.asm not present ! typechecking of $TESTDIR/$test.tz.liq.tz skipped${DEFAULT}\n"
fi

echo
echo GOOD
Expand Down
22 changes: 18 additions & 4 deletions check.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
#!/bin/sh

DEFAULT='\033[0m'
RED='\033[0;31m'

test=$1
echo $test
echo "\n[check.sh] test = $test"

LIQUIDITY=liquidity

echo ./_obuild/${LIQUIDITY}/${LIQUIDITY}.asm tests/$test.liq
./_obuild/${LIQUIDITY}/${LIQUIDITY}.asm tests/$test.liq || exit 2

./tezos/_obuild/tezos-client/tezos-client.asm typecheck program tests/$test.liq.tz

if [ -f ./tezos/_obuild/tezos-client/tezos-client.asm ] ; then
./tezos/_obuild/tezos-client/tezos-client.asm typecheck program tests/$test.liq.tz || exit 2
else
echo "\n${RED}./tezos/_obuild/tezos-client/tezos-client.asm not present ! typechecking of tests/$test.liq.tz skipped${DEFAULT}\n"
fi

echo ./_obuild/${LIQUIDITY}/${LIQUIDITY}.asm tests/$test.liq.tz
./_obuild/${LIQUIDITY}/${LIQUIDITY}.asm tests/$test.liq.tz || exit 2

echo ./_obuild/${LIQUIDITY}/${LIQUIDITY}.asm tests/$test.liq.tz.liq
./_obuild/${LIQUIDITY}/${LIQUIDITY}.asm tests/$test.liq.tz.liq || exit 2

./tezos/_obuild/tezos-client/tezos-client.asm typecheck program tests/$test.liq.tz.liq.tz
if [ -f ./tezos/_obuild/tezos-client/tezos-client.asm ] ; then
./tezos/_obuild/tezos-client/tezos-client.asm typecheck program tests/$test.liq.tz.liq.tz || exit 2
else
echo "\n${RED}./tezos/_obuild/tezos-client/tezos-client.asm not present ! typechecking of tests/$test.liq.tz.liq.tz skipped${DEFAULT}\n"
fi

echo ./_obuild/ocp-liquidity-comp/ocp-liquidity-comp.asm -I +../zarith zarith.cma -I _obuild/liquidity-env ./_obuild/liquidity-env/liquidity-env.cma -impl tests/$test.liq
./_obuild/ocp-liquidity-comp/ocp-liquidity-comp.asm -I +../zarith zarith.cma -I _obuild/liquidity-env ./_obuild/liquidity-env/liquidity-env.cma -dsource -impl tests/$test.liq
rm -f a.out
16 changes: 8 additions & 8 deletions docs/liquidity.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ All the contracts have the following form:
let%entry main
(parameter : TYPE)
(storage : TYPE)
[%return : TYPE] =
: TYPE =
BODY
```

Expand All @@ -40,17 +40,17 @@ network.
The `main` function is the default entry point for the contract.
`let%entry` is the construct used to declare entry points (there is
currently only one entry point, but there will be probably more in the
future). The declaration takes three parameters with names
`parameter`, `storage` and `return`. The first two parameters,
`parameter` and `storage` are arguments to the function, while the
latest one, `return`, is only used to specified the return type of the
function. The types of the three parameters must always be specified.
future). The declaration takes two parameters with names
`parameter`, `storage`, the arguments to the function. Their types must
always be specified. The return type of the function must also be
specified by a type annotation.

A contract always returns a pair `(return, storage)`, where `return`
is the return value to the caller, and `storage` is the final state of
the contract after the call. The type of the pair must match the type
of a pair with the two parameters, `return` and `storage`, that were
specified at the beginning of `main`.
of a pair where the first component is the return type of the function
specified in its signature and the second is the type of the argument
`storage` of `main`.

<... local declarations ...> is an optional set of optional type and
function declarations. Type declarations can be used to define records
Expand Down
2 changes: 2 additions & 0 deletions libs/deps-michelson/utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ let split delim ?(limit = max_int) path =
do_slashes [] limit 0
else
[ path ]

module StringMap = Map.Make (String)
1 change: 1 addition & 0 deletions libs/michelson/cli_entries.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
open Utils

#include "../../tezos/src/utils/cli_entries.ml"
(*
Expand Down
4 changes: 4 additions & 0 deletions libs/michelson/client_proto_args.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

open Tezos_context

#include "../../tezos/src/client/embedded/alpha/client_proto_args.mli"
1 change: 1 addition & 0 deletions libs/michelson/client_proto_programs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ end

module Environment = struct
module Ed25519 = Ed25519
module Error_monad = Error_monad
end

#include "../../tezos/src/client/embedded/alpha/client_proto_programs.ml"
Loading

0 comments on commit b9ea7cb

Please sign in to comment.