Skip to content

pulseengine/rules_moonbit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rules_moonbit

Bazel rules for MoonBit projects

 

Bazel License: Apache-2.0

 

Bazel rules for building MoonBit projects with hermetic toolchain support, multi-target compilation, and WebAssembly Component Model integration.

Note

Part of the PulseEngine toolchain. Provides build infrastructure for MoonBit-based components. See moonbit_checksum_updater for checksum management tooling.

Status

Early development phase. The goal is to create Bazel rules that integrate with MoonBit's build system while maintaining Bazel's core principles.

Getting Started

Prerequisites

  • Bazel 8.5+ (required for modern toolchain support)

Quick Start

Using Bzlmod (Modern Bazel):

# MODULE.bazel
bazel_dep(name = "rules_moonbit", version = "0.1.0")

Using WORKSPACE:

local_repository(
    name = "rules_moonbit",
    path = "/path/to/rules_moonbit",
)

register_toolchains("@moonbit_toolchain//:moonbit_toolchain")

When Hermetic Downloads Become Available:

load("@rules_moonbit//moonbit/tools:hermetic_toolchain.bzl", "moonbit_toolchain_repository")

moonbit_toolchain_repository(
    name = "moonbit_toolchain",
    version = "0.6.33",
)

register_toolchains("@moonbit_toolchain//:moonbit_toolchain")

BUILD file

load("@rules_moonbit//moonbit:defs.bzl", "moonbit_library", "moonbit_binary")

moonbit_library(
    name = "mylib",
    srcs = ["mylib.mbt"],
    deps = ["//:otherlib"],
)

moonbit_binary(
    name = "myapp",
    srcs = ["main.mbt"],
    deps = [":mylib"],
)

Features

Core

  • MoonBit compilation with multi-target support (WASM, JavaScript, C, native)
  • Cross-compilation for different platforms
  • WebAssembly Component Model with WIT interface support
  • Package management with MoonBit registry integration
  • Hermetic toolchain with automatic download and management

Advanced

  • Incremental compilation for faster rebuilds
  • Multiple optimization levels (debug, release, aggressive)
  • Content-addressable caching for build acceleration
  • Integration with rules_wasm_component
  • Checksum verification for hermetic builds

Advanced Usage

Cross-Compilation

moonbit_binary(
    name = "linux_app",
    srcs = ["main.mbt"],
    target_platform = "linux_x86_64",
    optimization = "aggressive",
)

WebAssembly Component Model

moonbit_component(
    name = "math_component",
    srcs = ["math.mbt"],
    wit_deps = [":math_wit"],
    target_platform = "wasm",
)

Development

bazel build //...     # Build
bazel test //...      # Test
bazel test //test/... # Run test suite

Contributing

See CONTRIBUTING.md for contribution guidelines.

License

Apache-2.0


Part of PulseEngine — formally verified WebAssembly toolchain for safety-critical systems

About

Bazel rules for MoonBit with hermetic toolchain support

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages