forked from adamlaska/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-ffmpeg.py
More file actions
executable file
·75 lines (56 loc) · 2.17 KB
/
verify-ffmpeg.py
File metadata and controls
executable file
·75 lines (56 loc) · 2.17 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
#!/usr/bin/env python
import os
import shutil
import subprocess
import sys
from lib.util import electron_gyp, rm_rf
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
FFMPEG_LIBCC_PATH = os.path.join(SOURCE_ROOT, 'vendor', 'download',
'libchromiumcontent', 'ffmpeg')
PROJECT_NAME = electron_gyp()['project_name%']
PRODUCT_NAME = electron_gyp()['product_name%']
def main():
os.chdir(SOURCE_ROOT)
if len(sys.argv) == 2 and sys.argv[1] == '-R':
config = 'R'
else:
config = 'D'
app_path = create_app_copy(config)
if sys.platform == 'darwin':
electron = os.path.join(app_path, 'Contents', 'MacOS', PRODUCT_NAME)
ffmpeg_name = 'libffmpeg.dylib'
ffmpeg_app_path = os.path.join(app_path, 'Contents', 'Frameworks',
'{0} Framework.framework'.format(PROJECT_NAME),
'Libraries')
elif sys.platform == 'win32':
electron = os.path.join(app_path, '{0}.exe'.format(PROJECT_NAME))
ffmpeg_app_path = app_path
ffmpeg_name = 'ffmpeg.dll'
else:
electron = os.path.join(app_path, PROJECT_NAME)
ffmpeg_app_path = app_path
ffmpeg_name = 'libffmpeg.so'
# Copy ffmpeg without proprietary codecs into app
shutil.copy(os.path.join(FFMPEG_LIBCC_PATH, ffmpeg_name), ffmpeg_app_path)
returncode = 0
try:
test_path = os.path.join('spec', 'fixtures', 'no-proprietary-codecs.js')
subprocess.check_call([electron, test_path] + sys.argv[1:])
except subprocess.CalledProcessError as e:
returncode = e.returncode
except KeyboardInterrupt:
returncode = 0
return returncode
# Create copy of app to install ffmpeg library without proprietary codecs into
def create_app_copy(config):
initial_app_path = os.path.join(SOURCE_ROOT, 'out', config)
app_path = os.path.join(SOURCE_ROOT, 'out', config + '-no-proprietary-codecs')
if sys.platform == 'darwin':
app_name = '{0}.app'.format(PRODUCT_NAME)
initial_app_path = os.path.join(initial_app_path, app_name)
app_path = os.path.join(app_path, app_name)
rm_rf(app_path)
shutil.copytree(initial_app_path, app_path, symlinks=True)
return app_path
if __name__ == '__main__':
sys.exit(main())