summaryrefslogtreecommitdiff
path: root/libnm
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-01-02 13:37:06 +0100
committerThomas Haller <thaller@redhat.com>2018-01-08 12:38:53 +0100
commit22ef6a507a308f2fe495b60bef78ac2ca00fb6d2 (patch)
tree3bd2f287df3db9c5254f9b27607b4f0735b938d7 /libnm
parent31b6abd4b533c56c91c616498ee2080d56d0fd48 (diff)
downloadNetworkManager-22ef6a507a308f2fe495b60bef78ac2ca00fb6d2.tar.gz
build: refine the NETWORKMANAGER_COMPILATION define
Note that: - we compile some source files multiple times. Most notably those under "shared/". - we include a default header "shared/nm-default.h" in every source file. This header is supposed to setup a common environment by defining and including parts that are commonly used. As we always include the same header, the header must behave differently depending one whether the compilation is for libnm-core, NetworkManager or libnm-glib. E.g. it must include <glib/gi18n.h> or <glib/gi18n-lib.h> depending on whether we compile a library or an application. For that, the source files need the NETWORKMANAGER_COMPILATION #define to behave accordingly. Extend the define to be composed of flags. These flags are all named NM_NETWORKMANAGER_COMPILATION_WITH_*, they indicate which part of the build are available. E.g. when building libnm-core.la itself, then WITH_LIBNM_CORE, WITH_LIBNM_CORE_INTERNAL, and WITH_LIBNM_CORE_PRIVATE are available. When building NetworkManager, WITH_LIBNM_CORE_PRIVATE is not available but the internal parts are still accessible. When building nmcli, only WITH_LIBNM_CORE (the public part) is available. This granularily controls the build.
Diffstat (limited to 'libnm')
-rw-r--r--libnm/meson.build2
-rw-r--r--libnm/nm-dbus-helpers.h4
-rw-r--r--libnm/nm-dhcp4-config.h11
-rw-r--r--libnm/nm-dhcp6-config.h11
-rw-r--r--libnm/nm-dns-manager.h11
-rw-r--r--libnm/nm-ip4-config.h11
-rw-r--r--libnm/nm-ip6-config.h11
-rw-r--r--libnm/nm-libnm-utils.h4
-rw-r--r--libnm/nm-manager.h14
-rw-r--r--libnm/nm-object-private.h4
-rw-r--r--libnm/nm-remote-connection-private.h4
-rw-r--r--libnm/nm-remote-settings.h12
-rw-r--r--libnm/tests/meson.build6
13 files changed, 49 insertions, 56 deletions
diff --git a/libnm/meson.build b/libnm/meson.build
index 80158c2fa2..062e8a8fb8 100644
--- a/libnm/meson.build
+++ b/libnm/meson.build
@@ -21,7 +21,7 @@ deps = [
cflags = [
'-DG_LOG_DOMAIN="libnm"',
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM',
'-DNMRUNDIR="@0@"'.format(nm_pkgrundir)
]
diff --git a/libnm/nm-dbus-helpers.h b/libnm/nm-dbus-helpers.h
index 1847da1d21..0f2cabe8cf 100644
--- a/libnm/nm-dbus-helpers.h
+++ b/libnm/nm-dbus-helpers.h
@@ -21,6 +21,10 @@
#ifndef __NM_DBUS_HELPERS_PRIVATE_H__
#define __NM_DBUS_HELPERS_PRIVATE_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-dbus-compat.h"
GBusType _nm_dbus_bus_type (void);
diff --git a/libnm/nm-dhcp4-config.h b/libnm/nm-dhcp4-config.h
index 2cbbdc9ebd..6669aa0ec1 100644
--- a/libnm/nm-dhcp4-config.h
+++ b/libnm/nm-dhcp4-config.h
@@ -21,9 +21,11 @@
#ifndef __NM_DHCP4_CONFIG_H__
#define __NM_DHCP4_CONFIG_H__
-#include "nm-dhcp-config.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-dhcp-config.h"
#define NM_TYPE_DHCP4_CONFIG (nm_dhcp4_config_get_type ())
#define NM_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4Config))
@@ -40,13 +42,8 @@ typedef struct {
typedef struct {
NMDhcpConfigClass parent;
-
- /*< private >*/
- gpointer padding[4];
} NMDhcp4ConfigClass;
GType nm_dhcp4_config_get_type (void);
-G_END_DECLS
-
#endif /* __NM_DHCP4_CONFIG_H__ */
diff --git a/libnm/nm-dhcp6-config.h b/libnm/nm-dhcp6-config.h
index 2d6568e12d..3c18f5ec48 100644
--- a/libnm/nm-dhcp6-config.h
+++ b/libnm/nm-dhcp6-config.h
@@ -21,9 +21,11 @@
#ifndef __NM_DHCP6_CONFIG_H__
#define __NM_DHCP6_CONFIG_H__
-#include "nm-dhcp-config.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-dhcp-config.h"
#define NM_TYPE_DHCP6_CONFIG (nm_dhcp6_config_get_type ())
#define NM_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6Config))
@@ -40,13 +42,8 @@ typedef struct {
typedef struct {
NMDhcpConfigClass parent;
-
- /*< private >*/
- gpointer padding[4];
} NMDhcp6ConfigClass;
GType nm_dhcp6_config_get_type (void);
-G_END_DECLS
-
#endif /* __NM_DHCP6_CONFIG_H__ */
diff --git a/libnm/nm-dns-manager.h b/libnm/nm-dns-manager.h
index 63989451e4..b72aea7da2 100644
--- a/libnm/nm-dns-manager.h
+++ b/libnm/nm-dns-manager.h
@@ -21,11 +21,13 @@
#ifndef __NM_DNS_MANAGER_H__
#define __NM_DNS_MANAGER_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-object.h"
#include "nm-client.h"
-G_BEGIN_DECLS
-
#define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type ())
#define NM_DNS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_MANAGER, NMDnsManager))
#define NM_DNS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_MANAGER, NMDnsManagerClass))
@@ -49,13 +51,8 @@ struct _NMDnsManager {
struct _NMDnsManagerClass {
NMObjectClass parent;
-
- /*< private >*/
- gpointer padding[8];
};
-G_END_DECLS
-
GType nm_dns_manager_get_type (void);
const char *nm_dns_manager_get_mode (NMDnsManager *manager);
diff --git a/libnm/nm-ip4-config.h b/libnm/nm-ip4-config.h
index d99b21138d..266e0bc52a 100644
--- a/libnm/nm-ip4-config.h
+++ b/libnm/nm-ip4-config.h
@@ -22,9 +22,11 @@
#ifndef __NM_IP4_CONFIG_H__
#define __NM_IP4_CONFIG_H__
-#include "nm-ip-config.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-ip-config.h"
#define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ())
#define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP4_CONFIG, NMIP4Config))
@@ -42,13 +44,8 @@ typedef struct {
typedef struct {
NMIPConfigClass parent;
-
- /*< private >*/
- gpointer padding[4];
} NMIP4ConfigClass;
GType nm_ip4_config_get_type (void);
-G_END_DECLS
-
#endif /* __NM_IP4_CONFIG_H__ */
diff --git a/libnm/nm-ip6-config.h b/libnm/nm-ip6-config.h
index 12e723b2fc..1d21adb4fe 100644
--- a/libnm/nm-ip6-config.h
+++ b/libnm/nm-ip6-config.h
@@ -22,9 +22,11 @@
#ifndef __NM_IP6_CONFIG_H__
#define __NM_IP6_CONFIG_H__
-#include "nm-ip-config.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-ip-config.h"
#define NM_TYPE_IP6_CONFIG (nm_ip6_config_get_type ())
#define NM_IP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP6_CONFIG, NMIP6Config))
@@ -42,13 +44,8 @@ typedef struct {
typedef struct {
NMIPConfigClass parent;
-
- /*< private >*/
- gpointer padding[4];
} NMIP6ConfigClass;
GType nm_ip6_config_get_type (void);
-G_END_DECLS
-
#endif /* __NM_IP6_CONFIG_H__ */
diff --git a/libnm/nm-libnm-utils.h b/libnm/nm-libnm-utils.h
index 4a5a361c51..7af5ba43ef 100644
--- a/libnm/nm-libnm-utils.h
+++ b/libnm/nm-libnm-utils.h
@@ -21,6 +21,10 @@
#ifndef __NM_LIBNM_UTILS_H__
#define __NM_LIBNM_UTILS_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
char *nm_utils_fixup_desc_string (const char *desc);
#endif /* __NM_LIBNM_UTILS_H__ */
diff --git a/libnm/nm-manager.h b/libnm/nm-manager.h
index 852a088972..ac0630ccf4 100644
--- a/libnm/nm-manager.h
+++ b/libnm/nm-manager.h
@@ -22,11 +22,13 @@
#ifndef __NM_MANAGER_H__
#define __NM_MANAGER_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-object.h"
#include "nm-client.h"
-G_BEGIN_DECLS
-
#define NM_TYPE_MANAGER (nm_manager_get_type ())
#define NM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MANAGER, NMManager))
#define NM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_MANAGER, NMManagerClass))
@@ -75,8 +77,6 @@ typedef struct {
void (*permission_changed) (NMManager *manager,
NMClientPermission permission,
NMClientPermissionResult result);
-
- /* nm-manager.h is internal API. We can add more slots without breaking ABI. */
} NMManagerClass;
GType nm_manager_get_type (void);
@@ -102,13 +102,10 @@ gboolean nm_manager_wimax_get_enabled (NMManager *manager);
void nm_manager_wimax_set_enabled (NMManager *manager, gboolean enabled);
gboolean nm_manager_wimax_hardware_get_enabled (NMManager *manager);
-NM_AVAILABLE_IN_1_10
gboolean nm_manager_connectivity_check_get_available (NMManager *manager);
-NM_AVAILABLE_IN_1_10
gboolean nm_manager_connectivity_check_get_enabled (NMManager *manager);
-NM_AVAILABLE_IN_1_10
void nm_manager_connectivity_check_set_enabled (NMManager *manager,
gboolean enabled);
@@ -140,7 +137,6 @@ NMConnectivityState nm_manager_check_connectivity_finish (NMManager *manager,
/* Devices */
const GPtrArray *nm_manager_get_devices (NMManager *manager);
-NM_AVAILABLE_IN_1_2
const GPtrArray *nm_manager_get_all_devices(NMManager *manager);
NMDevice *nm_manager_get_device_by_path (NMManager *manager, const char *object_path);
NMDevice *nm_manager_get_device_by_iface (NMManager *manager, const char *iface);
@@ -215,6 +211,4 @@ GHashTable *nm_manager_checkpoint_rollback_finish (NMManager *manager,
GAsyncResult *result,
GError **error);
-G_END_DECLS
-
#endif /* __NM_MANAGER_H__ */
diff --git a/libnm/nm-object-private.h b/libnm/nm-object-private.h
index 8c2f3a9cf4..1f6d54d324 100644
--- a/libnm/nm-object-private.h
+++ b/libnm/nm-object-private.h
@@ -21,6 +21,10 @@
#ifndef __NM_OBJECT_PRIVATE_H__
#define __NM_OBJECT_PRIVATE_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-object.h"
typedef gboolean (*PropertyMarshalFunc) (NMObject *, GParamSpec *, GVariant *, gpointer);
diff --git a/libnm/nm-remote-connection-private.h b/libnm/nm-remote-connection-private.h
index e3f35428cd..5ff282f4ba 100644
--- a/libnm/nm-remote-connection-private.h
+++ b/libnm/nm-remote-connection-private.h
@@ -21,6 +21,10 @@
#ifndef __NM_REMOTE_CONNECTION_PRIVATE_H__
#define __NM_REMOTE_CONNECTION_PRIVATE_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#define NM_REMOTE_CONNECTION_INIT_RESULT "init-result"
typedef enum {
diff --git a/libnm/nm-remote-settings.h b/libnm/nm-remote-settings.h
index 06d3ac0a39..ee0e0f225a 100644
--- a/libnm/nm-remote-settings.h
+++ b/libnm/nm-remote-settings.h
@@ -22,9 +22,11 @@
#ifndef __NM_REMOTE_SETTINGS_H__
#define __NM_REMOTE_SETTINGS_H__
-#include "nm-object.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-object.h"
#define NM_TYPE_REMOTE_SETTINGS (nm_remote_settings_get_type ())
#define NM_REMOTE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettings))
@@ -53,14 +55,10 @@ struct _NMRemoteSettings {
struct _NMRemoteSettingsClass {
NMObjectClass parent;
- /* Signals */
void (*connection_added) (NMRemoteSettings *settings,
NMRemoteConnection *connection);
void (*connection_removed) (NMRemoteSettings *settings,
NMRemoteConnection *connection);
-
- /*< private >*/
- gpointer padding[8];
};
GType nm_remote_settings_get_type (void);
@@ -125,6 +123,4 @@ gboolean nm_remote_settings_save_hostname_finish (NMRemoteSettings *settings,
GAsyncResult *result,
GError **error);
-G_END_DECLS
-
#endif /* __NM_REMOTE_SETTINGS_H__ */
diff --git a/libnm/tests/meson.build b/libnm/tests/meson.build
index fa7470f980..1955707ae1 100644
--- a/libnm/tests/meson.build
+++ b/libnm/tests/meson.build
@@ -18,7 +18,8 @@ deps = [
]
cflags = [
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB',
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM',
'-DTEST_NM_SERVICE="@0@"'.format(join_paths(meson.source_root(), 'tools', 'test-networkmanager-service.py'))
]
@@ -47,5 +48,6 @@ libnm_vpn_plugin_utils_test = static_library(
'nm-vpn-plugin-utils-test',
sources: shared_vpn_plugin_utils + [libnm_enum[1]],
include_directories: incs,
- dependencies: glib_dep
+ dependencies: glib_dep,
+ c_args: cflags,
)