-
Notifications
You must be signed in to change notification settings - Fork 14
/
SConstruct
229 lines (197 loc) · 8.79 KB
/
SConstruct
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Setup
import os
import json
env = Environment(ENV = os.environ)
try:
env.Tool('config', toolpath = [os.environ.get('CBANG_HOME')])
except Exception as e:
raise Exception('CBANG_HOME not set?\n' + str(e))
env.CBLoadTools('compiler cbang dist build_info packager resources osx')
# Options
env.CBAddVariables(
BoolVariable('wrap_glibc', 'Wrap some glibc functions for backwards '
'compatibility with older Linux OSes', 0))
conf = env.CBConfigure()
with open('package.json', 'r') as f:
package_info = json.load(f)
# Config vars
version = package_info['version']
env.Append(BUILD_INFO_PACKAGE_VARS = 'URL')
env.Replace(RESOURCES_NS = 'FAH::Client')
env.Replace(BUILD_INFO_NS = 'FAH::Client::BuildInfo')
env.Replace(PACKAGE_VERSION = version)
env.Replace(PACKAGE_AUTHOR = package_info['author'])
env.Replace(PACKAGE_COPYRIGHT = package_info['copyright'])
env.Replace(PACKAGE_HOMEPAGE = package_info['homepage'])
env.Replace(PACKAGE_LICENSE = package_info['license'])
env.Replace(PACKAGE_URL = package_info['url'])
env.Replace(PACKAGE_ORG = 'foldingathome.org')
if not env.GetOption('clean'):
conf.CBConfig('compiler')
conf.CBConfig('cbang')
env.CBDefine('USING_CBANG') # Using CBANG macro namespace
# OSX
if env['PLATFORM'] == 'darwin':
conf.RequireOSXFramework('SystemConfiguration')
# Windows Systray
if env['PLATFORM'] == 'win32': conf.CBRequireLib('shell32')
if env['PLATFORM'] == 'posix':
if env['wrap_glibc']:
funcs = 'glob logf log expf exp powf pow fcntl64'
flags = ['-Wl,--wrap=' + x for x in funcs.split()]
env.AppendUnique(LINKFLAGS = flags)
env.Append(PREFER_DYNAMIC = 'z bz2 lz4 systemd m'.split())
conf.Finish()
# Client
Export('env')
client = SConscript('src/client.scons', variant_dir = 'build', duplicate = 0)
Default(client)
# HideConsole
hide_console = None
if env['PLATFORM'] == 'win32' or int(env.get('cross_mingw', 0)):
hide_console = SConscript('src/HideConsole.scons', variant_dir = 'build',
duplicate = 0)
Default(hide_console)
# Clean
Clean(client, ['build', 'config.log'])
# Dist
docs = ['README.md', 'CHANGELOG.md', 'LICENSE']
distfiles = docs + [client, 'images/fahlogo.png']
if env['PLATFORM'] == 'posix':
distfiles.append('install/lin/fah-client.service')
if hide_console is not None: distfiles.append(hide_console)
tar = env.TarBZ2Dist('fah-client', distfiles)
Alias('dist', tar)
AlwaysBuild(tar)
Clean(tar, ['dist.txt'])
if 'package' in COMMAND_LINE_TARGETS:
# Resolve variables in ``.in`` files and directories
if env['PLATFORM'] == 'win32': paths = ['win']
elif env['PLATFORM'] == 'darwin': paths = ['osx']
else: paths = ['lin', 'debian', 'rpm']
for p in paths: env.ReplaceVariablesInFiles('install/' + p, 'build/install')
# Code sign key password
path = os.environ.get('CODE_SIGN_KEY_PASS_FILE')
if path is not None: code_sign_key_pass = open(path, 'r').read().strip()
else: code_sign_key_pass = None
if 'SIGNTOOL' in os.environ: env['SIGNTOOL'] = os.environ['SIGNTOOL']
misc = []
pkg_target = None
pkg_components = []
if env['PLATFORM'] == 'darwin':
def seticon(info):
"""Add icon to web control url file resourse fork"""
# brew install fileicon
# Packager functions do not preserve rsrc fork, so use callback
env.RunCommand(['fileicon', 'set',
info['root'] + '/Applications/Folding@home/[email protected]',
'images/fahlogo.icns'])
# Specify components for the osx distribution pkg
pkg_components = [dict(
# name is component pkg file name and name shown in installer
name = 'FAHClient',
pkg_id = 'org.foldingathome.fahclient.pkg',
description = 'FAH_CLIENT_DESC', # Localizable.strings key
home = '.', # abs path or relative to PWD
pkg_scripts = 'build/install/osx/scripts', # relative to home
root = './build/pkg/root', # abs path or relative to PWD
sign_tools = ['usr/local/bin/fah-client'], # relative to root
must_close_apps = [
'org.foldingathome.fahviewer',
'org.foldingathome.fahcontrol',
'edu.stanford.folding.fahviewer',
'edu.stanford.folding.fahcontrol',
],
pkg_files = [
[str(client[0]), 'usr/local/bin/', 0o755],
['scripts/fahctl', 'usr/local/bin/', 0o755],
['build/install/osx/fahclient.url',
'Applications/Folding@home/[email protected]', 0o644],
['build/install/osx/uninstall.url',
'Applications/Folding@home/uninstall.url', 0o644],
['build/install/osx/launchd.plist',
'Library/LaunchDaemons/' +
'org.foldingathome.fahclient.plist', 0o644]
],
pre_sign_callback = seticon,
)]
# min pkg target macos 10.13
pkg_target = env.get('osx_min_ver', '10.13')
ver = tuple([int(x) for x in pkg_target.split('.')])
if ver < (10, 13): pkg_target = '10.13'
elif env['PLATFORM'] == 'posix':
if env.GetPackageType() == 'deb':
polkit = [
'build/install/lin/10-fah-client.pkla',
'var/lib/polkit-1/localauthority/10-vendor.d/10-fah-client.pkla'
]
else:
polkit = ['build/install/lin/10-fah-client.rules',
'usr/share/polkit-1/rules.d/10-fah-client.rules']
misc.append(polkit)
# Package
pkg = env.Packager(
package_info.get('name'),
version = version,
maintainer = env['PACKAGE_AUTHOR'],
vendor = env['PACKAGE_ORG'],
url = env['PACKAGE_HOMEPAGE'],
license = 'LICENSE',
bug_url =
'https://github.com/FoldingAtHome/fah-client-bastet',
summary = 'Folding@home Client',
description = package_info.get('description'),
icons = ['images/fahlogo.png'],
documents = docs,
programs = [str(client[0]), 'scripts/fahctl'],
desktop_menu = ['build/install/lin/fah-client.desktop'],
changelog = 'CHANGELOG.md',
systemd = ['build/install/lin/fah-client.service'],
misc = misc,
nsi = 'build/install/win/fah-client.nsi',
timestamp_url = 'http://timestamp.comodoca.com/authenticode',
code_sign_key = os.environ.get('CODE_SIGN_KEY', None),
code_sign_key_pass = code_sign_key_pass,
deb_directory = 'build/install/debian',
deb_section = 'science',
deb_depends =
'ca-certificates, polkitd-pkla | policykit-1 (<< 0.106), libexpat1',
deb_recommends = 'nvidia-opencl-icd',
deb_conflicts = 'FAHClient, fahclient',
deb_replaces = 'FAHClient, fahclient',
deb_suggests = 'python3-websocket',
deb_pre_depends = 'adduser, procps',
deb_priority = 'optional',
rpm_license = env['PACKAGE_LICENSE'],
rpm_group = 'Applications/Internet',
rpm_post = 'build/install/rpm/post',
rpm_postun = 'build/install/rpm/postun',
rpm_pre = 'build/install/rpm/pre',
rpm_preun = 'build/install/rpm/preun',
rpm_conflicts = 'FAHClient, fahclient',
rpm_obsoletes = 'FAHClient, fahclient',
rpm_suggests = 'python3-websocket-client',
rpm_provides = 'user(fah-client), group(fah-client)',
rpm_build_requires = 'systemd-rpm-macros',
rpm_requires = 'polkit, expat',
rpm_pre_requires = 'systemd, procps, (shadow-utils or shadow)',
rpm_post_requires = 'systemd, coreutils',
rpm_preun_requires = 'systemd',
rpm_postun_requires= 'systemd',
rpm_client_dirs = [
'var/lib/fah-client', 'var/log/fah-client', 'etc/fah-client'],
pkg_type = 'dist',
pkg_resources = [['build/install/osx/Resources', '.'],
['LICENSE', 'en.lproj/LICENSE.txt']],
pkg_welcome = 'Welcome.rtf',
pkg_readme = 'Readme.rtf',
pkg_license = 'LICENSE.txt',
pkg_conclusion = 'Conclusion.rtf',
pkg_background = 'fah-opacity-50.png',
pkg_customize = 'ask',
pkg_target = pkg_target,
pkg_components = pkg_components,
)
AlwaysBuild(pkg)
env.Alias('package', pkg)
Clean(pkg, ['build/pkg', 'build/flatdistpkg', 'package.txt'])