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

Make juvix compile default to native target #1502

Merged
merged 2 commits into from
Aug 31, 2022
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
19 changes: 14 additions & 5 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ brew install --build-from-source --HEAD juvix --verbose

** The Hello World Example

In the following example a Juvix file is compiled to Wasm. Please check out the documentation
[[https://anoma.github.io/juvix/getting-started/dependencies.html][Installing
dependencies]] for instructions on how to setup your environment for compiling Juvix. You can also run =juvix doctor= to check your system setup.
This is the Juvix source code of the traditional Hello World program.

#+begin_src shell
-- HelloWorld.juvix
Expand All @@ -132,15 +130,26 @@ main ≔ putStrLn "hello world!";
end;
#+end_src

Then, run the following commands at the location folder of the file =HelloWorld.juvix=:
To compile and run a binary generated by Juvix, save the source code to a file
called =HelloWorld.juvix= and run the following command from the directory
containing it:

#+begin_src shell
juvix compile HelloWorld.juvix
wasmer HelloWorld.wasm
./HelloWorld
#+end_src

You should see the output: =hello world!=

The source code can also be compiled to a WebAssembly binary. This requires some
additional setup. See [[https://anoma.github.io/juvix/getting-started/dependencies.html][Installing dependencies]] in the documentation for more
information. You can also run =juvix doctor= to check your setup.

#+begin_src shell
juvix compile --target wasm HelloWorld.juvix
wasmer HelloWorld.wasm
#+end_src

** The Juvix programming language

Juvix allows us to write programs with a high degree of assurance. The Juvix
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ parseCompile = do
( long "target"
<> short 't'
<> metavar "TARGET"
<> value TargetWasm
<> value TargetNative
<> showDefaultWith targetShow
<> help "select a target: wasm, c, native"
)
Expand Down
4 changes: 2 additions & 2 deletions docs/org/tutorials/nodejs-interop.org
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ end;
The Juvix module can be compiled using the following command:

#+begin_src
juvix compile -r standalone NodeJsInterop.juvix
juvix compile -t wasm -r standalone NodeJsInterop.juvix
#+end_src

This will create a file containing a Wasm module called =NodeJsInterop.wasm=.
Expand All @@ -55,7 +55,7 @@ The functions =ptrToCstr= and =cstrlen= are necessary to convert the =char=
pointer passed from Juvix to a JS =String=.

#+begin_src
-- NodeJSInterop.js
// NodeJSInterop.js
const fs = require('fs');
let wasmModule = null;

Expand Down