-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathPackageScript
147 lines (123 loc) · 4.53 KB
/
PackageScript
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
# vim: set ts=2 sw=2 tw=99 noet ft=python:
import os
import shutil
import ambuild.osutil as osutil
from ambuild.command import Command
job = AMBuild.AddJob('package')
class DestroyPath(Command):
def __init__(self, folder):
Command.__init__(self)
self.folder = folder
def destroy(self, path):
entries = os.listdir(path)
for entry in entries:
newpath = os.path.join(path, entry)
if os.path.isdir(newpath):
self.destroy(newpath)
os.rmdir(newpath)
elif os.path.isfile(newpath):
os.remove(newpath)
def run(self, runner, job):
runner.PrintOut('rm -rf {0}/*'.format(self.folder))
self.destroy(self.folder)
class CreateFolders(Command):
def __init__(self, folders):
Command.__init__(self)
self.folders = folders
def run(self, runner, job):
for folder in self.folders:
path = os.path.join(*folder)
runner.PrintOut('mkdir {0}'.format(path))
os.makedirs(path)
#Shallow folder copy
class CopyFolder(Command):
def __init__(self, fromList, toList, excludes = []):
Command.__init__(self)
self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList)
self.toPath = os.path.join(*toList)
self.excludes = excludes
def run(self, runner, job):
entries = os.listdir(self.fromPath)
for entry in entries:
if entry in self.excludes:
continue
path = os.path.join(self.fromPath, entry)
if not os.path.isfile(path):
continue
runner.PrintOut('copy {0} to {1}'.format(path, self.toPath))
shutil.copy(path, self.toPath)
#Single file copy
class CopyFile(Command):
def __init__(self, fromFile, toPath):
Command.__init__(self)
self.fromFile = fromFile
self.toPath = toPath
def run(self, runner, job):
runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath))
shutil.copy(self.fromFile, self.toPath)
folders = [['cfg'],
['cfg', 'cssdm'],
['cfg', 'cssdm', 'extra'],
['cfg', 'cssdm', 'maps'],
['cfg', 'cssdm', 'spawns', 'cstrike'],
['cfg', 'cssdm', 'spawns', 'csgo'],
['addons', 'sourcemod'],
['addons', 'sourcemod', 'extensions'],
['addons', 'sourcemod', 'gamedata'],
['addons', 'sourcemod', 'plugins'],
['addons', 'sourcemod', 'plugins', 'cssdm'],
['addons', 'sourcemod', 'scripting'],
['addons', 'sourcemod', 'scripting', 'include'],
['addons', 'sourcemod', 'translations']]
#Setup
job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
job.AddCommand(CreateFolders(folders))
#Copy Files
job.AddCommand(CopyFolder(['gamedata'], ['addons', 'sourcemod', 'gamedata']))
job.AddCommand(CopyFolder(['scripting'], ['addons', 'sourcemod', 'scripting']))
job.AddCommand(CopyFolder(['scripting', 'include'], ['addons', 'sourcemod', 'scripting', 'include']))
job.AddCommand(CopyFolder(['translations'], ['addons', 'sourcemod', 'translations']))
job.AddCommand(CopyFolder(['cfg'], ['cfg', 'cssdm']))
job.AddCommand(CopyFolder(['cfg', 'spawns', 'cstrike'], ['cfg', 'cssdm', 'spawns', 'cstrike']))
job.AddCommand(CopyFolder(['cfg', 'spawns', 'csgo'], ['cfg', 'cssdm', 'spawns', 'csgo']))
job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'license.txt'),
os.path.join('cfg', 'cssdm', 'extra')))
job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'changelog.txt'),
os.path.join('cfg', 'cssdm', 'extra')))
job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'credits.txt'),
os.path.join('cfg', 'cssdm', 'extra')))
bincopies = []
def AddNormalLibrary(name, dest):
dest = os.path.join('addons', 'sourcemod', dest)
bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
pdb_list.append(name + '\\' + name + '.pdb')
def AddHL2Library(name, dest):
for i in CSSDM.sdkInfo:
sdk = CSSDM.sdkInfo[i]
if AMBuild.target['platform'] not in sdk['platform']:
continue
AddNormalLibrary(name + '.' + sdk['ext'], dest)
pdb_list = []
# Copy loader binaries
AddNormalLibrary('cssdm.ext.2.css', 'extensions')
if AMBuild.target['platform'] != 'darwin':
AddNormalLibrary('cssdm.ext.2.csgo', 'extensions')
job.AddCommandGroup(bincopies)
if AMBuild.target['platform'] == 'windows':
pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
for pdb in pdb_list:
pdblog.write(pdb + '\n')
pdblog.close()
# Copy plugins
plugins = [
'dm_basics',
'dm_bot_quotas',
'dm_equipment',
'dm_preset_spawns',
'dm_spawn_protection'
]
commands = []
for plugin in plugins:
commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'),
os.path.join('addons', 'sourcemod', 'plugins', 'cssdm')))
job.AddCommandGroup(commands)