Skip to content

Commit d9b2a55

Browse files
authored
Merge pull request #565 from ederag/packagers-skip-options
Packagers skip options
2 parents f5b067f + 27a54ba commit d9b2a55

3 files changed

Lines changed: 126 additions & 86 deletions

File tree

data/wscript

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This file is meant to be included in the root wscript,
2+
# through the recurse("data") command.
3+
# An advantage of keeping it there
4+
# instead of blending it in the root wscript build()
5+
# is that the files are looked for in the same folder
6+
# (no need to prepend data/ everywhere)
7+
8+
import os
9+
10+
from waflib import Logs
11+
12+
13+
def build(ctx):
14+
if not ctx.env.skip_gsettings:
15+
ctx(features='glib2',
16+
settings_schema_files=['org.gnome.hamster.gschema.xml'])
17+
18+
ctx.install_files('${DATADIR}/metainfo', 'org.gnome.Hamster.GUI.metainfo.xml')
19+
20+
filename = "org.gnome.Hamster.GUI.desktop"
21+
ctx(features = "subst",
22+
source= "%s.in" % filename,
23+
target= "%s" % filename,
24+
dict = ctx.env,
25+
install_path = "${DATADIR}/applications"
26+
)
27+
28+
start_dir = ctx.path.find_dir('.')
29+
30+
# glade builder files
31+
ctx.install_files('${DATADIR}/hamster', start_dir.ant_glob('*.ui'))
32+
# default files
33+
ctx.install_files('${DATADIR}/hamster', 'hamster.db')
34+
ctx.install_files('${DATADIR}/hamster', 'report_template.html')
35+
36+
# icons
37+
ctx.install_files('${DATADIR}/hamster/art', start_dir.ant_glob('art/*.png'))
38+
ctx.install_files('${DATADIR}/icons/hicolor/16x16/apps', 'art/16x16/org.gnome.Hamster.GUI.png')
39+
ctx.install_files('${DATADIR}/icons/hicolor/22x22/apps', 'art/22x22/org.gnome.Hamster.GUI.png')
40+
ctx.install_files('${DATADIR}/icons/hicolor/24x24/apps', 'art/24x24/org.gnome.Hamster.GUI.png')
41+
ctx.install_files('${DATADIR}/icons/hicolor/32x32/apps', 'art/32x32/org.gnome.Hamster.GUI.png')
42+
ctx.install_files('${DATADIR}/icons/hicolor/48x48/apps', 'art/scalable/org.gnome.Hamster.GUI.png')
43+
ctx.install_files('${DATADIR}/icons/hicolor/scalable/apps','art/scalable/org.gnome.Hamster.GUI.svg')
44+
45+
if not ctx.env.skip_icon_cache_update:
46+
ctx.add_post_fun(update_icon_cache)
47+
48+
49+
# icon cache update
50+
def update_icon_cache(ctx):
51+
"""Update the gtk icon cache."""
52+
if ctx.cmd == "install":
53+
# adapted from the previous waf gnome.py
54+
icon_dir = os.path.join(ctx.env.DATADIR, 'icons/hicolor')
55+
cmd = 'gtk-update-icon-cache -q -f -t {}'.format(icon_dir)
56+
err = ctx.exec_command(cmd)
57+
if err:
58+
Logs.warn('The following command failed:\n{}'.format(cmd))
59+
else:
60+
Logs.pprint('YELLOW', 'Successfully updated GTK icon cache')

data/wscript_build

Lines changed: 0 additions & 25 deletions
This file was deleted.

wscript

Lines changed: 66 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# -*- python -*-
22

3-
# slight code duplication with hamster/__init__.py, but this is finally cleaner.
3+
44
from subprocess import getstatusoutput
5+
6+
from waflib import Utils
7+
8+
9+
# slight code duplication with hamster/__init__.py, but this is finally cleaner.
510
rc, output = getstatusoutput("git describe --tags --always --dirty=+")
611
VERSION = "3.0-beta" if rc else output
712

@@ -10,95 +15,95 @@ APPNAME = 'hamster'
1015
top = '.'
1116
out = 'build'
1217

13-
import os
14-
from waflib import Logs, Utils
15-
16-
17-
def configure(conf):
18-
conf.load('gnu_dirs') # for DATADIR
19-
conf.load('glib2') # for GSettings support
20-
conf.load('python')
21-
conf.check_python_version(minver=(3,4,0))
22-
23-
conf.load('intltool')
24-
25-
conf.env.ENABLE_NLS = 1
26-
conf.env.HAVE_BIND_TEXTDOMAIN_CODESET = 1
27-
28-
conf.env.VERSION = VERSION
29-
conf.env.GETTEXT_PACKAGE = "hamster"
30-
conf.env.PACKAGE = "hamster"
3118

32-
conf.recurse("help")
33-
34-
35-
def options(opt):
36-
opt.load('gnu_dirs')
19+
def options(ctx):
20+
ctx.load('gnu_dirs')
3721

