Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.94 KB

Developing-bucklescript.adoc

File metadata and controls

58 lines (38 loc) · 1.94 KB

Developing BuckleScript

Building BuckleScript from Source

1. Recursively clone the BuckleScript repository
2. Build the patched OCaml toolchain

sh cd ./ocaml git checkout master ./configure -prefix \`pwd\ make world.opt make install export PATH=$(cwd)/bin:$PATH`

This install patched binaries into ./bin and adds them to your current command path.

3. Build the BuckleScript compiler

Make sure you have ocamlopt.opt in your $PATH from the previous step, then do the following:

sh cd ./jscomp npm_package_name=bs-platform make world export PATH=$(cwd)/jscomp/bin:$PATH

This install the compiler bsc.exe into ./jscomp/bin and adds it to your current command path.

Check that the BuckleScript compiler works

Create a simple OCaml program bs-hello/hello.ml in a directory adjacent to the bucklescript:

sh cd .. # if you are still in the bucklescript directory mkdir bs-hello cd bs-hello echo 'print_endline "hello world";;' > hello.ml

Next, compile it with bsc.exe, making sure to include the BuckleScript runtime and stdlib:

sh bsc.exe -I ../bucklescript/jscomp/runtime -I ../bucklescript/jscomp/stdlib -c hello.ml

You should now have a file bs-hello/hello.js. You can run it with Node or any other JavaScript engine:

sh node hello.js

If everything goes well, you will see hello world on your screen.