This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
SConstruct
118 lines (98 loc) · 3.5 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
# Setup
from __future__ import absolute_import
from __future__ import print_function
import os
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('packager run_distutils osx fah-client-version')
env.CBAddVariables(
BoolVariable('cross_mingw', 'Build with mingw cross compiler', 0))
conf = env.CBConfigure()
# Version
try:
version = env.FAHClientVersion()
except Exception as e:
print(e)
version = '0.0.0'
env.Replace(PACKAGE_VERSION = version)
f = open('version.txt', 'w')
f.write(version)
f.close()
if env['PLATFORM'] != 'darwin': env['package_arch'] = 'noarch'
# Build
target_dir = None
if env['PLATFORM'] == 'darwin':
env['RUN_DISTUTILSOPTS'] = 'py2app'
target_dir = 'dist/FAHControl.app'
import shutil
# rm old pkg dir so osx fah installer won't bundle an old build
shutil.rmtree('build/pkg', True)
elif env['PLATFORM'] == 'win32' or int(env.get('cross_mingw', 0)):
env['RUN_DISTUTILSOPTS'] = 'build'
target_dir = 'gui'
target_pat = '' # Not packaged here
elif env.GetPackageType() == 'deb':
env['RUN_DISTUTILSOPTS'] = ['--command-packages=stdeb.command', 'bdist_deb']
target_dir = 'deb_dist'
target_pat = 'deb_dist/fahcontrol_%s-*.deb' % version
# Run distutils
gui = None
if env.GetPackageType() != 'rpm':
# Cleanup old GUI build
# Note: py2app does not work correctly if the old .app is still around
import shutil
shutil.rmtree(target_dir, True)
if int(env.get('cross_mingw', 0)):
# Use the cross compiled Python
gui = env.Command(target_dir, 'setup.py', 'python2.exe setup.py build')
else:
gui = env.RunDistUtils(Dir(target_dir), 'setup.py')
Default(gui)
AlwaysBuild(gui)
# Package
if env['PLATFORM'] == 'darwin' or env.GetPackageType() == 'rpm':
pkg = env.Packager(
'FAHControl',
version = version,
maintainer = 'Joseph Coffland <[email protected]>',
vendor = 'Folding@home',
url = 'https://foldingathome.org/',
license = 'LICENSE.txt',
bug_url = 'https://apps.foldingathome.org/bugs/',
summary = 'Folding@home Control',
description = \
'Control and monitor local and remote Folding@home clients',
prefix = '/usr',
documents = ['README.md', 'CHANGELOG.md', 'LICENSE.txt'],
desktop_menu = ['FAHControl.desktop'],
icons = ['images/FAHControl.png'],
rpm_license = 'GPL v3+',
rpm_group = 'Applications/Internet',
rpm_requires = 'python, pygtk2',
rpm_build = 'rpm/build',
rpm_filelist = 'filelist.txt',
pkg_id = 'org.foldingathome.fahcontrol.pkg',
pkg_resources = 'osx/Resources',
pkg_apps = [['dist/FAHControl.app', 'Folding@home/FAHControl.app']],
pkg_scripts = 'osx/scripts',
pkg_target = '10.6',
pkg_distribution = 'osx/distribution.xml',
)
AlwaysBuild(pkg)
env.Alias('package', pkg)
if gui is not None: Depends(pkg, gui)
else:
# Write package.txt
def write_filename(target, source, env):
import glob
filename = str(Glob(target_pat)[0])
open(str(target[0]), 'w').write(filename)
bld = Builder(action = write_filename)
env.Append(BUILDERS = {'WriteFilename' : bld})
cmd = env.WriteFilename('package.txt', [])
AlwaysBuild(cmd)
if gui is not None: Depends(cmd, gui)
env.Alias('package', [cmd])