Added ./scripts/play.fun to interactive run thrue all examples in ./examples/. (0.40.6)
This commit is contained in:
parent
587bb76108
commit
5eb5cd7348
10 changed files with 275 additions and 141 deletions
|
|
@ -4,7 +4,7 @@ published: true
|
|||
noToc: false
|
||||
noComments: false
|
||||
noDate: false
|
||||
title: Fun - Building Fun
|
||||
title: Building Fun
|
||||
subtitle: How to build Fun with CMake, available targets, and build options (FUN_DEBUG, FUN_USE_MUSL, FUN_WITH_CPP, FUN_WITH_RUST, FUN_WITH_OPENSSL).
|
||||
description: How to build Fun with CMake, available targets, and build options (FUN_DEBUG, FUN_USE_MUSL, FUN_WITH_CPP, FUN_WITH_RUST, FUN_WITH_OPENSSL).
|
||||
permalink: /documentation/build/
|
||||
|
|
@ -27,11 +27,13 @@ tags:
|
|||
This guide describes how to build Fun from source using CMake and the available build options.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- A C compiler with C99 support
|
||||
- CMake 3.20+ (or newer)
|
||||
- Optional: Rust toolchain with cargo (required when building with `FUN_WITH_RUST=ON`)
|
||||
|
||||
## Common targets
|
||||
|
||||
- `build` - aggregate target that depends on `fun`, `fun_test`, and `test_opcodes`
|
||||
- `fun` - the CLI executable
|
||||
- `fun_test` - unit/feature tests (run with CTest)
|
||||
|
|
@ -40,6 +42,7 @@ This guide describes how to build Fun from source using CMake and the available
|
|||
These targets are defined by the project; use your configured CMake build directory/profile.
|
||||
|
||||
## Build options
|
||||
|
||||
Fun exposes several options you can toggle at configure time:
|
||||
|
||||
- `FUN_DEBUG` (ON/OFF) - Enables extra assertions and logging in the VM and runtime
|
||||
|
|
@ -49,6 +52,7 @@ Fun exposes several options you can toggle at configure time:
|
|||
- `FUN_WITH_OPENSSL` (ON/OFF) - Enable OpenSSL-backed helpers (MD5/SHA-256/SHA-512/RIPEMD-160)
|
||||
|
||||
### VM configuration constants
|
||||
|
||||
You can override internal VM limits at compile time by passing `-D<VAR>=<VALUE>` to CMake:
|
||||
|
||||
- `MAX_FRAMES` (default: 128) - Maximum depth of the call stack (frames)
|
||||
|
|
@ -61,45 +65,48 @@ These are defined as `CACHE` variables, so they will persist in your `CMakeCache
|
|||
|
||||
When configuring, the build prints a summary like:
|
||||
|
||||
See [../vm/](../vm/) for more information.
|
||||
See [VM](../vm/) for more information.
|
||||
|
||||
<pre>==== Fun build options ====
|
||||
FUN_DEBUG: ENABLED|DISABLED
|
||||
FUN_USE_MUSL: ENABLED|DISABLED
|
||||
FUN_WITH_CPP: ENABLED|DISABLED
|
||||
FUN_WITH_RUST: ENABLED|DISABLED
|
||||
===========================
|
||||
</pre>
|
||||
===========================</pre>
|
||||
|
||||
## Example commands
|
||||
|
||||
Use the CLion-provided build directories or your own. Typical invocations:
|
||||
|
||||
### Debug
|
||||
<pre>cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug \
|
||||
-DFUN_DEBUG=ON -DFUN_WITH_RUST=OFF
|
||||
cmake --build build --target build
|
||||
</pre>
|
||||
cmake --build build --target build</pre>
|
||||
|
||||
### Release
|
||||
|
||||
<pre>cmake -S . -B build_release -DCMAKE_BUILD_TYPE=Release \
|
||||
-DFUN_DEBUG=OFF -DFUN_WITH_RUST=OFF
|
||||
cmake --build build_release --target build
|
||||
</pre>
|
||||
cmake --build build_release --target build</pre>
|
||||
|
||||
### Enabling optional extensions
|
||||
|
||||
<pre>cmake -S . -B build_release -DCMAKE_BUILD_TYPE=Release \
|
||||
-DFUN_WITH_CPP=ON -DFUN_WITH_RUST=ON -DFUN_WITH_OPENSSL=ON
|
||||
cmake --build build_release --target build
|
||||
</pre>
|
||||
cmake --build build_release --target build</pre>
|
||||
|
||||
### Customizing VM limits
|
||||
|
||||
<pre>cmake -S . -B build_custom -DSTACK_SIZE=4096 -DMAX_GLOBALS=512
|
||||
cmake --build build_custom --target fun
|
||||
</pre>
|
||||
cmake --build build_custom --target fun</pre>
|
||||
|
||||
If `FUN_WITH_RUST` is enabled, ensure `cargo` is available in PATH; the build will invoke it and link the produced static library.
|
||||
|
||||
If `FUN_WITH_OPENSSL` is enabled, CMake must detect your system OpenSSL (libcrypto).
|
||||
|
||||
|
||||
## Running
|
||||
- CLI: run the `fun` executable from your build directory.
|
||||
- REPL: `fun -i` or just run `fun` without a script, depending on your CLI version (see [../cli/](../cli/)).
|
||||
- Examples: see [../examples/](../examples/).
|
||||
- REPL: `fun -i` or just run `fun` without a script, depending on your CLI version (see [CLI](../cli/)).
|
||||
- Examples: see [Examples](../examples/).
|
||||
|
||||
Tip: When running from the repository without installation, set `FUN_LIB_DIR` to the local `./lib` so includes can find the stdlib.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue