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