[gnome-weather] Build infrastructure: just give up
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-weather] Build infrastructure: just give up
- Date: Tue, 4 Feb 2014 20:11:29 +0000 (UTC)
commit 1cf714de05eb71e64408b6f8db4c223a8826ad9f
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Tue Feb 4 20:49:52 2014 +0100
Build infrastructure: just give up
I say it now, I give up. I tried everything to get a reasonable
environment for working with DBus activated apps, and the requirements
are always contrasting.
So I completely decoupled package.js from service/launcher. The
launcher is simply a shell script that execs the gapplication
tool from glib (much like the desktop file was already doing),
and the actual application is no longer a service. If you want it
to behave like one, you pass --gapplication-service (which is
a special flag interpreted by glib, we can't do local command
line handling in gjs).
This is pretty much the same as gnome-software does, except
the application is still namespaced and installed in libdir,
and the file in $bindir is a shim launcher.
Tests pass and so does coverage. The application can be launched
from the shell (nothing changes in that respect, because it
happens through DBus), and it can be launched from the
command line.
Only regression: gnome-weather --help and gnome-weather --version
no longer do what you would expect. Too bad. --help was useless
anyway, the only option in the list was --version, and we
have an about dialog (plus you should use package version, not
upstream version)
Makefile.am | 1 +
data/org.gnome.Weather.Application.service.in | 2 +-
src/Makefile.am | 22 +-----
src/gnome-weather | 2 +
src/gnome-weather.in | 6 --
src/main.js | 3 -
src/org.gnome.Weather.Application.in | 4 +-
src/package.js | 108 +------------------------
tests/Makefile.am | 7 +-
tests/testutil.py | 10 ++-
10 files changed, 27 insertions(+), 138 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 101238e..0be1a60 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,5 @@
ACLOCAL_AMFLAGS = -I m4 -I libgd ${ACLOCAL_FLAGS}
+DISTCHECK_CONFIGURE_FLAGS = --disable-dogtail
SUBDIRS = po data libgd src tests
diff --git a/data/org.gnome.Weather.Application.service.in b/data/org.gnome.Weather.Application.service.in
index 2f615d9..0b69597 100644
--- a/data/org.gnome.Weather.Application.service.in
+++ b/data/org.gnome.Weather.Application.service.in
@@ -1,3 +1,3 @@
[D-BUS Service]
Name= PACKAGE_NAME@
-Exec= pkgdatadir@/@PACKAGE_NAME@
\ No newline at end of file
+Exec= pkgdatadir@/@PACKAGE_NAME@ --gapplication-service
diff --git a/src/Makefile.am b/src/Makefile.am
index 52e0913..b79f942 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
NULL =
-nodist_bin_SCRIPTS = $(PACKAGE_TARNAME)
-nodist_pkgdata_SCRIPTS = $(PACKAGE_NAME)
+dist_bin_SCRIPTS = gnome-weather
+nodist_pkgdata_SCRIPTS = org.gnome.Weather.Application
resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies
$(srcdir)/$(PACKAGE_NAME).src.gresource.xml)
$(PACKAGE_NAME).src.gresource: $(PACKAGE_NAME).src.gresource.xml $(resource_files)
@@ -10,27 +10,13 @@ $(PACKAGE_NAME).src.gresource: $(PACKAGE_NAME).src.gresource.xml $(resource_file
resourcedir = $(pkgdatadir)
resource_DATA = $(PACKAGE_NAME).src.gresource
-EXTRA_SCRIPTS = org.gnome.Weather.Application gnome-weather
-
# Legacy, until we can depend on package.js provided by gjs
jsdir = $(pkgdatadir)
dist_js_DATA = package.js
-$(PACKAGE_TARNAME): $(PACKAGE_TARNAME).in
- $(AM_V_GEN) sed \
- -e "s|[ ]GJS@|$(GJS)|g" \
- -e "s|[ ]PACKAGE_NAME@|$(PACKAGE_NAME)|g" \
- -e "s|[ ]PACKAGE_VERSION@|$(PACKAGE_VERSION)|g" \
- -e "s|[ ]prefix@|$(prefix)|g" \
- -e "s|[ ]libdir@|$(libdir)|g" \
- -e "s|[ ]pkgdatadir@|$(pkgdatadir)|g" \
- $< > $@
- @chmod +x $@
-
-$(PACKAGE_NAME): $(PACKAGE_NAME).in
+org.gnome.Weather.Application: org.gnome.Weather.Application.in
$(AM_V_GEN) sed \
-e "s|[ ]GJS@|$(GJS)|g" \
- -e "s|[ ]PACKAGE_NAME@|$(PACKAGE_NAME)|g" \
-e "s|[ ]PACKAGE_VERSION@|$(PACKAGE_VERSION)|g" \
-e "s|[ ]prefix@|$(prefix)|g" \
-e "s|[ ]libdir@|$(libdir)|g" \
@@ -40,14 +26,12 @@ $(PACKAGE_NAME): $(PACKAGE_NAME).in
EXTRA_DIST = \
$(PACKAGE_NAME).in \
- $(PACKAGE_TARNAME).in \
$(PACKAGE_NAME).src.gresource.xml \
$(resource_files) \
$(NULL)
CLEANFILES = \
$(PACKAGE_NAME) \
- $(PACKAGE_TARNAME) \
$(PACKAGE_NAME).src.gresource \
$(NULL)
diff --git a/src/gnome-weather b/src/gnome-weather
new file mode 100755
index 0000000..487b5d5
--- /dev/null
+++ b/src/gnome-weather
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec gapplication launch org.gnome.Weather.Application
diff --git a/src/main.js b/src/main.js
index 2e43307..f0f0435 100644
--- a/src/main.js
+++ b/src/main.js
@@ -53,10 +53,7 @@ const Application = new Lang.Class({
_init: function() {
this.parent({ application_id: pkg.name,
- flags: pkg.appFlags,
inactivity_timeout: 60000 });
- if (this.flags & Gio.ApplicationFlags.IS_SERVICE)
- this.inactivity_timeout = 60000;
GLib.set_application_name(_("Weather"));
this._searchProvider = new SearchProvider.SearchProvider(this);
diff --git a/src/org.gnome.Weather.Application.in b/src/org.gnome.Weather.Application.in
index 11c4071..dc7b6bc 100644
--- a/src/org.gnome.Weather.Application.in
+++ b/src/org.gnome.Weather.Application.in
@@ -1,6 +1,6 @@
#! GJS@
imports.searchPath.push("@pkgdatadir@");
-imports.package.start({ name: "@PACKAGE_NAME@",
+imports.package.start({ name: "org.gnome.Weather.Application",
version: "@PACKAGE_VERSION@",
prefix: "@prefix@",
- libdir: "@libdir@" });
\ No newline at end of file
+ libdir: "@libdir@" });
diff --git a/src/package.js b/src/package.js
index 3ff427a..e8e50b0 100644
--- a/src/package.js
+++ b/src/package.js
@@ -33,7 +33,6 @@ const Gettext = imports.gettext;
/*< public >*/
var name;
var version;
-var appFlags;
var prefix;
var datadir;
var libdir;
@@ -44,7 +43,6 @@ var localedir;
/*< private >*/
let _base;
-let _requires;
function _runningFromSource() {
let fileName = System.programInvocationName;
@@ -100,11 +98,10 @@ function _makeNamePath(name) {
*
* As a side effect, init() calls GLib.set_prgname().
*/
-function init(params, fromLauncher) {
+function init(params) {
window.pkg = imports.package;
name = params.name;
version = params.version;
- appFlags = params.flags;
// Must call it first, because it can only be called
// once, and other library calls might have it as a
@@ -116,9 +113,6 @@ function init(params, fromLauncher) {
datadir = GLib.build_filenamev([prefix, 'share']);
let libpath, girpath;
- if (!fromLauncher)
- appFlags |= Gio.ApplicationFlags.IS_SERVICE;
-
if (_runningFromSource()) {
log('Running from source tree, using local files');
// Running from source directory
@@ -168,39 +162,10 @@ function init(params, fromLauncher) {
* You must define a main(ARGV) function inside a main.js
* module in moduledir.
*/
-function start(params, args, fromLauncher) {
- params.flags = params.flags || 0;
- args = args || ARGV;
- fromLauncher = !!fromLauncher;
- init(params, fromLauncher);
-
- return imports.main.main(args);
-}
-
-function _checkVersion(required, current) {
- if (required == '') {
- // No requirement
- return true;
- }
-
- // Major version must match, it's used for API
- // incompatible changes.
- // The rest just needs to be less or equal to
- // current. The code is generic, but gjs modules
- // should use only [major, minor]
- if (required[0] != current[0])
- return false;
-
- for (let i = 1; i < Math.min(current.length, required.length); i++) {
- if (required[i] > current[i])
- return false;
- if (required[i] < current[i])
- return true;
-
- // else they're equal, go on
- }
+function start(params) {
+ init(params);
- return true;
+ return imports.main.main([System.programInvocationName].concat(ARGV));
}
/**
@@ -214,8 +179,6 @@ function _checkVersion(required, current) {
* indicates any version.
*/
function require(libs) {
- _requires = libs;
-
for (let l in libs) {
let version = libs[l];
@@ -231,10 +194,6 @@ function require(libs) {
}
}
-function dumpRequires() {
- print(JSON.stringify(_requires));
-}
-
function initGettext() {
Gettext.bindtextdomain(name, localedir);
Gettext.textdomain(name);
@@ -262,62 +221,3 @@ function initSubmodule(name) {
// Running installed, submodule is in $(pkglibdir), nothing to do
}
}
-
-// Launcher support
-
-function _launcherUsage(flags) {
- print('Usage:');
-
- let name = GLib.path_get_basename(System.programInvocationName);
- if (flags & Gio.ApplicationFlags.HANDLES_OPEN)
- print(' ' + name + ' [OPTION...] [FILE...]\n');
- else
- print(' ' + name + ' [OPTION...]\n');
-
- print('Options:');
- print(' -h, --help Show this help message');
- print(' --version Show the application version');
-}
-
-function _parseLaunchArgs(args, params) {
- let newArgs = [];
-
- for (let i = 0; i < args.length; i++) {
- switch (args[i]) {
- case '--':
- newArgs.concat(args.slice(i));
- return newArgs;
-
- case '--help':
- case '-h':
- _launcherUsage(params.flags);
- System.exit(0);
- break;
-
- case '--version':
- print(params.name + ' ' + params.version);
- System.exit(0);
- break;
-
- default:
- newArgs.push(args[i]);
- }
- }
-
- return newArgs;
-}
-
-function launch(params) {
- params.flags = params.flags || 0;
- let args = _parseLaunchArgs(ARGV, params);
-
- if (_runningFromSource()) {
- return start(params, args, true);
- } else {
- params.flags |= Gio.ApplicationFlags.IS_LAUNCHER;
-
- let app = new Gio.Application({ application_id: params.name,
- flags: params.flags });
- return app.run(args);
- }
-}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6a959a2..fc2bb97 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,6 +3,8 @@ include $(top_srcdir)/glib-tap.mk
dogtail_tests = \
world_view.py
+TESTS_ENVIRONMENT += LC_ALL=C
+
if ENABLE_DOGTAIL
dist_test_scripts = $(dogtail_tests)
dist_test_data = testutil.py
@@ -11,9 +13,10 @@ CLEANFILES += *.pyc
if ENABLE_COVERAGE
lcov:
- ( cd $(abs_top_builddir) ; $(TEST_ENVIRONMENT) $(GJS) --coverage-output=$(abs_builddir) \
+ ( cd $(abs_top_builddir) ; $(TESTS_ENVIRONMENT) $(GJS) --coverage-output=$(abs_builddir) \
$(foreach source,$(wildcard $(abs_top_srcdir)/src/*.js),-C $(abs_top_srcdir)/src/$(notdir $(source)))
\
- $(abs_top_builddir)/src/org.gnome.Weather.Application ) & sleep 2 && $(MAKE) $(AM_MAKEFLAGS) check
+ $(abs_top_builddir)/src/org.gnome.Weather.Application --gapplication-service ) & \
+ sleep 2 && TESTUTIL_DONT_START=1 $(MAKE) $(AM_MAKEFLAGS) check
$(GENHTML) $(builddir)/coverage.lcov
clean-local:
diff --git a/tests/testutil.py b/tests/testutil.py
index 8c3d60f..2f6d347 100644
--- a/tests/testutil.py
+++ b/tests/testutil.py
@@ -6,6 +6,9 @@ from dogtail import utils
from dogtail.predicate import *
from dogtail.procedural import *
+import os, sys
+import subprocess
+
APPLICATION_ID = "org.gnome.Weather.Application"
_bus = None
@@ -38,7 +41,12 @@ def _do_bus_call(method, params):
-1, None)
def start():
- _do_bus_call("Activate", GLib.Variant('(a{sv})', ([],)))
+ builddir = os.environ.get('G_TEST_BUILDDIR', None)
+ if builddir and not 'TESTUTIL_DONT_START' in os.environ:
+ subprocess.Popen([os.path.join(builddir, '..', 'src', APPLICATION_ID)],
+ cwd=os.path.join(builddir, '..'))
+ else:
+ _do_bus_call("Activate", GLib.Variant('(a{sv})', ([],)))
utils.doDelay(3)
app = tree.root.application(APPLICATION_ID)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]