Our C++ code is built by Bazel. You will need to install Bazel, and use it to
build and run the wasm code/tests (everything under src/wasm/
).
- Installing Bazel: Follow project install instructions.
See here for a working example.
- Add a
BUILD
file in the relevant directory - Generate a C++ header file from your particle spec using the
arcs_cc_schema
build rule:arcs_cc_schema( # Name of the BUILD rule (tell Bazel to build this schema using this name). name = "example_schema", # Input source. src = "example.arcs", # Optional output filename. out = "example.h", )
- Write your C++ particle(s)
- Include the Arcs C++ header:
#include "src/wasm/cpp/arcs.h"
. - Include your generated schema header(s):
#include "particles/Native/Wasm/example.h"
. - Particles inherit from
arcs::Particle
and usearcs::Singleton
andarcs::Collection
- Include the Arcs C++ header:
- Add a
wasm_cc_binary
build rule for your C++ particle(s) to yourBUILD
file:cc_wasm_binary( # Name of the BUILD rule (tell Bazel to build this particle using this name). name = "example_particle", # Input C++ particle source files to compile. srcs = ["example.cc"], # Input C++ header files (example.h was generated by the example_schema rule above). hdrs = ["example.h"], # Other C++ dependencies this binary depends on (just the Arcs library). deps = ["//src/wasm/cpp:arcs"], )
- Build your particle using Bazel:
bazel build //particles/Native/Wasm:example_particle
.
tools/sigh devServer
- Visit localhost:8786/shells/dev-shell/?m=https://$arcs/particles/Native/Wasm/example.arcs (TODO(csilvestrini): update this path)
bazel test //src/wasm:wasm-api-test