Getting Started2 min read

Installation

Build the BWSL compiler or use the WebAssembly build in tools and editors.

Reading Time
2 min
Word Count
277
Sections
7
Try It Live

Turn the guide into code

Take the key idea from this page into the playground and validate it in a real shader instead of leaving it as theory.

Open Playground

The compiler repo supports three installation paths:

  • prebuilt command-line compilers from GitHub Releases
  • a native CLI compiler for local builds and asset pipelines
  • a WebAssembly build for browser tools, editors, and playgrounds

Download a Release

Prebuilt CLI binaries are published on the BWSL GitHub Releases page when a version is cut.

Choose the asset for your platform:

PlatformRelease asset
Windowsbwslc-windows-x64.exe
macOSbwslc-macos-arm64 or bwslc-macos-x64
Linuxbwslc-linux-x64

After downloading, put the binary somewhere on your PATH or call it directly from your build scripts. On macOS and Linux, make the binary executable if your browser or archive tool strips that bit:

bash
chmod +x bwslc-*

Build the CLI Compiler

From the BWSL source repo:

bash
git clone --recurse-submodules https://github.com/apresthus/BWSL.git
cd BWSL
make bwslc

This produces the native compiler in build/:

text
build/
└── bwslc

On Windows, the repo also includes build.bat and make.bat helpers:

bat
build.bat bwslc

Verify Installation

The current compiler exposes help and version information through -h:

bash
./build/bwslc -h

If bwslc is already on your PATH, the same check works as:

bash
bwslc -h

The help output should show the compiler version and flags such as -o, -metal, -hlsl, -glsl, -gles, -variant, and -dump-variant-space.

WebAssembly Build

For browser-based compilation, build the WASM target:

bash
make wasm

Artifacts are written to build/wasm/:

text
build/wasm/
├── bwsl.js
└── bwsl.wasm

Usage in JavaScript

typescript
import initBWSL from "./build/wasm/bwsl.js";

const bwsl = await initBWSL();

const result = bwsl.ccall(
  "compile",
  "string",
  ["string", "string", "string"],
  [
    shaderSource,
    "",
    "-internals -modules ./modules",
  ]
);

const output = JSON.parse(result);

The WASM build also exposes getSymbols for editor tooling and autocomplete.

Notes

  • Releases are the easiest path for users who only need the compiler binary.
  • Source builds require a C++20-capable toolchain.
  • WASM builds require Emscripten (emcc) in PATH.
  • Resources are declared in source; host-only preview or render-graph metadata should be handled outside the compiler call.

Next Steps