Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bamboo.js #260

Merged
merged 19 commits into from
Feb 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
_build
setup.data
setup.log
.DS_Store
.merlin
.bsb.lock
npm-debug.log
/lib/bs/
/lib/js/
/node_modules/
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ before_install:
# - locate libpolymain.a
- wget https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh -O - | sudo sh -s /usr/local/bin
- export OPAMJOBS=2
- opam init -y --comp=4.04.0
- opam switch 4.04.0
- opam init -y --comp=4.02.3+buckle-master
- opam switch 4.02.3+buckle-master
- eval `opam config env`
- opam update
- opam upgrade -y
- opam install -y ocamlfind menhir batteries rope zarith ppx_deriving rpc=1.9.52 cryptokit hex
# It's important to install batteries first, so the proper version of rpc can be installed afterwards
- git clone https://github.com/bsansouci/batteries-included
- cd ./batteries-included && opam pin add -y batteries . && cd ..
- opam install -y ocamlfind menhir rope zarith ppx_deriving rpc=1.9.52 cryptokit hex
- cd ../..
- if [ ! -d cpp-ethereum/.git ]; then rm -rf cpp-ethereum; git clone https://github.com/ethereum/cpp-ethereum --recursive; fi
- sudo apt install -y build-essential libgmp-dev libleveldb-dev libmicrohttpd-dev
Expand All @@ -59,17 +62,18 @@ before_install:
- sudo make install
- cd $BAMBOO
- sudo apt install texlive-latex-base texlive-science texlive-math-extra
install:
- npm install
script:
- make doc/spec.pdf
- make
- make test
- make endToEnd
- which eth
- eth --version
- mkdir -p /tmp/test
- eth --test -d /tmp/test &> eth.log &
- PID=$!
- sleep 4
- ./endToEnd.native
- ./lib/bs/native/endtoend.native
- kill $PID
- cat eth.log
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
.PHONY: test bamboo endToEnd clean
.PHONY: test bamboo clean

bamboo:
ocaml setup.ml -configure
ocaml setup.ml -build
npm run build

endToEnd:
ocamlbuild -use-ocamlfind -Is src/basics,src/ast,src/parse,src/lib,src/codegen -package batteries -package cryptokit -package rope -package rpclib -package rpclib.unix -package unix -package rpclib.json -package ppx_deriving -package ppx_deriving_rpc -package hex -use-menhir src/exec/endToEnd.native
install:
npm install
opam switch 4.02.3+buckle-master
eval `opam config env`
# It's important to install batteries first, so the proper version of rpc can be installed afterwards
git clone https://github.com/bsansouci/batteries-included ./node_modules/batteries-included
cd ./node_modules/batteries-included && opam pin add -y batteries . && cd ../..
opam install -y ocamlfind menhir rope zarith ppx_deriving rpc=1.9.52 cryptokit hex

doc/spec.pdf: doc/spec.tex
(cd doc; pdflatex -halt-on-error spec.tex; pdflatex -halt-on-error spec.tex)
Expand All @@ -14,4 +19,4 @@ test:
(cd src; sh ./run_tests.sh)

clean:
rm -rf _build
npm run clean
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ prints ABI.

## Developing Bamboo

To try Bamboo in your local environment, run `make install` from the project folder. That should install all dependencies.
Once the installation process is done, run `eval $(opam config env)` and then you can build all targets using `make`, and run the tests with `make test`.

When you modify the OCaml source of Bamboo, you can try your version by
```
$ make
$ ./bamboo.native < src/parse/examples/006auction_first_case.bbo
$ ./lib/bs/native/bamboo.native < src/parse/examples/006auction_first_case.bbo
```

## How to Contribute
Expand Down
19 changes: 19 additions & 0 deletions __tests__/compare-js-native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// A small script to test if both versions (JS and native) output the same
// string given the same programs as input
// To run: `node compare-js-native.js`

const fs = require('fs');
const path = require('path');
const execSync = require('child_process').execSync;
const examplesFolder = '../src/parse/examples';

fs.readdir(examplesFolder, (err, files) => {
files.forEach(file => {
console.log(`Comparing native vs js output for file: ${file}...`);
const filePath = path.join(examplesFolder, file);
const jsOutput = execSync(`node ../lib/js/src/exec-js/bambooJs.js < ${filePath}`).toString();
const nativeOutput = execSync(`../bamboo.native < ${filePath}`).toString();
const equal = jsOutput === nativeOutput;
console.log(`Result: ${equal ? 'ok' : 'DIFF'}\n`);
});
})
45 changes: 0 additions & 45 deletions _oasis

This file was deleted.

67 changes: 0 additions & 67 deletions _tags

This file was deleted.

92 changes: 92 additions & 0 deletions bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"name": "bamboo",
"version": "0.0.02",
"bsc-flags": "-w -27 -g",
"warnings": {
"number": "-40+6+7-26-27+32..39-28-44+45",
"error": "+8"
},
"bs-dependencies": [
"bs-bn.js"
],
"ocamlfind-dependencies": [
"batteries",
"cryptokit",
"hex",
"ppx_deriving",
"ppx_deriving_rpc",
"rpclib.json"
],
"generators": [
{
"name": "ocamllex",
"command": "ocamllex $in"
},
{
"name": "menhir",
"command": "menhir $in"
}
],
"sources": {
"dir": "src",
"subdirs": [
{"dir": "ast"},
{"dir": "basics"},
{"dir": "codegen"},
{"dir": "cross-platform"},
{"backend": "native", "dir": "exec"},
{"backend": "js", "dir": "exec-js"},
{"dir": "lib"},
{"dir": "parse"}
],
"generators": [
{
"name": "ocamllex",
"edge": ["parse/lexer.ml", ":", "parse/lexer.mll"]
},
{
"name": "menhir",
"edge": ["parse/parser.ml", "parse/parser.mli", ":", "parse/parser.mly"]
}
]
},
"entries": [
{
"backend": "native",
"main-module": "Bamboo"
},
{
"backend": "native",
"main-module": "Codegen_test"
},
{
"backend": "native",
"main-module": "Codegen_test2"
},
{
"backend": "native",
"main-module": "Lib_test"
},
{
"backend": "native",
"main-module": "Hex_test"
},
{
"backend": "native",
"main-module": "Parser_test"
},
{
"backend": "native",
"main-module": "Ast_test"
},
{
"backend": "native",
"main-module": "EndToEnd"
},
{
"backend": "js",
"main-module": "BambooJs"
}
],
"refmt": 3
}
2 changes: 1 addition & 1 deletion doc/testing-bytecode.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Getting a Bytecode
After following the [readme](../README.md),

```
./bamboo.native < src/parse/examples/006auction_first_case.bbo
./lib/bs/native/bamboo.native < src/parse/examples/006auction_first_case.bbo
```
should produce something like
```
Expand Down
Loading