build: use a common.sh file for common operations
[ugit.git] / wscript
bloba1d2033a65f5c1edea854c9444f0433ecda6ac1a
1 #!/usr/bin/env python
2 import os
3 import sys
4 import glob
5 import Params
6 import Common
7 from os.path import join
8 from distutils.sysconfig import get_python_version
10 # Release versioning
11 def get_version():
12 """Runs version.sh and returns the output."""
13 cmd = join(os.getcwd(), 'scripts', 'version.sh')
14 pipe = os.popen(cmd)
15 version = pipe.read()
16 pipe.close()
17 return version.strip()
19 #############################################################################
20 # Mandatory variables
21 APPNAME = 'ugit'
22 VERSION = get_version()
24 srcdir = '.'
25 blddir = 'obj'
27 #############################################################################
28 # Options
29 def set_options(opt):
30 opt.tool_options('python')
31 opt.tool_options('pyuic4', 'build')
32 pass
34 #############################################################################
35 # Configure
36 def configure(conf):
37 conf.check_tool('misc')
38 conf.check_tool('python')
39 conf.check_tool('pyuic4', 'build')
40 conf.check_tool('po2qm', 'build')
42 env = conf.env
43 prefix = env['PREFIX']
44 bindir = join(prefix, 'bin')
45 sitepackages = pymod(env)
46 modules = join(sitepackages, 'ugit')
47 views = join(modules, 'views')
48 controllers = join(modules, 'controllers')
49 icons = join(prefix, 'share', 'ugit', 'icons')
51 env['UGIT_BINDIR'] = bindir
52 env['UGIT_MODULES'] = modules
53 env['UGIT_VIEWS'] = views
54 env['UGIT_CONTROLLERS'] = controllers
55 env['UGIT_ICONS'] = icons
58 #############################################################################
59 # Build
60 def build(bld):
61 bld.add_subdirs('scripts ui ugit')
63 qm = bld.create_obj('po2qm')
64 qm.find_sources_in_dirs('po')
66 for icon in glob.glob('icons/*.png'):
67 Common.install_files('UGIT_ICONS', '', icon)
69 #############################################################################
70 # Other
71 def pymod(env):
72 """Returns a lib/python2.x/site-packages path relative to prefix"""
73 python_api = os.path.basename(env['PYTHON'])
74 if python_api == 'python':
75 python_api += get_python_version()
76 return join(env['PREFIX'], 'lib', python_api, 'site-packages')