0.0.9 • Published 7 months ago

bunative v0.0.9

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

bunative

A basic Bun plugin for running native code!

Currently supports any clang-compileable language, as long as it exports c-compatible functions.

Quickstart Example

  • Add preload = ["./init.ts"] to your bunfig.toml.
  • Add the following to init.ts:

    import { plugin } from "bun";
    import { clang } from "bunative";
    import clangConfig from './src/c/build';
    
    plugin(
      clang({
        buildConfig: clangConfig,
      })
    );
  • Create the dir ./src/c

  • Create a build.ts in ./src/c
  • Add the following to build.ts:

    export default {
      "test.c": {
        out: "./out/test.o",
      },
    } as NativeModuleConfigSet;
  • Create test.c inside ./src/c

  • Add methods to test.c

Then to use, simply import the test.c file; The first time you run your code, it will compile and generate type definitions for your source file.

Notes

  • Hash checking only applies to the imported file. If that file includes additional source files, it will not consider the file as changed.
0.0.9

7 months ago

0.0.8

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.2

8 months ago

0.0.1

8 months ago