11# -*- python -*-
22
3- # slight code duplication with hamster/__init__.py, but this is finally cleaner.
3+
44from subprocess import getstatusoutput
5+
6+ from waflib import Utils
7+
8+
9+ # slight code duplication with hamster/__init__.py, but this is finally cleaner.
510rc , output = getstatusoutput ("git describe --tags --always --dirty=+" )
611VERSION = "3.0-beta" if rc else output
712
@@ -10,95 +15,95 @@ APPNAME = 'hamster'
1015top = '.'
1116out = '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