forked from mypaint/mypaint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConscript
108 lines (81 loc) · 3.45 KB
/
SConscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import os, sys
import time
from os.path import join, basename
from subprocess import check_output
# Pre-fight checks
if not os.path.exists('brushlib/SConscript'):
print >>sys.stderr, """
----------------------------------------------------------------------
Missing submodule "brushlib"
Please run "git submodule update --init" to create it. See the README
for more information.
----------------------------------------------------------------------
"""
sys.exit(2)
Import('env', 'install_perms', 'install_tree')
# Clone the environment to not affect the common one
env = env.Clone()
mypaintlib = SConscript('lib/SConscript')
languages = SConscript('po/SConscript')
try:
new_umask = 022
old_umask = os.umask(new_umask)
print "set umask to 0%03o (was 0%03o)" % (new_umask, old_umask)
except OSError:
# Systems like Win32...
pass
def burn_versions(target, source, env):
"""Burn versions into the generated Python target."""
# Make sure we run the python version that we built the extension
# modules for:
script_header = '#!/usr/bin/env ' + env['python_binary'] + '\n'
script_header += 5*'#\n'
script_header += '# DO NOT EDIT - edit %s instead\n' % source[0]
script_header += 5*'#\n'
script_header += "\n\n"
script_header += "# Auto-generated version info\n"
sys.path.append(".")
import lib.meta
script_header += lib.meta._get_release_info_script(gitprefix="git")
script_header += "\n\n"
script_header += open(str(source[0])).read()
f = open(str(target[0]), 'w')
f.write(script_header)
f.close()
## Build-time customization
# User-facing executable Python code
# MyPaint app
env.Command('mypaint', 'mypaint.py', [burn_versions, Chmod('$TARGET', 0755)])
AlwaysBuild('mypaint') # especially if the "python_binary" option was changed
# Thumbnailer script
env.Command('desktop/mypaint-ora-thumbnailer', 'desktop/mypaint-ora-thumbnailer.py', [burn_versions, Chmod('$TARGET', 0755)])
AlwaysBuild('desktop/mypaint-ora-thumbnailer')
## Additional cleanup
env.Clean('.', Glob('*.pyc'))
env.Clean('.', Glob('gui/*.pyc'))
env.Clean('.', Glob('gui/colors/*.pyc'))
env.Clean('.', Glob('lib/*.pyc'))
env.Clean('.', Glob('lib/layer/*.pyc'))
## Installation
# Painting resources
install_tree(env, '$prefix/share/mypaint', 'backgrounds')
install_tree(env, '$prefix/share/mypaint', 'pixmaps')
install_tree(env, '$prefix/share/mypaint', 'palettes')
# Desktop resources and themeable internal icons
install_tree(env, '$prefix/share', 'desktop/icons')
install_perms(env, '$prefix/share/applications', 'desktop/mypaint.desktop')
install_perms(env, '$prefix/bin', 'desktop/mypaint-ora-thumbnailer', perms=0755)
install_perms(env, '$prefix/share/thumbnailers', 'desktop/mypaint-ora.thumbnailer')
install_perms(env, '$prefix/share/appdata', 'desktop/mypaint.appdata.xml')
# location for achitecture-dependent modules
install_perms(env, '$prefix/lib/mypaint', mypaintlib)
# Program and supporting UI XML
install_perms(env, '$prefix/bin', 'mypaint', perms=0755)
install_perms(env, '$prefix/share/mypaint/gui', Glob('gui/*.xml'))
install_perms(env, '$prefix/share/mypaint/gui', Glob('gui/*.glade'))
install_perms(env, "$prefix/share/mypaint/lib", Glob("lib/*.py"))
install_perms(env, "$prefix/share/mypaint/lib/layer", Glob("lib/layer/*.py"))
install_perms(env, "$prefix/share/mypaint/gui", Glob("gui/*.py"))
install_perms(env, "$prefix/share/mypaint/gui/colors", Glob("gui/colors/*.py"))
Return('mypaintlib')
# vim:syntax=python