forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.h
More file actions
335 lines (258 loc) · 9.97 KB
/
deploy.h
File metadata and controls
335 lines (258 loc) · 9.97 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
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/* Copyright (C) 2003-2013 Runtime Revolution Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
#ifndef __MC_DEPLOY__
#define __MC_DEPLOY__
////////////////////////////////////////////////////////////////////////////////
struct MCDeployParameters
{
// The path to the engine binaries to use. On Windows and Linux this should
// be just 'engine'. On OS X, set one other or both to form a single or
// universal architecture standalone.
char *engine;
char *engine_ppc;
char *engine_x86;
// When building on Windows, this might contain an array with the versioninfo
// fields.
MCVariableValue *version_info;
// The root stackfile to be included in the standalone.
char *stackfile;
// The array of auxillary stackfiles to be included in the standalone.
char **auxillary_stackfiles;
uint32_t auxillary_stackfile_count;
// The array of externals to be loaded on startup by the standalone.
char **externals;
uint32_t external_count;
// The script to be executed on startup by the standalone.
char *startup_script;
// If true, then the standalone will have an implicit timeout
uint32_t timeout;
// The list of redirection mappings
char **redirects;
uint32_t redirect_count;
// On Windows, the icon files to be inserted into the resource directory.
char *app_icon;
char *doc_icon;
// On Windows, the path to the manifest file to be included in the executable
// (optional).
char *manifest;
// When building an installer, the path to the payload to be inserted
char *payload;
// If this is non-nil, it contains a file to be used to 'spill' data above
// 4K into. It is designed for use on OS X to reduce standalone file size.
char *spill;
// The output path for the new executable.
char *output;
};
Exec_stat MCDeployToWindows(const MCDeployParameters& p_params);
Exec_stat MCDeployToLinux(const MCDeployParameters& p_params);
Exec_stat MCDeployToMacOSX(const MCDeployParameters& p_params);
Exec_stat MCDeployToIOS(const MCDeployParameters& p_params, bool embedded);
Exec_stat MCDeployToAndroid(const MCDeployParameters& p_params);
////////////////////////////////////////////////////////////////////////////////
struct MCDeploySignParameters
{
// The passphrase needed to decrypt any of the other files (if needed).
char *passphrase;
// The path to the software publishing certificate stored in a PKCS#7
// SignedInfo structure.
char *certificate;
// The path to the private key file stored in a PKCS#8 PrivateKey
// structure or the Microsoft PVK file format.
char *privatekey;
// The path to either a PKCS#12 certificate/privatekey store. This is
// only needed if the previous two fields are nil.
char *certstore;
// The url to use for timestamping - if needed
char *timestamper;
// The UTF-8 string describing the pprogram name/description
char *description;
// The UTF-8 string contining the URL of the company
char *url;
// The path to the executable to sign
char *input;
// The outpath for the resulting signed executable
char *output;
};
bool MCDeploySignWindows(const MCDeploySignParameters& p_params);
////////////////////////////////////////////////////////////////////////////////
struct MCDeployDietParameters
{
// The input engine to process
char *input;
// Which architectures to keep (if present)
bool keep_x86;
bool keep_x86_64;
bool keep_ppc;
bool keep_ppc64;
bool keep_arm;
// Whether to keep symbols
bool keep_debug_symbols;
// Where to put the output
char *output;
};
Exec_stat MCDeployDietMacOSX(const MCDeployDietParameters& p_params);
////////////////////////////////////////////////////////////////////////////////
struct MCDeployDmgItem
{
uint32_t parent;
char *name;
bool is_folder;
// BSD permission info
uint32_t owner_id;
uint32_t group_id;
uint32_t file_mode;
// If any of these are 0 they take on 'default' values.
uint32_t create_date;
uint32_t content_mod_date;
uint32_t attribute_mod_date;
uint32_t access_date;
uint32_t backup_date;
union
{
struct
{
char *data_fork;
uint32_t file_type;
uint32_t file_creator;
int16_t location_x;
int16_t location_y;
} file;
struct
{
int16_t window_x;
int16_t window_y;
int16_t window_width;
int16_t window_height;
int16_t location_x;
int16_t location_y;
} folder;
};
};
struct MCDeployDmgParameters
{
// The items to include in the dmg
MCDeployDmgItem *items;
uint32_t item_count;
// Where to put the output
char *output;
};
Exec_stat MCDeployDmgBuild(MCDeployDmgParameters& params);
bool MCDeployDmgDump(const char *p_dmg_file, void (*p_log)(void *, const char *, ...), void *p_context);
////////////////////////////////////////////////////////////////////////////////
Exec_stat MCDeployExtractMacOSX(const char *p_filename, const char *p_segment, const char *p_section, void*& r_data, uint32_t& r_data_size);
////////////////////////////////////////////////////////////////////////////////
enum MCDeployError
{
kMCDeployErrorNone,
kMCDeployErrorNoMemory,
kMCDeployErrorNoEngine,
kMCDeployErrorNoStackfile,
kMCDeployErrorNoAuxStackfile,
kMCDeployErrorNoOutput,
kMCDeployErrorNoSpill,
kMCDeployErrorNoPayload,
kMCDeployErrorBadFile,
kMCDeployErrorBadRead,
kMCDeployErrorBadWrite,
kMCDeployErrorBadCompress,
kMCDeployErrorWindowsNoDOSHeader,
kMCDeployErrorWindowsBadDOSSignature,
kMCDeployErrorWindowsBadDOSHeader,
kMCDeployErrorWindowsNoNTHeader,
kMCDeployErrorWindowsBadNTSignature,
kMCDeployErrorWindowsBadSectionHeaderOffset,
kMCDeployErrorWindowsNoSectionHeaders,
kMCDeployErrorWindowsMissingSections,
kMCDeployErrorWindowsNoResourceSection,
kMCDeployErrorWindowsNoProjectSection,
kMCDeployErrorWindowsNoPayloadSection,
kMCDeployErrorWindowsBadAppIcon,
kMCDeployErrorWindowsBadDocIcon,
kMCDeployErrorWindowsBadManifest,
kMCDeployErrorWindowsBadSecuritySection,
kMCDeployErrorLinuxNoHeader,
kMCDeployErrorLinuxBadHeaderMagic,
kMCDeployErrorLinuxBadHeaderType,
kMCDeployErrorLinuxBadImage,
kMCDeployErrorLinuxBadSectionSize,
kMCDeployErrorLinuxBadSectionTable,
kMCDeployErrorLinuxBadSegmentSize,
kMCDeployErrorLinuxBadProgramTable,
kMCDeployErrorLinuxBadStringIndex,
kMCDeployErrorLinuxBadString,
kMCDeployErrorLinuxNoProjectSection,
kMCDeployErrorLinuxNoPayloadSection,
kMCDeployErrorLinuxBadSectionOrder,
kMCDeployErrorLinuxNoProjectSegment,
kMCDeployErrorLinuxPayloadNotInProjectSegment,
kMCDeployErrorMacOSXNoHeader,
kMCDeployErrorMacOSXBadHeader,
kMCDeployErrorMacOSXBadCommand,
kMCDeployErrorMacOSXNoLinkEditSegment,
kMCDeployErrorMacOSXNoProjectSegment,
kMCDeployErrorMacOSXNoPayloadSegment,
kMCDeployErrorMacOSXBadSegmentOrder,
kMCDeployErrorMacOSXUnknownLoadCommand,
kMCDeployErrorMacOSXBadCpuType,
kMCDeployErrorMacOSXBadTarget,
// SIGN ERRORS
kMCDeployErrorNoCertificate,
kMCDeployErrorBadCertificate,
kMCDeployErrorEmptyCertificate,
kMCDeployErrorNoPrivateKey,
kMCDeployErrorBadPrivateKey,
// The privatekey does not match the cert
kMCDeployErrorCertMismatch,
// A password is needed, but was not given
kMCDeployErrorNoPassword,
// The password did not match
kMCDeployErrorBadPassword,
// An error occured while building the signature
kMCDeployErrorBadSignature,
// An error occured while trying to convert a string
kMCDeployErrorBadString,
// An error occured while trying to compute the hash
kMCDeployErrorBadHash,
// An error occured while trying to fetch a timestamp
kMCDeployErrorTimestampFailed,
// An error occured decoding the timestamp response
kMCDeployErrorBadTimestamp,
// DIET ERRORS
kMCDeployErrorNoArchs,
kMCDeployErrorCannotDiet,
};
bool MCDeployThrow(MCDeployError status);
MCDeployError MCDeployCatch(void);
const char *MCDeployErrorToString(MCDeployError p_error);
////////////////////////////////////////////////////////////////////////////////
// The MCDeployFileRef is an opaque type with a set of methods allowing easy
// file manipulation designed for the kinds of operations needed by the deploy
// methods. It should not be used outside of these routines.
typedef FILE *MCDeployFileRef;
bool MCDeployFileOpen(const char *p_path, const char *p_mode , MCDeployFileRef& r_file);
void MCDeployFileClose(MCDeployFileRef p_file);
bool MCDeployFileRead(MCDeployFileRef p_file, void *p_buffer, uint32_t p_buffer_size);
bool MCDeployFileReadAt(MCDeployFileRef p_file, void *p_buffer, uint32_t p_buffer_size, uint32_t p_at);
bool MCDeployFileSeek(MCDeployFileRef p_file, long p_offset, int p_origin);
bool MCDeployFileCopy(MCDeployFileRef p_dst, uint32_t p_at, MCDeployFileRef p_src, uint32_t p_from, uint32_t p_amount);
bool MCDeployFileWriteAt(MCDeployFileRef p_dst, const void *p_buffer, uint32_t p_size, uint32_t p_at);
bool MCDeployFileTruncate(MCDeployFileRef p_dst, uint32_t amount);
bool MCDeployFileMeasure(MCDeployFileRef p_file, uint32_t& r_size);
////////////////////////////////////////////////////////////////////////////////
void MCDeployByteSwap32(bool p_to_network, uint32_t& p_var);
void MCDeployByteSwapRecord(bool p_to_network, const char *p_format, void *p_data, uint32_t p_data_size);
////////////////////////////////////////////////////////////////////////////////
bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_output, uint32_t& x_offset);
bool MCDeployWriteProject(const MCDeployParameters& p_params, bool p_to_network, MCDeployFileRef p_output, uint32_t p_output_offset, uint32_t& r_project_size);
bool MCDeployWritePayload(const MCDeployParameters& p_params, bool p_to_network, MCDeployFileRef p_output, uint32_t p_output_offset, uint32_t& r_payload_size);
////////////////////////////////////////////////////////////////////////////////
#endif