...
 
Commits (11)
# 1.0.3
* Field and constructor annotations in output Michelson code
* Very rough implementation of --scaml-revert, which is to revert SCaml expression from a Michelson value and its SCaml type.
* Checks for comparable, packable, and parameterable types.
* Fixed the compilation of SELF by introducing Annot "not_expand" not to expand let-def.
* Michelson optimziation : DIP { DROP } x n => DIP { DROP n }
* Introduce docker file
# 1.0.2
* Fixed typos of messages
......
FROM ocaml/opam2:4.07
RUN sudo apt-get update
RUN sudo apt-get install -y libgmp-dev perl pkg-config m4 zlib1g-dev
RUN git clone https://gitlab.com/dailambda/scaml.git
WORKDIR scaml
RUN git checkout pyramid
RUN opam update
RUN opam install -y vendors/*/*.opam src/scaml.opam
RUN eval $(opam env) && which scamlc
WORKDIR /scaml-work
FROM ubuntu:18.04
MAINTAINER Jun FURUSE <jun.furuse@dailambda.jp>
# # Replacing the source
# RUN sed -e 's|/archive\.ubuntu\.com/ubuntu|/ftp.jaist.ac.jp/pub/Linux/ubuntu|g' /etc/apt/sources.list > /tmp/sources.list
# RUN mv /tmp/sources.list /etc/apt/sources.list
RUN apt-get clean
RUN apt-get update
# Git
RUN apt install -y --no-install-recommends git ca-certificates
# OPAM (using old OCaml)
WORKDIR /
RUN git clone https://github.com/ocaml/opam
WORKDIR opam
RUN git checkout 2.0.3
RUN apt install -y --no-install-recommends \
curl pkg-config m4 unzip ocaml-nox git make patch
RUN apt install -y --no-install-recommends rsync
RUN apt install -y --no-install-recommends g++ # Required for the OPAM's internal solver
RUN ./configure
RUN make lib-ext && make && make install
RUN opam init -a --bare --disable-sandboxing # bwrap does not work...
RUN rm -rf /opam
RUN apt remove -y ocaml-nox # We do not need the old OCaml
RUN apt remove -y g++ # Required for the external solver
RUN apt autoremove -y
# SCaml
WORKDIR /
RUN git clone https://gitlab.com/dailambda/scaml.git
WORKDIR /scaml
RUN opam switch create . ocaml-base-compiler.4.07.1
RUN opam update
RUN git pull
RUN git checkout @COMMIT@
RUN apt install -y --no-install-recommends libgmp-dev
RUN eval $(opam env) && env && opam install -y vendors/*/*.opam src/scaml.opam
# Cleanup
WORKDIR /
RUN du -sh /usr /scaml /root /var
# Under /scaml, destorying the local OPAM switch
RUN opam clean -a
RUN rm -rf /scaml/_opam/.opam-switch
RUN tar zcf /tmp/scaml.tgz /scaml/_opam/lib/stublibs /scaml/_opam/lib/ocaml/stdlib.cmi /scaml/_opam/bin/scamlc /scaml/_opam/lib/scaml
RUN rm -rf /scaml/_opam
RUN tar xvf /tmp/scaml.tgz
# Destroy OPAM
RUN rm -rf /root/.opam
# Clean and destroy APT
RUN rm -rf /usr/local
RUN apt remove -y git gcc cpp-7 perl make
RUN apt remove -y '*-dev' > /dev/null 2>&1
RUN apt-get clean
RUN apt autoremove -y
RUN rm -rf /var/lib/apt
RUN du -sh /usr /scaml /root /var
RUN SCAMLIB=/scaml/_opam/lib/scaml /scaml/_opam/bin/scamlc /scaml/src/tests/app_vote.ml && echo OK
ENV SCAMLIB /scaml/_opam/lib/scaml
ENV PATH /scaml/_opam/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
CMD [ "scamlc", "--scaml-version" ]
#!/bin/bash
set -e
COMMIT=$1
if [ -z $COMMIT ]; then
echo Using master
COMMIT=master
fi
sed -e "s/@COMMIT@/$COMMIT/g" Dockerfile.in > Dockerfile
docker build --squash=true -t dailambda/scaml:$COMMIT .
......@@ -82,3 +82,13 @@ Boo
Note that the values must be constants. Constructors and types can refer to types
defined in other modules, as far as they are already compiled to `.cmi` files.
## Where to find "SCamlib" module
To compile smart contracts, you need to use `SCaml` module which declares the primitives for them. The module `SCaml` is seeked in directories in the following order:
* In the current directory.
* Directories specified by `-I <dir>` option.
* If `--scaml-noscamlib` is not specified:
* Directory specified by the environment variable `SCAMLIB`.
* If `SCAMLIB` is not speicified, directory `` `opam config var prefix`/lib/scaml``.
......@@ -18,26 +18,40 @@ open Tools
module M = Michelson
let init () =
if not !Flags.flags.scaml_noscamlib then begin
(* exec opam config var prefix *)
let dir = match
let open Command in
exec ["opam"; "config"; "var"; "prefix"]
|> stdout
|> wait
|> must_exit_with 0
with
| dir::_ -> String.chop_eols dir ^/ "lib/scaml"
| [] ->
internal_error ~loc:Location.none "Command 'opam config var prefix' answered nothing"
| exception (Failure s) ->
internal_error ~loc:Location.none "Command 'opam config var prefix' has failed: %s" s
| exception e ->
internal_error ~loc:Location.none "Command 'opam config var prefix' raised an exception: %s" (Printexc.to_string e)
in
Clflags.include_dirs := !Clflags.include_dirs @ [dir];
(* List.iter (fun s -> prerr_endline @@ "Include: " ^ s) !Clflags.include_dirs *)
end
(* If --scaml-noscamlib is specified, None.
If SCAMLLIB is specified, SCAMLLIB is chosen.
Otherwise, `opam config var prefix`/lib/scaml is used.
If `opam config var prefix` does not print a directory nor crashes,
scamlc prints out a warning and continues with None
*)
let scamllib =
if !Flags.flags.scaml_noscamlib then None
else
match Sys.getenv "SCAMLIB" with
| dir -> Some dir
| exception Not_found ->
(* exec opam config var prefix *)
match
let open Command in
exec ["opam"; "config"; "var"; "prefix"]
|> stdout
|> wait
|> must_exit_with 0
with
| dir::_ -> Some (String.chop_eols dir ^/ "lib/scaml")
| [] ->
Format.eprintf "Warning: Command 'opam config var prefix' answered nothing@."; None
| exception (Failure s) ->
Format.eprintf "Warning: Command 'opam config var prefix' has failed: %s" s; None
| exception e ->
Format.eprintf "Warning: Command 'opam config var prefix' raised an exception: %s" (Printexc.to_string e); None
in
match scamllib with
| None -> ()
| Some dir -> Clflags.include_dirs := !Clflags.include_dirs @ [dir]
let implementation sourcefile outputprefix _modulename (str, _coercion) =
let parameter, storage, t = Translate.implementation sourcefile str in
......
opam-version: "2.0"
name: "scaml"
version: "1.0.2"
version: "1.0.3"
authors: "Jun Furuse"
maintainer: "jun.furuse@dailambda.jp"
synopsis: "SCaml, Smart Contract Abstract Machine Language"
......
......@@ -12,5 +12,5 @@
(* *)
(**************************************************************************)
let scaml = "1.0.1"
let scaml = "1.0.3"
let protocol = "005"