DeviceScript is a programming language for scripting Jacdac services.
It has JavaScript-like syntax and is compiled to a custom VM bytecode, which can run in very constrained environments (VM itself compiles to 10kB of code, with the floating point library and Jacdac SDK adding further 30kB).
This repository contains:
- jacdac-c submodule, including sources for Jacdac client libraries and DeviceScript VM
compiler/- sources for DeviceScript compilerruntime/devicescript-vm/- glue files to build DeviceScript VM as WASM module using emscripten;vm/dist/contain pre-built filesdevs/samples/- sample DeviceScript programsruntime/posix/- implementation of Jacdac SDK HAL for grown-up POSIX-like operating systems (as opposed to embedded platforms)
You can just use the devcontainer to build.
If you want to build locally you need to install node.js. After cloning, the repo run
yarn setupTo run a watch build and the docs, run
nvm use 18
yarn dev
- start
jacdac devtools(the npm version) and let is running - open this folder in VSCode; use "Reopen in Container" if needed
- start Terminal in VSCode
- run
yarn install - run
yarn build - run
devs run devs/samples/something.ts- this will execute given DeviceScript program using the WASM binary
If you want to develop the runtime (as opposed to compiler or website), you will also need GNU Make, C compiler, and emscripten. Once you have it all:
- run
make nativeto compile using native C compiler - run
devs crun devs/samples/something.ts- this will execute given DeviceScript program using the POSIX/native binary - run
./runtime/built/jdcli 8082- this will run the POSIX/native DeviceScript server, which can be accessed from the devtools dashboard - run
make emto compile using emscripten
- secure - can predictably execute untrusted code (random bytes)
- small memory (RAM) footprint
- small code (flash) footprint
- leave space for extensions in future
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.