]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
CODING_STYLE: clarify the rules for the src/basic & src/shared split
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 19 Nov 2018 12:14:21 +0000 (13:14 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Nov 2018 06:27:37 +0000 (07:27 +0100)
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.

docs/CODING_STYLE.md

index b8337fd097fc3cfb24cdcbeae8da3a1688a31458..abcdaab4acac32e57e93d9d9c67d340a0f728491 100644 (file)
   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:
 
   - 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