Calculator provides an interface for client components to request compute operations over IPC using FIDL. The calculator sample has three parts: the engine, a client, and a library defining a FIDL communication protocol between the components.
fidl/
: Contains the definition of a Fuchsia interprocess communication (IPC) protocol (fuchsia.examples.calculator.Calculator
) defined as a Fuchsia Interface Definition Language (FIDL) library. The BUILD.gn
file describes how to build the FIDL library that can be used as a dependency for the client and engine.engine/
: Contains the source for the calculator engine that accepts compute operations and sends the results back. The engine handles incoming requests as FIDL messages received from the client.client/
: Contains the source for the client that sends compute requests to the calculator engine then prints the results to the system log.meta/
: Top-level component realm to perform capability routing between the engine and client components.Start a FEMU instance:
$ ./third_party/fuchsia-sdk/bin/femu.sh -N
Start a local package repository instance:
$ ./third_party/fuchsia-sdk/bin/fserve.sh --image qemu-x64
Run the build script to compile and package the sample:
$ ./scripts/build.sh
Publish the FAR package to your local package repository:
$ ./third_party/fuchsia-sdk/bin/fpublish.sh out/x64/calculator-example.far
Launch the sample component using ffx component run
. This resolves the component from the package repository and starts it:
$ ffx component run fuchsia-pkg://fuchsia.com/calculator-example#meta/calculator_realm.cm
View the result messages in the system log using ffx target log
:
$ ffx target log watch [calculator_realm/client] INFO: Request: 2 + 2 [calculator_realm/client] INFO: Result: 4