Skip to content

Commit

Permalink
Restructure directories and build
Browse files Browse the repository at this point in the history
This moves a all source code into separate subdirs per binary. The
helper and the generic stuff goes into lib/ which is then used by all
the others. For now this is a completely internal library, but at
some point we will probably clean it up and expose some subset.

Also, we move the dbus proxy to libexecdir.
  • Loading branch information
alexlarsson committed Jul 10, 2015
1 parent ef223b6 commit 302f88e
Show file tree
Hide file tree
Showing 39 changed files with 153 additions and 125 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ xdg-app-systemd-dbus.[ch]
xdg-app-resources.[ch]
xdg-dbus-proxy
*.service
xdg-app.env
xdg-app.sh

142 changes: 20 additions & 122 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
NULL =

bin_PROGRAMS = $(NULL)
libexec_PROGRAMS = $(NULL)
DISTCLEANFILES= $(NULL)

if BUILD_DOCUMENTATION
SUBDIRS = doc
endif
Expand All @@ -11,6 +15,10 @@ AM_CPPFLAGS = \
-DXDG_APP_TRIGGERDIR=\"$(pkgdatadir)/triggers\" \
-DSYSTEM_FONTS_DIR=\"$(SYSTEM_FONTS_DIR)\" \
-DHELPER=\"$(bindir)/xdg-app-helper\" \
-DDBUSPROXY=\"$(libexecdir)/xdg-dbus-proxy\" \
-I$(srcdir)/libglnx \
-I$(srcdir)/lib \
-I$(builddir)/lib \
$(NULL)

triggersdir = $(pkgdatadir)/triggers
Expand All @@ -20,130 +28,18 @@ dist_triggers_SCRIPTS = \
triggers/desktop-database.trigger \
$(NULL)

bin_PROGRAMS = \
xdg-app-helper \
xdg-dbus-proxy \
xdg-app \
$(NULL)

libexec_PROGRAMS = \
xdg-app-session-helper \
$(NULL)

EXTRA_DIST = xdg-app.gresource.xml xdg-app-dbus-interfaces.xml org.freedesktop.systemd1.xml
EXTRA_DIST = data/xdg-app-dbus-interfaces.xml data/org.freedesktop.systemd1.xml

noinst_LTLIBRARIES = libglnx.la
libglnx_srcpath := $(srcdir)/libglnx
libglnx_cflags := $(BASE_CFLAGS) "-I$(libglnx_srcpath)"
libglnx_libs := $(BASE_LIBS)
include libglnx/Makefile-libglnx.am.inc

noinst_LTLIBRARIES = libglnx.la

xdg_app_helper_SOURCES = xdg-app-helper.c
xdg_app_helper_LDADD = $(LIBSECCOMP_LIBS)
xdg_app_helper_CFLAGS = $(LIBSECCOMP_CFLAGS)

dbus_built_sources = xdg-app-dbus.c xdg-app-dbus.h
systemd_dbus_built_sources = xdg-app-systemd-dbus.c xdg-app-systemd-dbus.h
BUILT_SOURCES = $(dbus_built_sources) $(systemd_dbus_built_sources)

$(dbus_built_sources) : Makefile.am xdg-app-dbus-interfaces.xml
$(AM_V_GEN) $(GDBUS_CODEGEN) \
--interface-prefix org.freedesktop.XdgApp. \
--c-namespace XdgApp \
--generate-c-code xdg-app-dbus \
$(srcdir)/xdg-app-dbus-interfaces.xml \
$(NULL)

$(systemd_dbus_built_sources) : Makefile.am org.freedesktop.systemd1.xml
$(AM_V_GEN) $(GDBUS_CODEGEN) \
--interface-prefix org.freedesktop.systemd1. \
--c-namespace Systemd \
--generate-c-code xdg-app-systemd-dbus \
$(srcdir)/org.freedesktop.systemd1.xml \
$(NULL)

resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/xdg-app.gresource.xml)

xdg-app-resources.h: xdg-app.gresource.xml
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-header

xdg-app-resources.c: xdg-app.gresource.xml $(resource_files)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-source

# D-BUS service file
%.service: %.service.in config.log
$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@

servicedir = $(DBUS_SERVICE_DIR)
service_in_files = xdg-app-session.service.in
service_DATA = xdg-app-session.service

EXTRA_DIST += $(service_in_files)

xdg_app_session_helper_SOURCES = \
xdg-app-session-helper.c \
$(dbus_built_sources) \
xdg-app-resources.h \
xdg-app-resources.c \
$(NULL)

xdg_app_session_helper_LDADD = $(BASE_LIBS)
xdg_app_session_helper_CFLAGS = $(BASE_CFLAGS)

