doc/HACKING: Update Module.md for the relay module

Also fix some typos, and delete some obsolete instructions.

Part of 32123.
This commit is contained in:
teor 2019-10-17 16:12:24 +10:00
parent bf45b6cf0c
commit 0973575737
No known key found for this signature in database
GPG Key ID: 10FEAA0E7075672A

View File

@ -8,13 +8,18 @@ module in Tor.
In the context of the tor code base, a module is a subsystem that we can
selectively enable or disable, at `configure` time.
Currently, there is only one module:
Currently, tor has these modules:
- Relay subsystem (relay)
- Directory Authority subsystem (dirauth)
It is located in its own directory in `src/feature/dirauth/`. To disable it,
one need to pass `--disable-module-dirauth` at configure time. All modules
are currently enabled by default.
dirauth is located in its own directory in `src/feature/dirauth/`.
Relay is located in directories named `src/*/*relay` and `src/*/*dircache`,
which are being progressively refactored and disabled.
To disable a module, pass `--disable-module-{dirauth,relay}` at configure
time. All modules are currently enabled by default.
## Build System ##
@ -24,7 +29,7 @@ The changes to the build system are pretty straightforward.
contains a list (white-space separated) of the module in tor. Add yours to
the list.
2. Use the `AC_ARG_ENABLE([module-dirauth]` template for your new module. We
2. Use the `AC_ARG_ENABLE([module-relay]` template for your new module. We
use the "disable module" approach instead of enabling them one by one. So,
by default, tor will build all the modules.
@ -32,7 +37,7 @@ The changes to the build system are pretty straightforward.
the C code to conditionally compile things for your module. And the
`BUILD_MODULE_<name>` is also defined for automake files (e.g: include.am).
3. In the `src/core/include.am` file, locate the `MODULE_DIRAUTH_SOURCES`
3. In the `src/core/include.am` file, locate the `MODULE_RELAY_SOURCES`
value. You need to create your own `_SOURCES` variable for your module
and then conditionally add the it to `LIBTOR_A_SOURCES` if you should
build the module.
@ -40,18 +45,14 @@ The changes to the build system are pretty straightforward.
It is then **very** important to add your SOURCES variable to
`src_or_libtor_testing_a_SOURCES` so the tests can build it.
4. Do the same for header files, locate `ORHEADERS +=` which always add all
headers of all modules so the symbol can be found for the module entry
points.
Finally, your module will automatically be included in the
`TOR_MODULES_ALL_ENABLED` variable which is used to build the unit tests. They
always build everything in order to tests everything.
`TOR_MODULES_ALL_ENABLED` variable which is used to build the unit tests.
They always build everything in order to test everything.
## Coding ##
As mentioned above, a module must be isolated in its own directory (name of
the module) in `src/feature/`.
As mentioned above, a module should be isolated in its own directories,
suffixed with the name of the module, in `src/*/`.
There are couples of "rules" you want to follow: