Skip to content

Commit 31baccc

Browse files
committed
build-sys: update setup.py to build everything
1 parent 022c9b5 commit 31baccc

File tree

10 files changed

+176
-15
lines changed

10 files changed

+176
-15
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SED = sed
2+
INCLUDE_DIR = /usr/include/
3+
4+
systemd/id128-constants.h: $(INCLUDE_DIR)/systemd/sd-messages.h
5+
$(SED) -n -r 's/,//g; s/#define (SD_MESSAGE_[A-Z0-9_]+)\s.*/add_id(m, "\1", \1) JOINER/p' <$< >$@

setup.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,43 @@
11
from distutils.core import setup, Extension
22

3-
cjournal = Extension('systemd/_journal',
4-
libraries = ['systemd-journal'],
5-
sources = ['systemd/_journal.c'])
3+
version = '221'
4+
defines = [('PACKAGE_VERSION', '"{}"'.format(version))]
65

6+
_journal = Extension('systemd/_journal',
7+
define_macros = defines,
8+
libraries = ['systemd'],
9+
sources = ['systemd/_journal.c',
10+
'systemd/pyutil.c'])
11+
_reader = Extension('systemd/_reader',
12+
define_macros = defines,
13+
libraries = ['systemd'],
14+
sources = ['systemd/_reader.c',
15+
'systemd/pyutil.c',
16+
'systemd/strv.c'])
17+
_daemon = Extension('systemd/_daemon',
18+
define_macros = defines,
19+
libraries = ['systemd'],
20+
sources = ['systemd/_daemon.c',
21+
'systemd/pyutil.c'])
22+
id128 = Extension('systemd/id128',
23+
define_macros = defines,
24+
libraries = ['systemd'],
25+
sources = ['systemd/id128.c',
26+
'systemd/pyutil.c'])
27+
login = Extension('systemd/login',
28+
define_macros = defines,
29+
libraries = ['systemd'],
30+
sources = ['systemd/login.c',
31+
'systemd/pyutil.c',
32+
'systemd/strv.c'])
733
setup (name = 'systemd',
8-
version = '0.1',
34+
version = version,
935
description = 'Native interface to the facilities of systemd',
1036
author_email = 'david@davidstrauss.net',
1137
url = 'https://github.com/systemd/python-systemd',
12-
py_modules = ['systemd.journal'],
13-
ext_modules = [cjournal])
38+
py_modules = ['systemd.journal', 'systemd.daemon'],
39+
ext_modules = [_journal,
40+
_reader,
41+
_daemon,
42+
id128,
43+
login])

systemd/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/id128-constants.h
22
*.py[oc]
3+
*.so

systemd/_journal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
#include <Python.h>
2323

2424
#include <alloca.h>
25-
#include "util.h"
2625

2726
#define SD_JOURNAL_SUPPRESS_LOCATION
2827
#include "systemd/sd-journal.h"
2928

29+
#include "macro.h"
30+
3031
PyDoc_STRVAR(journal_sendv__doc__,
3132
"sendv('FIELD=value', 'FIELD=value', ...) -> None\n\n"
3233
"Send an entry to the journal."

systemd/_reader.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
#include <datetime.h>
2525
#include <time.h>
2626
#include <stdio.h>
27+
#include <stdbool.h>
2728

2829
#include "systemd/sd-journal.h"
2930

3031
#include "pyutil.h"
3132
#include "macro.h"
32-
#include "util.h"
3333
#include "strv.h"
34-
#include "build.h"
3534

3635
typedef struct {
3736
PyObject_HEAD
@@ -113,8 +112,10 @@ static int strv_converter(PyObject* obj, void *_result) {
113112
goto cleanup;
114113

115114
s2 = strdup(s);
116-
if (!s2)
117-
log_oom();
115+
if (!s2) {
116+
set_error(-ENOMEM, NULL, NULL);
117+
goto cleanup;
118+
}
118119

119120
(*result)[i] = s2;
120121
}
@@ -343,7 +344,7 @@ static PyObject* Reader_next(Reader *self, PyObject *args) {
343344
else if (skip < -1LL)
344345
r = sd_journal_previous_skip(self->j, -skip);
345346
else
346-
assert_not_reached("should not be here");
347+
assert(!"should be here");
347348
Py_END_ALLOW_THREADS
348349

349350
if (set_error(r, NULL, NULL) < 0)

systemd/id128.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include "systemd/sd-messages.h"
2525

2626
#include "pyutil.h"
27-
#include "log.h"
28-
#include "util.h"
2927
#include "macro.h"
3028

3129
PyDoc_STRVAR(module__doc__,

systemd/login.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#include "systemd/sd-login.h"
2929
#include "pyutil.h"
30-
#include "util.h"
3130
#include "strv.h"
3231

3332
PyDoc_STRVAR(module__doc__,

systemd/macro.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2+
3+
#pragma once
4+
5+
/***
6+
This file is part of systemd.
7+
8+
Copyright 2010 Lennart Poettering
9+
10+
systemd is free software; you can redistribute it and/or modify it
11+
under the terms of the GNU Lesser General Public License as published by
12+
the Free Software Foundation; either version 2.1 of the License, or
13+
(at your option) any later version.
14+
15+
systemd is distributed in the hope that it will be useful, but
16+
WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+
Lesser General Public License for more details.
19+
20+
You should have received a copy of the GNU Lesser General Public License
21+
along with systemd; If not, see <http://www.gnu.org/licenses/>.
22+
***/
23+
24+
#define DISABLE_WARNING_MISSING_PROTOTYPES \
25+
_Pragma("GCC diagnostic push"); \
26+
_Pragma("GCC diagnostic ignored \"-Wmissing-prototypes\"")
27+
28+
#define REENABLE_WARNING \
29+
_Pragma("GCC diagnostic pop")
30+
31+
#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
32+
static inline void func##p(type *p) { \
33+
if (*p) \
34+
func(*p); \
35+
} \
36+
struct __useless_struct_to_allow_trailing_semicolon__
37+
38+
#define new0(t, n) ((t*) calloc((n), sizeof(t)))
39+
#define alloca0(n) \
40+
({ \
41+
char *_new_; \
42+
size_t _len_ = n; \
43+
_new_ = alloca(_len_); \
44+
(void *) memset(_new_, 0, _len_); \
45+
})
46+
47+
#define _cleanup_(x) __attribute__((cleanup(x)))
48+
49+
static inline void freep(void *p) {
50+
free(*(void**) p);
51+
}
52+
53+
#define _cleanup_free_ _cleanup_(freep)
54+
55+
#if defined(static_assert)
56+
# define assert_cc(expr) \
57+
static_assert(expr, #expr)
58+
#else
59+
# define assert_cc(expr)
60+
#endif

systemd/strv.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2+
3+
/***
4+
This file is part of systemd.
5+
6+
Copyright 2010 Lennart Poettering
7+
8+
systemd is free software; you can redistribute it and/or modify it
9+
under the terms of the GNU Lesser General Public License as published by
10+
the Free Software Foundation; either version 2.1 of the License, or
11+
(at your option) any later version.
12+
13+
systemd is distributed in the hope that it will be useful, but
14+
WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public License
19+
along with systemd; If not, see <http://www.gnu.org/licenses/>.
20+
***/
21+
22+
#include <stdlib.h>
23+
24+
void strv_clear(char **l) {
25+
char **k;
26+
27+
if (!l)
28+
return;
29+
30+
for (k = l; *k; k++)
31+
free(*k);
32+
33+
*l = NULL;
34+
}
35+
36+
char **strv_free(char **l) {
37+
strv_clear(l);
38+
free(l);
39+
return NULL;
40+
}

systemd/strv.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2+
3+
/***
4+
This file is part of systemd.
5+
6+
Copyright 2010 Lennart Poettering
7+
8+
systemd is free software; you can redistribute it and/or modify it
9+
under the terms of the GNU Lesser General Public License as published by
10+
the Free Software Foundation; either version 2.1 of the License, or
11+
(at your option) any later version.
12+
13+
systemd is distributed in the hope that it will be useful, but
14+
WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public License
19+
along with systemd; If not, see <http://www.gnu.org/licenses/>.
20+
***/
21+
22+
#include "macro.h"
23+
24+
char **strv_free(char **l);
25+
DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free);
26+
#define _cleanup_strv_free_ _cleanup_(strv_freep)

0 commit comments

Comments
 (0)