Skip to content

Commit

Permalink
Merge pull request projecthamster#565 from ederag/packagers-skip-options
Browse files Browse the repository at this point in the history
Packagers skip options
  • Loading branch information
ederag authored Feb 18, 2020
2 parents f5b067f + 27a54ba commit d9b2a55
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 86 deletions.
60 changes: 60 additions & 0 deletions data/wscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This file is meant to be included in the root wscript,
# through the recurse("data") command.
# An advantage of keeping it there
# instead of blending it in the root wscript build()
# is that the files are looked for in the same folder
# (no need to prepend data/ everywhere)

import os

from waflib import Logs


def build(ctx):
if not ctx.env.skip_gsettings:
ctx(features='glib2',
settings_schema_files=['org.gnome.hamster.gschema.xml'])

ctx.install_files('${DATADIR}/metainfo', 'org.gnome.Hamster.GUI.metainfo.xml')

filename = "org.gnome.Hamster.GUI.desktop"
ctx(features = "subst",
source= "%s.in" % filename,
target= "%s" % filename,
dict = ctx.env,
install_path = "${DATADIR}/applications"
)

start_dir = ctx.path.find_dir('.')

# glade builder files
ctx.install_files('${DATADIR}/hamster', start_dir.ant_glob('*.ui'))
# default files
ctx.install_files('${DATADIR}/hamster', 'hamster.db')
ctx.install_files('${DATADIR}/hamster', 'report_template.html')

# icons
ctx.install_files('${DATADIR}/hamster/art', start_dir.ant_glob('art/*.png'))
ctx.install_files('${DATADIR}/icons/hicolor/16x16/apps', 'art/16x16/org.gnome.Hamster.GUI.png')
ctx.install_files('${DATADIR}/icons/hicolor/22x22/apps', 'art/22x22/org.gnome.Hamster.GUI.png')
ctx.install_files('${DATADIR}/icons/hicolor/24x24/apps', 'art/24x24/org.gnome.Hamster.GUI.png')
ctx.install_files('${DATADIR}/icons/hicolor/32x32/apps', 'art/32x32/org.gnome.Hamster.GUI.png')
ctx.install_files('${DATADIR}/icons/hicolor/48x48/apps', 'art/scalable/org.gnome.Hamster.GUI.png')
ctx.install_files('${DATADIR}/icons/hicolor/scalable/apps','art/scalable/org.gnome.Hamster.GUI.svg')

if not ctx.env.skip_icon_cache_update:
ctx.add_post_fun(update_icon_cache)


# icon cache update
def update_icon_cache(ctx):
"""Update the gtk icon cache."""
if ctx.cmd == "install":
# adapted from the previous waf gnome.py
icon_dir = os.path.join(ctx.env.DATADIR, 'icons/hicolor')
cmd = 'gtk-update-icon-cache -q -f -t {}'.format(icon_dir)
err = ctx.exec_command(cmd)
if err:
Logs.warn('The following command failed:\n{}'.format(cmd))
else:
Logs.pprint('YELLOW', 'Successfully updated GTK icon cache')
25 changes: 0 additions & 25 deletions data/wscript_build

This file was deleted.

127 changes: 66 additions & 61 deletions wscript
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# -*- python -*-

# slight code duplication with hamster/__init__.py, but this is finally cleaner.

from subprocess import getstatusoutput

from waflib import Utils


# slight code duplication with hamster/__init__.py, but this is finally cleaner.
rc, output = getstatusoutput("git describe --tags --always --dirty=+")
VERSION = "3.0-beta" if rc else output

Expand All @@ -10,95 +15,95 @@ APPNAME = 'hamster'
top = '.'
out = 'build'

import os
from waflib import Logs, Utils


def configure(conf):
conf.load('gnu_dirs') # for DATADIR
conf.load('glib2') # for GSettings support
conf.load('python')
conf.check_python_version(minver=(3,4,0))

conf.load('intltool')

conf.env.ENABLE_NLS = 1
conf.env.HAVE_BIND_TEXTDOMAIN_CODESET = 1

conf.env.VERSION = VERSION
conf.env.GETTEXT_PACKAGE = "hamster"
conf.env.PACKAGE = "hamster"

conf.recurse("help")


def options(opt):
opt.load('gnu_dirs')
def options(ctx):
ctx.load('gnu_dirs')

