CODING_STYLE: clarify the rules for the src/basic & src/shared split

The rule is changed from "put in basic unless there's a reason not to" to "put
in shared unless there's a reason not to", to match the change done in previous
commit. This minimizes libbasic. See previous commit for the reasons why this
is useful.

Previously, the guideline was based on whether the files in question use
"publicly exported APIs". This distinction is not particularly relevant. Let's
consider all other programs we compile: most of them use "publicly exported
APIs", usually linking to libsystemd-shared.so for the actual code. But those
programs are not forced to be in src/basic, and the distinction whether they
happen to use 'sd-*.h' or not is of no importance. The same is true for files
in src/shared/. If we didn't have publicly exported shared objects, we'd put
everything in libsystemd-shared.so. So let's only move things out of it that we
need to. Previous guideline was not "wrong", in the sense that it created *a*
split that was functional (no code in src/shared was required in the publicly
exported shared objects), but it put more files in basic/ then necessary.

Not much changes in practice, because (as previous commit shows), moving files
between libbasic.a and libsystemd-shared.so mostly just changes compilation
order.

The list of components which cannot use libsystemd-shared.so is adjusted.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-11-19 13:14:21 +01:00
parent 4de8d971f0
commit a527f70a41
1 changed files with 10 additions and 7 deletions

View File

@ -431,12 +431,13 @@
want to call it "big endian" right-away.
- You might wonder what kind of common code belongs in `src/shared/` and what
belongs in `src/basic/`. The split is like this: anything that uses public APIs
we expose (i.e. any of the sd-bus, sd-login, sd-id128, ... APIs) must be
located in `src/shared/`. All stuff that only uses external libraries from
other projects (such as glibc's APIs), or APIs from `src/basic/` itself should
be placed in `src/basic/`. Conversely, `src/libsystemd/` may only use symbols
from `src/basic`, but not from `src/shared/`.
belongs in `src/basic/`. The split is like this: anything that is used to
implement the public shared object we provide (sd-bus, sd-login, sd-id128,
nss-systemd, nss-mymachines, nss-resolve, nss-myhostname, pam_systemd), must
be located in `src/basic` (those objects are not allowed to link to
libsystemd-shared.so). Conversly, anything which is shared between multiple
components and does not need to be in `src/basic/`, should be in
`src/shared/`.
To summarize:
@ -449,7 +450,9 @@
- may not use any code outside of `src/basic/`, `src/libsystemd/`
`src/shared/`
- may be used by all code in the tree, except for code in `src/basic/`, `src/libsystemd/`
- may be used by all code in the tree, except for code in `src/basic/`,
`src/libsystemd/`, `src/nss-*`, `src/login/pam_systemd.*`, and files under
`src/journal/` that end up in `libjournal-client.a` convenience library.
- may not use any code outside of `src/basic/`, `src/libsystemd/`, `src/shared/`
- Our focus is on the GNU libc (glibc), not any other libcs. If other libcs are