2017-03-30 02:23:30 +03:00
|
|
|
#!/usr/bin/env python
|
2018-08-22 18:41:25 +03:00
|
|
|
import argparse
|
2017-03-30 02:23:30 +03:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
2018-09-27 21:53:08 +03:00
|
|
|
from lib.util import get_electron_branding, rm_rf
|
2017-03-30 02:23:30 +03:00
|
|
|
|
2018-09-27 21:53:08 +03:00
|
|
|
PROJECT_NAME = get_electron_branding()['project_name']
|
|
|
|
PRODUCT_NAME = get_electron_branding()['product_name']
|
2017-03-30 02:23:30 +03:00
|
|
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
|
|
|
|
|
|
|
def main():
|
2018-08-22 18:41:25 +03:00
|
|
|
args = parse_args()
|
2017-03-30 02:23:30 +03:00
|
|
|
|
2018-09-11 15:53:23 +03:00
|
|
|
source_root = os.path.abspath(args.source_root)
|
|
|
|
initial_app_path = os.path.join(source_root, args.build_dir)
|
2018-08-31 14:52:21 +03:00
|
|
|
app_path = create_app_copy(initial_app_path)
|
|
|
|
|
2017-03-30 02:23:30 +03:00
|
|
|
if sys.platform == 'darwin':
|
2018-09-27 21:53:08 +03:00
|
|
|
electron = os.path.join(app_path, 'Contents', 'MacOS', PRODUCT_NAME)
|
2017-03-30 02:23:30 +03:00
|
|
|
ffmpeg_name = 'libffmpeg.dylib'
|
|
|
|
ffmpeg_app_path = os.path.join(app_path, 'Contents', 'Frameworks',
|
2018-09-27 21:53:08 +03:00
|
|
|
'{0} Framework.framework'.format(PRODUCT_NAME),
|
2017-03-30 02:23:30 +03:00
|
|
|
'Libraries')
|
|
|
|
elif sys.platform == 'win32':
|
2018-09-27 21:53:08 +03:00
|
|
|
electron = os.path.join(app_path, '{0}.exe'.format(PROJECT_NAME))
|
2017-03-30 02:23:30 +03:00
|
|
|
ffmpeg_app_path = app_path
|
2017-03-30 03:01:25 +03:00
|
|
|
ffmpeg_name = 'ffmpeg.dll'
|
2017-03-30 02:23:30 +03:00
|
|
|
else:
|
2018-09-27 21:53:08 +03:00
|
|
|
electron = os.path.join(app_path, PROJECT_NAME)
|
2017-03-30 02:23:30 +03:00
|
|
|
ffmpeg_app_path = app_path
|
|
|
|
ffmpeg_name = 'libffmpeg.so'
|
|
|
|
|
2018-08-31 14:52:21 +03:00
|
|
|
# Copy ffmpeg without proprietary codecs into app.
|
2018-09-11 15:53:23 +03:00
|
|
|
ffmpeg_lib_path = os.path.join(source_root, args.ffmpeg_path, ffmpeg_name)
|
2018-08-31 14:52:21 +03:00
|
|
|
shutil.copy(ffmpeg_lib_path, ffmpeg_app_path)
|
2017-03-30 02:23:30 +03:00
|
|
|
|
|
|
|
returncode = 0
|
|
|
|
try:
|
2018-08-22 18:41:25 +03:00
|
|
|
test_path = os.path.join(SOURCE_ROOT, 'spec', 'fixtures',
|
|
|
|
'no-proprietary-codecs.js')
|
2018-09-21 00:15:33 +03:00
|
|
|
env = dict(os.environ)
|
|
|
|
env['ELECTRON_ENABLE_STACK_DUMPING'] = 'true'
|
2018-10-10 05:11:10 +03:00
|
|
|
# FIXME: Enable after ELECTRON_ENABLE_LOGGING works again
|
|
|
|
# env['ELECTRON_ENABLE_LOGGING'] = 'true'
|
2018-09-21 00:15:33 +03:00
|
|
|
subprocess.check_call([electron, test_path] + sys.argv[1:], env=env)
|
2017-03-30 02:23:30 +03:00
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
returncode = e.returncode
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
returncode = 0
|
|
|
|
|
2018-08-24 17:49:01 +03:00
|
|
|
if returncode == 0:
|
|
|
|
print 'ok Non proprietary ffmpeg does not contain proprietary codes.'
|
2017-03-30 02:23:30 +03:00
|
|
|
return returncode
|
|
|
|
|
|
|
|
|
|
|
|
# Create copy of app to install ffmpeg library without proprietary codecs into
|
2018-08-31 14:52:21 +03:00
|
|
|
def create_app_copy(initial_app_path):
|
|
|
|
app_path = os.path.join(os.path.dirname(initial_app_path),
|
2018-09-11 15:53:23 +03:00
|
|
|
os.path.basename(initial_app_path)
|
|
|
|
+ '-no-proprietary-codecs')
|
2017-03-30 02:23:30 +03:00
|
|
|
|
|
|
|
if sys.platform == 'darwin':
|
2018-09-27 21:53:08 +03:00
|
|
|
app_name = '{0}.app'.format(PRODUCT_NAME)
|
2017-03-30 02:23:30 +03:00
|
|
|
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
|
|
|
|
|
2018-08-22 18:41:25 +03:00
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser(description='Test non-proprietary ffmpeg')
|
2018-08-31 14:52:21 +03:00
|
|
|
parser.add_argument('-b', '--build-dir',
|
2018-09-11 15:53:23 +03:00
|
|
|
help='Path to an Electron build folder. \
|
|
|
|
Relative to the --source-root.',
|
2018-08-31 14:52:21 +03:00
|
|
|
default=None,
|
|
|
|
required=True)
|
2018-08-22 18:41:25 +03:00
|
|
|
parser.add_argument('--source-root',
|
|
|
|
default=SOURCE_ROOT,
|
|
|
|
required=False)
|
|
|
|
parser.add_argument('--ffmpeg-path',
|
2018-09-11 15:53:23 +03:00
|
|
|
help='Path to a folder with a ffmpeg lib. \
|
|
|
|
Relative to the --source-root.',
|
2018-08-31 14:52:21 +03:00
|
|
|
default=None,
|
|
|
|
required=True)
|
2018-08-22 18:41:25 +03:00
|
|
|
return parser.parse_args()
|
2017-03-30 02:23:30 +03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|