3822
# the waf default value is /usr/local, which causes issues (e.g. #309)
39-
# opt.parser.set_defaults(prefix='/usr') did not update the help string,
23+
# ctx.parser.set_defaults(prefix='/usr') did not update the help string,
4024
# hence need to replace the whole option
41-
opt.parser.remove_option('--prefix')
25+
ctx.parser.remove_option('--prefix')
4226
default_prefix = '/usr'
43-
opt.add_option('--prefix', dest='prefix', default=default_prefix,
27+
28+
ctx.add_option('--prefix', dest='prefix', default=default_prefix,
4429
help='installation prefix [default: {}]'.format(default_prefix))
45-
46-
47-
def build(bld):
48-
bld.install_as('${LIBEXECDIR}/hamster/hamster-service', "src/hamster-service.py", chmod=Utils.O755)
49-
bld.install_as('${LIBEXECDIR}/hamster/hamster-windows-service', "src/hamster-windows-service.py", chmod=Utils.O755)
50-
bld.install_as('${BINDIR}/hamster', "src/hamster-cli.py", chmod=Utils.O755)
51-
52-
53-
bld.install_files('${PREFIX}/share/bash-completion/completions',
30+
31+
ctx.add_option('--skip-gsettings', dest='skip_gsettings', action='store_true',
32+
help='skip gsettings schemas build and installation (for packagers)')
33+
34+
ctx.add_option('--skip-icon-cache-update', dest='skip_icon_cache_update', action='store_true',
35+
help='skip icon cache update (for packagers)')
36+
37+
38+
def configure(ctx):
39+
ctx.load('gnu_dirs') # for DATADIR
40+
41+
if not ctx.options.skip_gsettings:
42+
ctx.load('glib2') # for GSettings support
43+
44+
ctx.load('python')
45+
ctx.check_python_version(minver=(3,4,0))
46+
47+
ctx.load('intltool')
48+
49+
ctx.env.ENABLE_NLS = 1
50+
ctx.env.HAVE_BIND_TEXTDOMAIN_CODESET = 1
51+
52+
ctx.env.VERSION = VERSION
53+
ctx.env.GETTEXT_PACKAGE = "hamster"
54+
ctx.env.PACKAGE = "hamster"
55+
56+
ctx.recurse("help")
57+
58+
# options are tied to a specific ./waf invocation (one terminal line),
59+
# and woud have to be given again at any other ./waf invocation
60+
# that is trouble when one wants to ./waf uninstall much later;
61+
# it can be hard to remember the exact options used at the install step.
62+
# So from now on, options have to be given at the configure step only.
63+
# copy the options to the persistent env:
64+
for name in ('prefix', 'skip_gsettings', 'skip_icon_cache_update'):
65+
value = getattr(ctx.options, name)
66+
setattr(ctx.env, name, value)
67+
68+
69+
def build(ctx):
70+
ctx.install_as('${LIBEXECDIR}/hamster/hamster-service', "src/hamster-service.py", chmod=Utils.O755)
71+
ctx.install_as('${LIBEXECDIR}/hamster/hamster-windows-service', "src/hamster-windows-service.py", chmod=Utils.O755)
72+
ctx.install_as('${BINDIR}/hamster', "src/hamster-cli.py", chmod=Utils.O755)
73+
74+
75+
ctx.install_files('${PREFIX}/share/bash-completion/completions',
5476
'src/hamster.bash')
5577

5678

57-
bld(features='py',
58-
source=bld.path.ant_glob('src/hamster/**/*.py'),
79+
ctx(features='py',
80+
source=ctx.path.ant_glob('src/hamster/**/*.py'),
5981
install_from='src')
6082

6183
# set correct flags in defs.py
62-
bld(features="subst",
84+
ctx(features="subst",
6385
source="src/hamster/defs.py.in",
6486
target="src/hamster/defs.py",
6587
install_path="${PYTHONDIR}/hamster"
6688
)
6789

68-
bld(features="subst",
90+
ctx(features="subst",
6991
source= "org.gnome.Hamster.service.in",
7092
target= "org.gnome.Hamster.service",
7193
install_path="${DATADIR}/dbus-1/services",
7294
)
7395

74-
bld(features="subst",
96+
ctx(features="subst",
7597
source= "org.gnome.Hamster.GUI.service.in",
7698
target= "org.gnome.Hamster.GUI.service",
7799
install_path="${DATADIR}/dbus-1/services",
78100
)
79101

80-
bld(features="subst",
102+
ctx(features="subst",
81103
source= "org.gnome.Hamster.WindowServer.service.in",
82104
target= "org.gnome.Hamster.WindowServer.service",
83105
install_path="${DATADIR}/dbus-1/services",
84106
)
85107

86-
bld.recurse("po data help")
87-
88-
bld(features='glib2',
89-
settings_schema_files = ['data/org.gnome.hamster.gschema.xml'])
90-
91-
def update_icon_cache(ctx):
92-
"""Update the gtk icon cache."""
93-
if ctx.cmd == "install":
94-
# adapted from the previous waf gnome.py
95-
icon_dir = os.path.join(ctx.env.DATADIR, 'icons/hicolor')
96-
cmd = 'gtk-update-icon-cache -q -f -t {}'.format(icon_dir)
97-
err = ctx.exec_command(cmd)
98-
if err:
99-
Logs.warn('The following command failed:\n{}'.format(cmd))
100-
else:
101-
Logs.pprint('YELLOW', 'Successfully updated GTK icon cache')
102-
103-
104-
bld.add_post_fun(update_icon_cache)
108+
# look for wscript into further directories
109+
ctx.recurse("po data help")

0 commit comments

Comments
 (0)