> ## Documentation Index
> Fetch the complete documentation index at: https://docs.springtail.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Building & Modules

## Compiling the code

Compiling the C++ code is fairly straightforward.  All dependencies will be installed via vcpkg; note the first build may take a long time due to downloading and compiling all dependencies.

Make sure all dependencies from the [Local Dev Environment](/local-dev-environment) setup have been installed; otherwise vcpkg deps will not compile.

To do a debug build run:

```bash theme={null}
springtail % ./debug.sh  # first time build, setups up springtail/debug
springtail % cd debug; make # compile source; or switch to appropriate module
springtail % ./clean.sh. # does a make clean and removes the springtail/debug dir
```

## Adding a C++ module

* Create new subdirs under src/ and include/
* Add module to top level CMakeLists.txt: `add_subdirectory(src/module)`
* Within module (`/src/module/`) create a test subdir and a CMakeLists.txt
* Add source code and library dependencies to CMakeLists.txt
* Add test source code (or helper utils) under `test/` subdir

  * Add to function `springtail_unit_test()` to `CMakeLists.txt`
  * E.g.

  ```
  springtail_unit_test(test_replica_shutdown
    SOURCES test/test_replica_shutdown.cc
    INCLUDES ${CMAKE_SOURCE_DIR}/include
    LIBS springtail_proxy GTest::gtest_main
  )
  ```

## Accessing the postgres database on your machine

Run the following command: `psql "dbname=springtail user=springtail host=/var/run/postgresql password=springtail”`
