Skip to content

Latest commit

 

History

History
80 lines (70 loc) · 2.61 KB

File metadata and controls

80 lines (70 loc) · 2.61 KB

Development

Building AmbaPlugin

Building AMBA for release is done with nix.

$ nix build .#amba

Building AMBA for development is done by running make in the crates/AmbaPlugin directory. To install all of the required dependencies we recommend that you use a nix dev shell.

$ nix develop

This will not result in a runnable binary however, just a compiled S2E plugin. To link the plugin with S2E and run it the impure-amba script is provided in the nix devshell.

AMBA built with Nix will be built with no debug symbols and with optimisations while AMBA built with manual make commands in a dev shell will build with no optimisations and maximum debug symbols.

LSP

AMBA is written in a mix of C++ and Rust. For these languages we recommend using clangd and rust-analyzer respectively. They are both included in the nix devshell.

Clangd requires additional configuration however.

  1. A compile_flags.txt file is required at the top level. This file can be generated by running make compile_flags.txt in the top folder while in the dev shell.
  2. A local copy of the S2E project is required for jump to definition actions in some editors. This can be acquired by running
$ git clone https://github.com/S2E/s2e.git

Adding dependencies in C++

If the library exists in nixpkgs you need to add the path to the package and then its include folder in the all-include-paths variable in nix/libamba.nix. If it doesn't or you need to override parts of it create a new derivation for it and include that. See nix/zycore.nix for inspiration. Then you also need to add it to the LIBS variable in crates/AmbaPlugin/Makefile and to the list in crates/AmbaPlugin/compile_flags_template.txt. compile_flags.txt needs to be regenerated after this and you might need to reload your LSP server.

Adding dependencies in Rust

Adding dependencies in Rust is much simplier. Just add it to Cargo.toml of the crate in question and then run

$ cargo check && cargo2nix -f

from the top folder. Make sure to commit the new lockfiles.

Formatting

C++ is manually formatted. Contributions of a automatic formatting setup that follows the existing style is appreciated. Rust is formatted with rustfmt. Make sure to run rustfmt on every commit as CI checks for style. You can run rustfmt with

$ cargo fmt

Tests

AMBA can be testrun with the command:

$ nix run .#test-amba

Rust crates' tests can be run with

$ cargo test

from either the top level folder or each respective crate.

READMEs