This repository has been archived by the owner on Nov 17, 2020. It is now read-only.
forked from mypaint/mypaint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConscript
166 lines (134 loc) · 5.16 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import os, sys
import time
from os.path import join, basename
from subprocess import check_output
# Pre-fight checks
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 = 0o22
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 CheckPKGConfig(context, version):
context.Message( 'Checking for pkg-config... ' )
ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
context.Result( ret )
return ret
def CheckPKG(context, name):
context.Message( 'Checking for %s... ' % name )
ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
context.Result( ret )
return ret
# Generate a config.py file with build data.
def create_config_py(env):
mypaint_brushdir = check_output(['pkg-config', '--variable=brushdir', 'mypaint-brushes'])
mypaint_brushdir = mypaint_brushdir.strip()
config_info = {
'@MYPAINT_BRUSHDIR@': mypaint_brushdir,
}
config_file = env.Substfile('config.py', 'config.py.in',
SUBST_DICT=config_info)
install_perms(env, '$prefix/share/mypaint', config_file)
return config_file
def burn_versions(env, target, source):
"""Pseudo-builder: bakes version info into the target Python script.
This also burns in a suitable #! line for "python_binary".
"""
def _burn_versions(target, source, env):
sys.path.insert(0, ".")
import lib.meta
relinfo_script = lib.meta._get_release_info_script(gitprefix="git")
header = "\n".join([
"#!/usr/bin/env {python_binary}",
"#",
"# ***DO NOT EDIT THIS FILE***: edit {source} instead.",
"#",
"# Auto-generated version info:",
"{relinfo_script}",
]).format(
python_binary = env['python_binary'],
relinfo_script = relinfo_script,
source = source[0],
)
with open(unicode(target[0]), 'w') as output:
output.write(header)
with open(unicode(source[0])) as input:
output.write(input.read())
c = env.Command(target, source, [
_burn_versions,
Chmod(target, 0o755),
])
d = env.Depends(target, env.Value(env["python_binary"]))
# But don't depend on the git output:
# users often run "scons prefix=/foo install" to install
# after invoking "scons prefix=foo" to build.
# In this case, we don't want git updating its index,
# or scons to update any files.
return [c, d]
env.AddMethod(burn_versions, "BurnVersions")
## Build-time customization
# User-facing executable Python code
# MyPaint app
env.BurnVersions('mypaint', 'mypaint.py')
# Thumbnailer script and .thumbnailer
# Only build or install on platforms where we might expect to find
# GNOME or Cinnamon.
if os.name == "posix":
env.BurnVersions(
'desktop/mypaint-ora-thumbnailer',
'desktop/mypaint-ora-thumbnailer.py',
)
install_perms(env,
'$prefix/bin',
'desktop/mypaint-ora-thumbnailer',
perms=0o755,
)
install_perms(env,
'$prefix/share/thumbnailers',
'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'))
## Configuration
conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
'CheckPKG' : CheckPKG })
if not conf.CheckPKGConfig('0.4.0'):
# At least 0.4.0 is needed for option --variable.
# Probably an even more recent version is preferred though.
print 'pkg-config >= 0.4.0 not found.'
Exit(1)
if not conf.CheckPKG('mypaint-brushes >= 1.1'):
print 'mypaint-brushes >= 1.1 not found.'
Exit(1)
create_config_py(env)
## 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/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=0o755)
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