# the waf default value is /usr/local, which causes issues (e.g. #309)
# opt.parser.set_defaults(prefix='/usr') did not update the help string,
# ctx.parser.set_defaults(prefix='/usr') did not update the help string,
# hence need to replace the whole option
opt.parser.remove_option('--prefix')
ctx.parser.remove_option('--prefix')
default_prefix = '/usr'
opt.add_option('--prefix', dest='prefix', default=default_prefix,

ctx.add_option('--prefix', dest='prefix', default=default_prefix,
help='installation prefix [default: {}]'.format(default_prefix))


def build(bld):
bld.install_as('${LIBEXECDIR}/hamster/hamster-service', "src/hamster-service.py", chmod=Utils.O755)
bld.install_as('${LIBEXECDIR}/hamster/hamster-windows-service', "src/hamster-windows-service.py", chmod=Utils.O755)
bld.install_as('${BINDIR}/hamster', "src/hamster-cli.py", chmod=Utils.O755)


bld.install_files('${PREFIX}/share/bash-completion/completions',

ctx.add_option('--skip-gsettings', dest='skip_gsettings', action='store_true',
help='skip gsettings schemas build and installation (for packagers)')

ctx.add_option('--skip-icon-cache-update', dest='skip_icon_cache_update', action='store_true',
help='skip icon cache update (for packagers)')


def configure(ctx):
ctx.load('gnu_dirs') # for DATADIR

if not ctx.options.skip_gsettings:
ctx.load('glib2') # for GSettings support

ctx.load('python')
ctx.check_python_version(minver=(3,4,0))

ctx.load('intltool')

ctx.env.ENABLE_NLS = 1
ctx.env.HAVE_BIND_TEXTDOMAIN_CODESET = 1

ctx.env.VERSION = VERSION
ctx.env.GETTEXT_PACKAGE = "hamster"
ctx.env.PACKAGE = "hamster"

ctx.recurse("help")

# options are tied to a specific ./waf invocation (one terminal line),
# and woud have to be given again at any other ./waf invocation
# that is trouble when one wants to ./waf uninstall much later;
# it can be hard to remember the exact options used at the install step.
# So from now on, options have to be given at the configure step only.
# copy the options to the persistent env:
for name in ('prefix', 'skip_gsettings', 'skip_icon_cache_update'):
value = getattr(ctx.options, name)
setattr(ctx.env, name, value)


def build(ctx):
ctx.install_as('${LIBEXECDIR}/hamster/hamster-service', "src/hamster-service.py", chmod=Utils.O755)
ctx.install_as('${LIBEXECDIR}/hamster/hamster-windows-service', "src/hamster-windows-service.py", chmod=Utils.O755)
ctx.install_as('${BINDIR}/hamster', "src/hamster-cli.py", chmod=Utils.O755)


ctx.install_files('${PREFIX}/share/bash-completion/completions',
'src/hamster.bash')


bld(features='py',
source=bld.path.ant_glob('src/hamster/**/*.py'),
ctx(features='py',
source=ctx.path.ant_glob('src/hamster/**/*.py'),
install_from='src')

# set correct flags in defs.py
bld(features="subst",
ctx(features="subst",
source="src/hamster/defs.py.in",
target="src/hamster/defs.py",
install_path="${PYTHONDIR}/hamster"
)

bld(features="subst",
ctx(features="subst",
source= "org.gnome.Hamster.service.in",
target= "org.gnome.Hamster.service",
install_path="${DATADIR}/dbus-1/services",
)

bld(features="subst",
ctx(features="subst",
source= "org.gnome.Hamster.GUI.service.in",
target= "org.gnome.Hamster.GUI.service",
install_path="${DATADIR}/dbus-1/services",
)

bld(features="subst",
ctx(features="subst",
source= "org.gnome.Hamster.WindowServer.service.in",
target= "org.gnome.Hamster.WindowServer.service",
install_path="${DATADIR}/dbus-1/services",
)

bld.recurse("po data help")

bld(features='glib2',
settings_schema_files = ['data/org.gnome.hamster.gschema.xml'])

def update_icon_cache(ctx):
"""Update the gtk icon cache."""
if ctx.cmd == "install":
# adapted from the previous waf gnome.py
icon_dir = os.path.join(ctx.env.DATADIR, 'icons/hicolor')
cmd = 'gtk-update-icon-cache -q -f -t {}'.format(icon_dir)
err = ctx.exec_command(cmd)
if err:
Logs.warn('The following command failed:\n{}'.format(cmd))
else:
Logs.pprint('YELLOW', 'Successfully updated GTK icon cache')


bld.add_post_fun(update_icon_cache)
# look for wscript into further directories
ctx.recurse("po data help")

0 comments on commit d9b2a55

Please sign in to comment.