-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathafter_prepare.js
70 lines (51 loc) · 1.91 KB
/
after_prepare.js
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
#!/usr/bin/env node
'use strict';
const fs = require('fs');
const path = require('path');
const child_process = require('child_process');
const execSync = child_process.execSync;
const ARCH_TYPES = ['i386', 'x86_64', 'armv7', 'arm64'];
function extract(dir) {
// extract all archs, you might want to delete it later.
console.log('Extracting...');
ARCH_TYPES.forEach(elm => {
execSync(`lipo -extract ${elm} WebRTC -o WebRTC-${elm}`, {cwd: dir});
});
execSync('cp WebRTC WebRTC-all', {cwd: dir}); // make a backup
}
function simulator(dir) {
// re-package simulator related archs only. ( i386, x86_64 )
console.log('Compiling simulator...');
execSync(`lipo -o WebRTC -create WebRTC-x86_64 WebRTC-i386`, {cwd: dir});
}
function device(dir) {
// re-package device related archs only. ( armv7, arm64 )
console.log('Compiling device...');
execSync(`lipo -o WebRTC -create WebRTC-armv7 WebRTC-arm64`, {cwd: dir});
}
function list(dir) {
// List WebRTC architectures
console.log('List WebRTC architectures...');
console.log(execSync(`file WebRTC`, {cwd: dir}).toString().trim());
}
function clean(dir) {
// Delete WebRTC-* architectures
console.log('Clean WebRTC architectures...');
console.log(execSync(`rm -f WebRTC-*`, {cwd: dir}).toString().trim());
}
module.exports = function(ctx) {
console.log('[after_prepare hook] Project root: ' + ctx.opts.projectRoot);
const IOSRTC_PLUGIN_PATH = path.join(ctx.opts.projectRoot, 'plugins/cordova-plugin-iosrtc');
const LIB_PATH = path.join(IOSRTC_PLUGIN_PATH, 'lib');
const WEBRTC_BIN_PATH = path.join(LIB_PATH, 'WebRTC.framework');
const dir = WEBRTC_BIN_PATH;
console.log('List WebRTC files...');
console.log(execSync('ls -ahl | grep WebRTC', {cwd: dir}).toString().trim());
extract(dir);
//simulator(dir);
device(dir);
clean(dir);
list(dir);
console.log('List WebRTC files...');
console.log(execSync('ls -ahl | grep WebRTC', {cwd: dir}).toString().trim());
};