-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackageScript
More file actions
143 lines (96 loc) · 2.71 KB
/
PackageScript
File metadata and controls
143 lines (96 loc) · 2.71 KB
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
# vim: set ts=2 sw=2 tw=99 noet ft=python:
import os
import glob
builder.SetBuildFolder('package')
class SDKPackage:
def __init__(self, cxx, sdk_name):
self.sdk_name = sdk_name
self.plugin_folder_path = os.path.join(
self.sdk_name,
'addons',
MMSPlugin.plugin_name
)
self.plugin_folder = builder.AddFolder(self.plugin_folder_path)
self.metamod_path = os.path.join(
self.sdk_name,
'addons',
'metamod'
)
self.metamod = builder.AddFolder(self.metamod_path)
self.addBinFolder(cxx)
self.generateVDF()
def addBinFolder(self, cxx):
platform64_path_map = {
'windows': 'win64',
'linux': 'linuxsteamrt64',
'mac': 'osx64'
}
if cxx.target.arch == 'x86_64':
self.bin_path = os.path.join(
self.plugin_folder_path,
'bin',
platform64_path_map[cxx.target.platform]
)
else:
self.bin_path = os.path.join(
self.plugin_folder_path,
'bin'
)
self.bin = builder.AddFolder(self.bin_path)
def generateVDF(self):
vdf = '"Metamod Plugin"\n'
vdf += '{\n'
vdf += f'\t"alias"\t"{MMSPlugin.plugin_alias}"\n'
vdf += f'\t"file"\t"{os.path.join(os.path.relpath(self.bin_path, self.sdk_name), MMSPlugin.plugin_name)}"\n'
vdf += '}'
builder.AddOutputFile(
os.path.join(
self.metamod_path,
f'{MMSPlugin.plugin_name}.vdf'
),
vdf.encode('utf8')
)
def addBinary(self, binary):
(_, name) = os.path.split(binary.path)
ext = os.path.splitext(name)[1]
builder.AddCopy(
binary,
os.path.join(
self.bin_path,
MMSPlugin.plugin_name + ext
)
)
def addFolder(self, folder_path, result_path=None):
if not os.path.isabs(folder_path):
folder_path = os.path.join(builder.sourcePath, folder_path)
if result_path is None:
result_path = self.sdk_name
else:
result_path = os.path.join(self.sdk_name, result_path)
for root, _, files in os.walk(folder_path):
for f in files:
src = os.path.join(root, f)
rel = os.path.relpath(src, folder_path)
dst = os.path.join(result_path, rel)
builder.AddFolder(os.path.dirname(dst))
builder.AddCopy(src, dst)
packages = {}
for sdk_target in MMSPlugin.sdk_targets:
sdk = sdk_target.sdk
cxx = sdk_target.cxx
packages[sdk['name']] = SDKPackage(
cxx,
sdk['name']
)
pdb_list = []
sdk_name = list(packages.keys())[0]
for task in MMSPlugin.binaries:
packages[sdk_name].addBinary(task.binary)
if task.debug:
pdb_list.append(task.debug)
with open(
os.path.join(builder.buildPath, 'pdblog.txt'),
'wt'
) as fp:
for line in pdb_list:
fp.write(line.path + '\n')