Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Micro services

Yury Delendik edited this page Mar 14, 2018 · 3 revisions

The WebAssembly Studio sometimes rely on the server to perform some expensive tasks such as compile C or Rust code to the WebAssembly. We are trying to move everything on the client side, however it may take some time, but we need to learn/teach WebAssembly now.

It is possible to run some of the services locally. The config.json can be modified to points the WebAssembly Studio application to the different end-points.

Clang compiler service

The micro-service allows compiling C and C++ code for the "wasm32-unknown-unknown-wasm" target. It also has basic set of standard libraries such as libc and libc++.

The clang compiler service is located at the "webassembly-studio-clang" heroku app. Its source code is located at https://github.com/yurydelendik/clang-heroku-slug.

build end-point

The "build" end-point URL for REST service is https://webassembly-studio-clang.herokuapp.com/build. It accepts the JSON content in the following format:

 {
     output: "wasm",
     compressed: false,
     files: [
         {
             type: "cpp",
             name: "file.cpp",
             options: "-O3 -std=c++98",
             src: "puts(\"hi\")"
         }
     ],
     link_options: "--import-memory"
 }

and it returns JSON in the following format

{
     success: true,
     message: "Success",
     output: "AGFzbQE.... =",
     tasks: [
         {
             name: "building file.cpp",
             file: "file.cpp",
             success: true,
             console: ""
         },
         {
             name: "linking wasm",
             success: true,
             console: ""
         }
     ]
 }

Rustc compiler server

The micro-service allows compiling Rust code for the "wasm32-unknown-unknown-wasm" target.

The clang compiler service is temporary (TBD) located at the "rust-heroku" heroku app. Its source code is located at https://github.com/yurydelendik/rust-heroku-slug.

rustc end-point

The "rustc" end-point URL for REST service is https://rust-heroku.herokuapp.com/rustc. It accepts the JSON content in the following format:

{
    code: "fn main() { }"
}

and it returns JSON in the following format

{
    success: true,
    output: "AGFzbQE.... =",
    console: "Warning/error messages"
}

Legacy wasmexplorer-service

This service is set of the micro-services for the WasmExplorer. The service can:

  • Build C/C++ code into WebAssembly (and X86)
  • Convert between text and binary format
  • Get SpiderMonkey JIT code for X86 platform

The service is located at the "wasmexplorer-service" heroku app. Its source code is located at https://github.com/wasdk/wasmexplorer-service.

service.php end-point

The catch-all-actions end-point URL for this service is located at wasmexplorer-service.herokuapp.com/service.php. It usually accepts requests in POST form and the input/output format depends on actions that service will perform. See the source code for more information at https://github.com/wasdk/wasmexplorer-service/blob/master/web/service.php.