-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConscript
84 lines (63 loc) · 2.94 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
import requests
import os
import shutil
env = Environment()
baseUrl = 'https://github.com/lordofdragons/dragengine/releases'
#engineVersion = requests.get('{}/latest'.format(baseUrl)).url.split('/')[-1][1:]
#print('Latest Drag[en]gine Release Version: {}'.format(engineVersion))
def StringVariable(key, help, default=''):
return (key, '%s (string)' % help, default)
params = Variables(['custom.py'])
params.Add(StringVariable('version', 'Version', '9999'))
params.Update(env)
distribution = []
pathMSStore = 'distribution/content/microsoft_appstore/VFS/ProgramFilesX64/MyGame'
distribution.extend(env.Install(pathMSStore, 'windows/build/Launcher64.exe'))
distribution.extend(env.Install(pathMSStore, 'data/Launcher.ini'))
pathSteamWorks = 'distribution/content/steamworks'
distribution.extend(env.Install(pathSteamWorks, 'windows_direct/build/Launcher64.exe'))
distribution.extend(env.Install(pathSteamWorks, 'linux/build/launcher64'))
distribution.extend(env.Install(pathSteamWorks, 'data/Launcher.ini'))
def downloadFile(env, target, source):
path = target[0].abspath
with open(path, 'wb') as f:
f.write(requests.get(env['URL']).content)
if 'SET_EXECUTABLE_BIT' in env and env['SET_EXECUTABLE_BIT']:
os.chmod(path, 0o755)
def copyWindowsInstallerScript(env, target, source):
with open(source[0].abspath, 'r') as f:
content = f.read()
content = content.replace('{VERSION}', env['version'])
with open(target[0].abspath, 'w') as f:
f.write(content)
def copyReadme(env, target, source):
with open(source[0].abspath, 'r') as f:
content = f.read()
content = content.replace('{VERSION}', env['version'])
with open(target[0].abspath, 'w') as f:
f.write(content)
def createZipFile(env, target, source):
shutil.make_archive(target[0].abspath, 'zip', source[0].abspath)
distribution.extend(env.Command(
'{}/install-dragengine-{}-windows64.exe'.format(pathSteamWorks, env['version']),
'data/Launcher.ini',
env.Action(downloadFile, 'Download Windows Installer'),
URL='{0}/download/v{1}/install-dragengine-{1}-windows64.exe'.format(baseUrl, env['version'])))
distribution.extend(env.Command(
'{}/install-dragengine-{}-linux64.sh'.format(pathSteamWorks, env['version']),
'data/Launcher.ini',
env.Action(downloadFile, 'Download Linux Installer'),
URL='{0}/download/v{1}/install-dragengine-{1}-linux64.sh'.format(baseUrl, env['version']),
SET_EXECUTABLE_BIT=True))
distribution.extend(env.Command(
'{}/installscript-dragengine-{}.vdf'.format(pathSteamWorks, env['version']),
'data/installscript-dragengine.vdf',
env.Action(copyWindowsInstallerScript, 'SteamWorks Windows Install Script')))
distribution.extend(env.Command(
'distribution/content/README.md'.format(env['version']),
'README.md',
env.Action(copyReadme, 'ReadMe')))
archive = env.Command('distribution/distribute-delga-{}'.format(env['version']),
'distribution/content', env.Action(createZipFile, 'Archive Distribution'))
env.Depends(archive, distribution)
Default(env.Alias('distribution', archive))