| 1 |
libglnx is the successor to [libgsystem](https://gitlab.gnome.org/Archive/libgsystem). |
| 2 |
|
| 3 |
It is for modules which depend on both GLib and Linux, intended to be |
| 4 |
used as a git submodule. |
| 5 |
|
| 6 |
Features: |
| 7 |
|
| 8 |
- File APIs which use `openat()` like APIs, but also take a `GCancellable` |
| 9 |
to support dynamic cancellation |
| 10 |
- APIs also have a `GError` parameter |
| 11 |
- High level "shutil", somewhat inspired by Python's |
| 12 |
- A "console" API for tty output |
| 13 |
- A backport of the GLib cleanup macros for projects which can't yet take |
| 14 |
a dependency on 2.40. |
| 15 |
|
| 16 |
Why? |
| 17 |
---- |
| 18 |
|
| 19 |
There are multiple projects which have a hard dependency on Linux and |
| 20 |
GLib, such as NetworkManager, ostree, flatpak, etc. It makes sense |
| 21 |
for them to be able to share Linux-specific APIs. |
| 22 |
|
| 23 |
This module also contains some code taken from systemd, which has very |
| 24 |
high quality LGPLv2+ shared library code, but most of the internal |
| 25 |
shared library is private, and not namespaced. |
| 26 |
|
| 27 |
One could also compare this project to gnulib; the salient differences |
| 28 |
there are that at least some of this module is eventually destined for |
| 29 |
inclusion in GLib. |
| 30 |
|
| 31 |
Adding this to your project |
| 32 |
--------------------------- |
| 33 |
|
| 34 |
## Meson |
| 35 |
|
| 36 |
First, set up a Git submodule: |
| 37 |
|
| 38 |
``` |
| 39 |
git submodule add https://gitlab.gnome.org/GNOME/libglnx subprojects/libglnx |
| 40 |
``` |
| 41 |
|
| 42 |
Or a Git [subtree](https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt): |
| 43 |
|
| 44 |
``` |
| 45 |
git remote add libglnx https://gitlab.gnome.org/GNOME/libglnx.git |
| 46 |
git fetch libglnx |
| 47 |
git subtree add -P subprojects/libglnx libglnx/master |
| 48 |
``` |
| 49 |
|
| 50 |
Then, in your top-level `meson.build`: |
| 51 |
|
| 52 |
``` |
| 53 |
libglnx_dep = subproject('libglnx').get_variable('libglnx_dep') |
| 54 |
# now use libglnx_dep in your dependencies |
| 55 |
``` |
| 56 |
|
| 57 |
Porting from libgsystem |
| 58 |
----------------------- |
| 59 |
|
| 60 |
For all of the filesystem access code, libglnx exposes only |
| 61 |
fd-relative API, not `GFile*`. It does use `GCancellable` where |
| 62 |
applicable. |
| 63 |
|
| 64 |
For local allocation macros, you should start using the `g_auto` |
| 65 |
macros from GLib. A backport is included in libglnx. There are a few |
| 66 |
APIs not defined in GLib yet, such as `glnx_autofd`. |
| 67 |
|
| 68 |
`gs_transfer_out_value` is replaced by `g_steal_pointer`. |
| 69 |
|
| 70 |
Contributing |
| 71 |
------------ |
| 72 |
|
| 73 |
Development happens in GNOME Gitlab: https://gitlab.gnome.org/GNOME/libglnx |
| 74 |
|
| 75 |
(If you're seeing this on the Github mirror, we used to do development |
| 76 |
on Github but that was before GNOME deployed Gitlab.) |
| 77 |
|
| 78 |
<!-- |
| 79 |
Copyright 2015-2018 Colin Walters |
| 80 |
Copyright 2019 Endless OS Foundation LLC |
| 81 |
SPDX-License-Identifier: LGPL-2.1-or-later |
| 82 |
--> |