Skip to content

Commit b4505ce

Browse files
aschwerdfeger-galoisdc-mak
authored andcommitted
Added sections about the dev container and coding style to 'CONTRIBUTING.md'.
1 parent e7f971b commit b4505ce

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

doc/CONTRIBUTING.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Learn how the CN project works and how you can contribute.
44

55
## Start here
66

7-
TODO (dcm41): Setting up ocamlformat.
87
TOD (PS?): licensing agreements, acks etc?
98

109
We use [this GitHub project](https://github.com/orgs/GaloisInc/projects/23/views/9) to
@@ -25,10 +24,17 @@ Wondering if the juice is worth the squeeze? Jump to [Why this process?](#why-th
2524

2625
## Setting up your development environment
2726

28-
We currently don't have any specific environment setup, but will add information
29-
here as we progress in the project.
27+
### VSCode development container
3028

31-
Mac OS X users should install the coreutils package with the following to run the `timeout` command which is used in test scripts (like `tests/run-cn.sh`).
29+
For those using Visual Studio Code, there is a development container that may be used as a CN development environment. This requires a Docker container engine and the [Dev Containers VSCode extension](https://marketplace.visualstudio.com/items/?itemName=ms-vscode-remote.remote-containers). If these are installed, on opening the CN repository in VSCode you will be prompted to reopen in a container. This will pull the image and set everything up.
30+
31+
### General setup instructions
32+
33+
For those setting up a development environment outside VSCode, see [the project README](../README.md#installation) for instructions on the basic development-environment setup (following step 6 "for CN developers").
34+
35+
If modifying any ML or C files, be sure you have the correct versions of code-formatting tools installed (see [the "Coding style" section](#coding-style) below).
36+
37+
Those developing on macOS should install the `coreutils` package to enable running the `timeout` command used in test scripts such as `tests/run-cn.sh`. If using the [Homebrew](https://brew.sh/) package manager, this is installed as follows:
3238
```
3339
brew install coreutils
3440
```
@@ -130,6 +136,24 @@ guidelines on merging your branch commit history into `main`.
130136
- Prefer library-first development (the functionality of any program should be available as a library)
131137
- A clean version control history is important (e.g., to support bisecting and code understanding), but extensive history rewriting is not important (more on this in [Git guidelines](#git-guidelines))
132138

139+
### Coding style
140+
141+
CN maintains (and enforces in its CI builds) coding styles for both its ML and C source files.
142+
143+
CN's ML style rules (viewable [here](../.ocamlformat)) are maintained by the `ocamlformat` tool. The C style rules are the default LLVM style and are maintained by the `clang-format` tool. Style rules vary slightly between different versions of `clang-format`, so it is important to use a compatible version to ensure that the style tests in the CI builds pass. The CI uses the latest release of version 19 from [the LLVM Foundation](https://llvm.org/), which is also available for Debian/Ubuntu systems through an [APT repository](https://apt.llvm.org/).
144+
145+
When developing with Visual Studio Code, if `ocamlformat` is installed, the OCaml extension will automatically format any ML file when it is saved. VSCode's C extension can also be configured to auto-format C files with `clang-format` on save. CN's [development container](#vscode-development-container) contains the formatting tools for both languages.
146+
147+
Outside of VSCode, the style of the ML files can be checked by running the following command from the repository's root directory:
148+
```
149+
dune build @fmt
150+
```
151+
The C files' style may be checked by running `clang-format` on every file with the extension `.c` or `.h` in the `runtime/libcn` directory. On a POSIX-compliant system, the style-checking command is
152+
```
153+
find runtime/libcn/ -iname '*.h' -o -iname '*.c' | xargs clang-format --dry-run -Werror
154+
```
155+
156+
133157
## Git guidelines
134158

135159
- [General guidelines](#general-guidelines)

0 commit comments

Comments
 (0)