Building and running a session {#building-and-running-a-session}
A session is the first product-specific component started on boot. The session component is responsible for building a product’s user experience. For more information on sessions, see session framework.
Booting into a session {#booting-into-a-session}
To boot into a session, do the following:
For a session to run at boot you need to create a configuration file with the session component URL.
{
"session_url": "fuchsia-pkg://fuchsia.com/pkg-name#meta/your_session.cm"
}
Replace the following:
- pkg-name: the package name
- your_session.cm: the name of your session, including the
.cm
extension.
For more information, see
fuchsia-pkg
and Package name.In the
BUILD.gn
file, include the configuration file for the session componentimport("//src/session/build/session_config.gni")
session_config("your_session_config") {
config = "path/to/config.json"
}
Run the following command to include the
session_manager
,your_session
, and:your_session_config
in your base image:fx set product.board --with-base=//src/session,//path/to/your/session,//path/to/your/session:your_session_config
Note: Selecting a product that already has a session_config will result in a build error because the configurations will conflict. The
core
product would be a good choice as a starting point as it includes only the bare minimum needed to launch Fuchsia.fx list-products
andfx list-boards
will show lists of the products and boards available to be used in thefx set
command. For more information onfx
commands see the fx documentation.Rebuild and re-pave the device.
fx build
fx ota
This causes
session_manager
to start and launch your session.
For a full explanation of building a session component, see Writing a Hello World Session.
Launch a session from the command line {#launch-a-session-from-the-command-line}
There are cases when you don’t want your session to launch at boot but still
want to be able to launch it from the command line. There still needs to be a
session launched at boot so configure the build to use the default
session_manager
configuration.
To launch a session from the command line, do the following:
Run the following command to include the
session_manager
and thesession_manager
configuration file,session_manager.config
, in the base image while also including your session in the build.fx set product.board --with-base=//src/session,//src/session/bin/session_manager:session_manager.config --with=//path/to/your/session
fx list-products
andfx list-boards
will show lists of the products and boards available to be used in thefx set
command. For more information onfx
commands see the fx documentation.Run the following command to rebuild and repave the device:
fx build
fx ota
This causes
session_manager
to start without launching your session.Your session can now be launched from the command line.
Run the following command to launch your session:
ffx session launch fuchsia-pkg://fuchsia.com/pkg-name#meta/your_session.cm
For more information about the
ffx session
command, runffx session --help
. For more information aboutffx
, see theffx documentation
.