Getting Started with KubOS and Rust =================================== This document will cover getting started using Rust for local KubOS development. You will need to have the build dependencies listed in :ref:`local build dependencies ` installed prior to using Rust. After these dependencies have been installed, you are ready to begin creating and running your own Rust projects. New Project ----------- A new Rust project can be created by running the following command:: $ cargo new project_name Cargo will create the project folder and a basic folder structure. It is suggested that you create custom mission applications or services outside of the Kubos source repo, preferably in your own project's repo folder. Compiling and Running --------------------- To compile the project use the normal Cargo build command:: $ cargo build This command should be run from within the project's directory, which was generated by the ``cargo new`` command. The resulting binary will be located in `{project directory}/target/debug/{project name}`. The binary can be run locally using the ``cargo run`` command. Any desired arguments can be passed to the underlying executable by placing them behind ``--`` like so:: $ cargo run -- -c config.toml .. _rust-opt: Making Rust Binaries Smaller ---------------------------- By default, Rust binaries can be quite large. These are some steps which we recommend in order to drastically shrink the size of your compiled application: - Do a release build, rather than a debug build (``cargo build --release``) - Add the following optimization args to your `Cargo.toml` file and recompile:: [profile.release] lto = true opt-level = "z" panic = "abort" codegen-units = 1 - After the binary has been built, run ``arm-linux-strip /path/to/binary`` Next Steps ---------- Ready to create a mission application in Rust? Take a look at the :doc:`Python mission application <../tutorials/first-mission-app>` tutorial for guidance in the construction of a mission application. The `example rust mission application `__ is a good model for a Rust-based mission application. Interested in cross-compiling your project for use on hardware? Take a look at the :doc:`local cross-compiling <../obc-docs/cross-compile>` guide. Interested in working on the KubOS Rust source or contributing back? Take a look at the :doc:`Contributing to KubOS <../contributing/index>` docs.