commit | c335978dfddf66208fa9bb9f7cb3cb4f2c3ae10c | [log] [tgz] |
---|---|---|
author | third-party-roller <third-party-roller@fuchsia-infra.iam.gserviceaccount.com> | Wed Apr 22 10:39:57 2020 +0000 |
committer | CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> | Wed Apr 22 10:39:57 2020 +0000 |
tree | 245f4e636251b3fd25ddbb1c00beaa393686a831 | |
parent | e222dd1e4c7f74abd25994198cdc5819daef20d3 [diff] |
Updating with "scripts/update-fuchsia-sdk.sh" Change-Id: I200ecc35b81154b5cfd647de9cc8bb02b232eec0 Reviewed-on: https://fuchsia-review.googlesource.com/c/samples/+/382594 Reviewed-by: third_party Roller <third-party-roller@fuchsia-infra.iam.gserviceaccount.com> Commit-Queue: third_party Roller <third-party-roller@fuchsia-infra.iam.gserviceaccount.com>
A collection of samples demonstrating how to build, run, and test Fuchsia components outside the Fuchsia source code tree.
These samples might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy. |
---|
sudo apt-get install curl unzip python python2
.git clone https://fuchsia.googlesource.com/samples --recursive
. If you have already cloned this repo without the --recursive
flag you can run git submodule init && git submodule update --recursive
to download the submodules.cd samples
and setup and run the tests./scripts/setup-and-test.sh
. This script downloads all required dependencies (this may take 5-30min), build the samples and run the tests. If the script completes without errors all tests have passed.The C++ samples in this repo only support linux hosts and the GN build system.
To get started see the SDK documentation.
The src/hello_world
directory contains the source for the sample that prints “Hello, world”. The BUILD.gn
contains rules for how to build a single binary (hello_bin
) with its shared and static libraries dependencies. The hello_world.cmx
contains metadata necessary to run the binary as a component on Fuchsia.
rot13 (“rotate by 13 places”) takes a message a replaces each letter in the message with the letter 13th places after it in the alphabet. The rot13 sample has three parts: a client, a server, and a library defining the communication protocol for the server and client:
src/rot13/fild
directory contains the definition of a Fuchsia interprocess communication (IPC) protocol for a rot13 server and client. rot13.fidl
is a Fuchsia Interface Definition Language (FIDL) file that defines a message that can be sent between the server and client's that implment the protocol. The BUILD.gn
file describes how to build the FIDL file as a library that can be used as a dependency for the client and server binaries.src/rot13/client
directory contains the source for the rot13 echo client that sends the string “uryyb jbeyq” (“hello world” after being rot13 encoded) to a rot13 server via Fuchsia's interprocess communication (IPC) system called FIDL (Fuchsia Interface Definition Language) using the protocol defined in src/rot13/fidl/rot13.fidl
. The client then prints the response from the server. The BUILD.gn
file describes how to build the client binary with the necessary dependencies including a the FIDL library defined in src/rot13/fidl
. The meta/rot13_client.cmx
contains metadata necessary to run the binary as a component on Fuchsia.src/rot13/server
directory contains the source for the rot13 echo server that takes rot13 encoded messages from clients and decodes the messages and sends the decoded message back to the client. The server receives and responds to message via Fuchsia's interprocess communication (IPC) system called FIDL (Fuchsia Interface Definition Language) using the protocol defined in src/rot13/fidl/rot13.fidl
. The BUILD.gn
file describes how to build the server binary with the necessary dependencies including a the FIDL library defined in src/rot13/fidl
. The meta/rot13_client.cmx
contains metadata necessary to run the binary as a component on Fuchsia.The build
directory contains the build configuration for the sample including the toolchain, targets and tests.
The buildtools
directory contains scripts to help with the build process like downloading needed tools (e.g. gn, ninja).
The src
directory contains the source code for the two C++ samples: hello world and rot13 echo server/client.
GN samples has two third_party dependencies: the Fuchsia GN SDK and googletest (googletest is only required for testing):
Fuchsia system images can be started with the included emulator scripts. Native Vulkan support on the host is required for graphics support.
sudo apt-get install libvulkan1 mesa-vulkan-drivers
../scripts/download-build-tools.sh
../buildtools/linux64/gn gen out/x64 --args='target_os="fuchsia" target_cpu="x64"'
../buildtools/linux64/ninja -C out/x64 bouncing_ball
./third_party/fuchsia-sdk/bin/femu.sh -N
../third_party/fuchsia-sdk/bin/fserve.sh --image qemu-x64
../third_party/fuchsia-sdk/bin/fpublish.sh ./out/x64/bouncing_ball.far
../third_party/fuchsia-sdk/bin/fssh.sh tiles_ctl add fuchsia-pkg://fuchsia.com/bouncing_ball#meta/bouncing_ball.cmx
.