Skip to content

Commit

Permalink
Add developer documentation for astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldouglas92 committed Feb 13, 2024
1 parent 40655ff commit 98f5bee
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
Astyle
=====

```{todo}
Explain what Astyle does, why it is important and how to get the right version.
```
Astyle (Artistic Style) is a tool that automates the formatting of code. Executing astyle will automatically indent new code to the standard that the Geodynamic WorldBuilder uses, and should be done before each pull request to ensure that the indenter tests do not fail.

GWB requires the use of astyle v2.04, which can be downloaded from sourceforge [here](https://sourceforge.net/projects/astyle/files/astyle/astyle%202.04/) for mac, linux or windows.

An example one line command for how to build and install the correct version of astyle on linux is shown below, followed by a more general description on building astyle and linking it to the GWB.

`mkdir astyle && cd astyle && wget 'https://sourceforge.net/projects/astyle/files/astyle/astyle 2.04/astyle_2.04_linux.tar.gz' && tar -zxvf astyle_2.04_linux.tar.gz && cd astyle/build/gcc && make && sudo make install`

After the download is complete, simply unzip the files in your desired directory, and compile the astyle executible. To do this, run `make` in the `$ASTYLE_DIR/build/$COMPILER`. Here `$ASTYLE_DIR` is the path to the unzipped astyle directory, and `$COMPILER` is the directory within `$ASTYLE_DIR/build/` that corresponds to the compiler you will use to generate astyle (gcc, clang, intel, etc.). This should generate the astyle executible in `$ASTYLE_DIR/build/$COMPILER/bin/`. For the GWB to see this executible, you now need to add this to your `$PATH`. For mac, open your `~/.bash_profile` and add the following line:

`export PATH=$ASTYLE_DIR/build/$COMPILER/bin/:$PATH`

Now, if you navigate to `$WORLDBUILDER_SOURCE_DIR/build` and run `make indent`, astyle will run and automatically format all files within `$WORLDBUILDER_SOURCE_DIR`.

0 comments on commit 98f5bee

Please sign in to comment.