xdg_app_SOURCES = \
xdg-app-main.c \
xdg-app-builtins.h \
xdg-app-builtins-add-remote.c \
xdg-app-builtins-delete-remote.c \
xdg-app-builtins-list-remotes.c \
xdg-app-builtins-repo-contents.c \
xdg-app-builtins-install.c \
xdg-app-builtins-make-current.c \
xdg-app-builtins-update.c \
xdg-app-builtins-uninstall.c \
xdg-app-builtins-list.c \
xdg-app-builtins-run.c \
xdg-app-builtins-build-init.c \
xdg-app-builtins-build.c \
xdg-app-builtins-build-finish.c \
xdg-app-builtins-build-export.c \
xdg-app-builtins-repo-update.c \
xdg-app-dir.c \
xdg-app-dir.h \
xdg-app-run.c \
xdg-app-run.h \
xdg-app-utils.h \
xdg-app-utils.c \
$(systemd_dbus_built_sources) \
$(dbus_built_sources) \
$(NULL)

xdg_app_LDADD = $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) libglnx.la
xdg_app_CFLAGS = $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(SOUP_CFLAGS) -I$(srcdir)/libglnx

xdg_dbus_proxy_SOURCES = \
xdg-app-proxy.c \
xdg-app-proxy.h \
dbus-proxy.c \
$(NULL)

xdg_dbus_proxy_LDADD = $(BASE_LIBS) libglnx.la
xdg_dbus_proxy_CFLAGS = $(BASE_CFLAGS) -I$(srcdir)/libglnx

install-exec-hook:
if DISABLE_USERNS
if PRIV_MODE_SETUID
$(SUDO_BIN) chown root $(DESTDIR)$(bindir)/xdg-app-helper
$(SUDO_BIN) chmod u+s $(DESTDIR)$(bindir)/xdg-app-helper
else
if PRIV_MODE_FILECAPS
$(SUDO_BIN) setcap cap_sys_admin+ep $(DESTDIR)$(bindir)/xdg-app-helper
endif
endif
endif
include lib/Makefile.am.inc
include app/Makefile.am.inc
include session-helper/Makefile.am.inc
include dbus-proxy/Makefile.am.inc

completiondir = $(datadir)/bash-completion/completions
completion_DATA = completion/xdg-app
Expand All @@ -152,15 +48,17 @@ EXTRA_DIST += $(completion_DATA)
profiledir = $(sysconfdir)/profile.d
profile_DATA = xdg-app.sh
EXTRA_DIST += profile/xdg-app.sh.in

envdir = $(datadir)/gdm/env.d
env_DATA = xdg-app.env
EXTRA_DIST += env.d/xdg-app.env.in
DISTCLEANFILES += xdg-app.sh

xdg-app.sh: profile/xdg-app.sh.in
$(AM_V_GEN) $(SED) -e "s|\@localstatedir\@|$(localstatedir)|" \
-e "s|\@sysconfdir\@|$(sysconfdir)|" $< > $@

envdir = $(datadir)/gdm/env.d
env_DATA = xdg-app.env
EXTRA_DIST += env.d/xdg-app.env.in
DISTCLEANFILES += xdg-app.env

xdg-app.env: env.d/xdg-app.env.in
$(AM_V_GEN) $(SED) -e "s|\@localstatedir\@|$(localstatedir)|" \
-e "s|\@sysconfdir\@|$(sysconfdir)|" $< > $@
27 changes: 27 additions & 0 deletions app/Makefile.am.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
bin_PROGRAMS += \
xdg-app \
$(NULL)

xdg_app_SOURCES = \
app/xdg-app-main.c \
app/xdg-app-builtins.h \
app/xdg-app-builtins-add-remote.c \
app/xdg-app-builtins-delete-remote.c \
app/xdg-app-builtins-list-remotes.c \
app/xdg-app-builtins-repo-contents.c \
app/xdg-app-builtins-install.c \
app/xdg-app-builtins-make-current.c \
app/xdg-app-builtins-update.c \
app/xdg-app-builtins-uninstall.c \
app/xdg-app-builtins-list.c \
app/xdg-app-builtins-run.c \
app/xdg-app-builtins-build-init.c \
app/xdg-app-builtins-build.c \
app/xdg-app-builtins-build-finish.c \
app/xdg-app-builtins-build-export.c \
app/xdg-app-builtins-repo-update.c \
$(NULL)

xdg_app_LDADD = $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) libglnx.la libxdgapp.la
xdg_app_CFLAGS = $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(SOUP_CFLAGS)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion xdg-app-builtins-run.c → app/xdg-app-builtins-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
goto out;
}

g_ptr_array_insert (dbus_proxy_argv, 0, g_strdup ("xdg-dbus-proxy"));
g_ptr_array_insert (dbus_proxy_argv, 0, g_strdup (DBUSPROXY));
g_ptr_array_insert (dbus_proxy_argv, 1, g_strdup_printf ("--fd=%d", sync_proxy_pipes[1]));

g_ptr_array_add (dbus_proxy_argv, NULL); /* NULL terminate */
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AC_DISABLE_STATIC
LT_PREREQ([2.2.6])
LT_INIT([disable-static])

