2018-08-21 20:06:28 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import zipfile
|
|
|
|
|
2018-09-18 16:48:01 +03:00
|
|
|
EXTENSIONS_TO_SKIP = [
|
2019-05-29 00:11:02 +03:00
|
|
|
'.pdb',
|
|
|
|
'.mojom.js',
|
|
|
|
'.mojom-lite.js',
|
2018-09-18 16:48:01 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
PATHS_TO_SKIP = [
|
2018-09-21 23:58:33 +03:00
|
|
|
'angledata', #Skipping because it is an output of //ui/gl that we don't need
|
2019-06-03 21:17:57 +03:00
|
|
|
'./libVkICD_mock_', #Skipping because these are outputs that we don't need
|
|
|
|
'./VkICD_mock_', #Skipping because these are outputs that we don't need
|
2018-10-24 03:19:02 +03:00
|
|
|
|
|
|
|
# //chrome/browser:resources depends on this via
|
|
|
|
# //chrome/browser/resources/ssl/ssl_error_assistant, but we don't need to
|
|
|
|
# ship it.
|
|
|
|
'pyproto',
|
2018-09-18 16:48:01 +03:00
|
|
|
]
|
|
|
|
|
2018-11-21 23:19:19 +03:00
|
|
|
def skip_path(dep, dist_zip, target_cpu):
|
|
|
|
# Skip specific paths and extensions as well as the following special case:
|
|
|
|
# snapshot_blob.bin is a dependency of mksnapshot.zip because
|
|
|
|
# v8_context_generator needs it, but this file does not get generated for arm
|
|
|
|
# and arm 64 binaries of mksnapshot since they are built on x64 hardware.
|
|
|
|
# Consumers of arm and arm64 mksnapshot can generate snapshot_blob.bin
|
|
|
|
# themselves by running mksnapshot.
|
2018-09-20 18:02:47 +03:00
|
|
|
should_skip = (
|
|
|
|
any(dep.startswith(path) for path in PATHS_TO_SKIP) or
|
2018-11-21 23:19:19 +03:00
|
|
|
any(dep.endswith(ext) for ext in EXTENSIONS_TO_SKIP) or
|
|
|
|
('arm' in target_cpu and dist_zip == 'mksnapshot.zip' and dep == 'snapshot_blob.bin'))
|
2018-09-21 23:58:33 +03:00
|
|
|
if should_skip:
|
|
|
|
print("Skipping {}".format(dep))
|
2018-09-20 18:02:47 +03:00
|
|
|
return should_skip
|
2018-09-18 16:48:01 +03:00
|
|
|
|
2018-08-21 20:06:28 +03:00
|
|
|
def execute(argv):
|
|
|
|
try:
|
|
|
|
output = subprocess.check_output(argv, stderr=subprocess.STDOUT)
|
|
|
|
return output
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
print e.output
|
|
|
|
raise e
|
|
|
|
|
|
|
|
def main(argv):
|
|
|
|
dist_zip, runtime_deps, target_cpu, target_os = argv
|
2018-10-03 07:49:10 +03:00
|
|
|
dist_files = set()
|
2018-08-21 20:06:28 +03:00
|
|
|
with open(runtime_deps) as f:
|
|
|
|
for dep in f.readlines():
|
|
|
|
dep = dep.strip()
|
2018-10-03 07:49:10 +03:00
|
|
|
dist_files.add(dep)
|
2018-08-21 20:06:28 +03:00
|
|
|
if sys.platform == 'darwin':
|
2018-10-03 07:49:10 +03:00
|
|
|
execute(['zip', '-r', '-y', dist_zip] + list(dist_files))
|
2018-08-21 20:06:28 +03:00
|
|
|
else:
|
2019-05-29 19:40:02 +03:00
|
|
|
with zipfile.ZipFile(dist_zip, 'w', zipfile.ZIP_DEFLATED, allowZip64=True) as z:
|
2018-08-21 20:06:28 +03:00
|
|
|
for dep in dist_files:
|
2018-11-21 23:19:19 +03:00
|
|
|
if skip_path(dep, dist_zip, target_cpu):
|
2018-09-18 16:48:01 +03:00
|
|
|
continue
|
2018-08-21 20:06:28 +03:00
|
|
|
if os.path.isdir(dep):
|
|
|
|
for root, dirs, files in os.walk(dep):
|
|
|
|
for file in files:
|
2018-09-22 04:29:55 +03:00
|
|
|
z.write(os.path.join(root, file))
|
2018-08-21 20:06:28 +03:00
|
|
|
else:
|
2019-03-09 00:10:26 +03:00
|
|
|
basename = os.path.basename(dep)
|
|
|
|
dirname = os.path.dirname(dep)
|
|
|
|
arcname = os.path.join(dirname, 'chrome-sandbox') if basename == 'chrome_sandbox' else dep
|
|
|
|
z.write(dep, arcname)
|
2018-08-21 20:06:28 +03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main(sys.argv[1:]))
|