Building AMBA for release is done with nix.
$ nix build .#ambaBuilding 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 developThis 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.
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.
- A
compile_flags.txtfile is required at the top level. This file can be generated by runningmake compile_flags.txtin the top folder while in the dev shell. - 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.gitIf 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 is much simplier. Just add it to Cargo.toml
of the crate in question and then run
$ cargo check && cargo2nix -ffrom the top folder. Make sure to commit the new lockfiles.
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 fmtAMBA can be testrun with the command:
$ nix run .#test-ambaRust crates' tests can be run with
$ cargo testfrom either the top level folder or each respective crate.