AC_CONFIG_SRCDIR([xdg-app-helper.c])
AC_CONFIG_SRCDIR([lib/xdg-app-helper.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.11 no-define no-dist-gzip dist-xz tar-ustar foreign subdir-objects])
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions dbus-proxy/Makefile.am.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
libexec_PROGRAMS += \
xdg-dbus-proxy \
$(NULL)

xdg_dbus_proxy_SOURCES = \
dbus-proxy/xdg-app-proxy.c \
dbus-proxy/xdg-app-proxy.h \
dbus-proxy/dbus-proxy.c \
$(NULL)

xdg_dbus_proxy_LDADD = $(BASE_LIBS) libglnx.la
xdg_dbus_proxy_CFLAGS = $(BASE_CFLAGS) -I$(srcdir)/dbus-proxy
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions lib/Makefile.am.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
noinst_LTLIBRARIES += libxdgapp.la

dbus_built_sources = lib/xdg-app-dbus.c lib/xdg-app-dbus.h
systemd_dbus_built_sources = lib/xdg-app-systemd-dbus.c lib/xdg-app-systemd-dbus.h
BUILT_SOURCES = $(dbus_built_sources) $(systemd_dbus_built_sources)

$(dbus_built_sources) : data/xdg-app-dbus-interfaces.xml
$(AM_V_GEN) $(GDBUS_CODEGEN) \
--interface-prefix org.freedesktop.XdgApp. \
--c-namespace XdgApp \
--generate-c-code $(builddir)/lib/xdg-app-dbus \
$(srcdir)/data/xdg-app-dbus-interfaces.xml \
$(NULL)

$(systemd_dbus_built_sources) : data/org.freedesktop.systemd1.xml
$(AM_V_GEN) $(GDBUS_CODEGEN) \
--interface-prefix org.freedesktop.systemd1. \
--c-namespace Systemd \
--generate-c-code $(builddir)/lib/xdg-app-systemd-dbus \
$(srcdir)/data/org.freedesktop.systemd1.xml \
$(NULL)

libxdgapp_la_SOURCES = \
lib/xdg-app-dir.c \
lib/xdg-app-dir.h \
lib/xdg-app-run.c \
lib/xdg-app-run.h \
lib/xdg-app-utils.c \
lib/xdg-app-utils.h \
$(dbus_built_sources) \
$(systemd_dbus_built_sources) \
$(NULL)

libxdgapp_la_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(SOUP_CFLAGS) -I$(srcdir)/dbus-proxy
libxdgapp_la_LIBADD = libglnx.la $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS)

bin_PROGRAMS += \
xdg-app-helper \
$(NULL)

xdg_app_helper_SOURCES = lib/xdg-app-helper.c
xdg_app_helper_LDADD = $(LIBSECCOMP_LIBS)
xdg_app_helper_CFLAGS = $(LIBSECCOMP_CFLAGS)

install-exec-hook:
if DISABLE_USERNS
if PRIV_MODE_SETUID
$(SUDO_BIN) chown root $(DESTDIR)$(bindir)/xdg-app-helper
$(SUDO_BIN) chmod u+s $(DESTDIR)$(bindir)/xdg-app-helper
else
if PRIV_MODE_FILECAPS
$(SUDO_BIN) setcap cap_sys_admin+ep $(DESTDIR)$(bindir)/xdg-app-helper
endif
endif
endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions session-helper/Makefile.am.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/session-helper/xdg-app.gresource.xml)

libexec_PROGRAMS += \
xdg-app-session-helper \
$(NULL)

session-helper/xdg-app-resources.h: session-helper/xdg-app.gresource.xml
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-header

session-helper/xdg-app-resources.c: session-helper/xdg-app.gresource.xml $(resource_files)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-source

# D-BUS service file
%.service: %.service.in config.log
$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@

servicedir = $(DBUS_SERVICE_DIR)
service_in_files = session-helper/xdg-app-session.service.in
service_DATA = session-helper/xdg-app-session.service
DISTCLEANFILES += $(service_DATA)

EXTRA_DIST += session-helper/xdg-app.gresource.xml $(service_in_files)

xdg_app_session_helper_SOURCES = \
session-helper/xdg-app-session-helper.c \
session-helper/xdg-app-resources.h \
session-helper/xdg-app-resources.c \
$(NULL)

xdg_app_session_helper_LDADD = $(BASE_LIBS) libxdgapp.la
xdg_app_session_helper_CFLAGS = $(BASE_CFLAGS)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<gresources>
<gresource prefix='/org/freedesktop/XdgApp'>
<file>xdg-app-dbus-interfaces.xml</file>
<file alias="xdg-app-dbus-interfaces.xml">data/xdg-app-dbus-interfaces.xml</file>
</gresource>
</gresources>

0 comments on commit 302f88e

Please sign in to comment.