blob: eba4bd1fb3c83fc80dab7caa45298688160d176f [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Replaces GN files in tree with files from here that
make the build use system libraries.
from __future__ import print_function
import argparse
import os
import shutil
import sys
'ffmpeg': 'third_party/ffmpeg/',
'flac': 'third_party/flac/',
'fontconfig': 'third_party/fontconfig/',
'freetype': 'build/config/freetype/freetype.gni',
'harfbuzz-ng': 'third_party/harfbuzz-ng/harfbuzz.gni',
'icu': 'third_party/icu/',
'libdrm': 'third_party/libdrm/',
'libevent': 'base/third_party/libevent/',
'libjpeg': 'third_party/libjpeg.gni',
'libpng': 'third_party/libpng/',
'libvpx': 'third_party/libvpx/',
'libwebp': 'third_party/libwebp/',
'libxml': 'third_party/libxml/',
'libxslt': 'third_party/libxslt/',
'openh264': 'third_party/openh264/',
'opus': 'third_party/opus/',
're2': 'third_party/re2/',
'snappy': 'third_party/snappy/',
'zlib': 'third_party/zlib/',
def DoMain(argv):
my_dirname = os.path.dirname(__file__)
source_tree_root = os.path.abspath(
os.path.join(my_dirname, '..', '..', '..'))
parser = argparse.ArgumentParser()
parser.add_argument('--system-libraries', nargs='*', default=[])
parser.add_argument('--undo', action='store_true')
args = parser.parse_args(argv)
handled_libraries = set()
for lib, path in REPLACEMENTS.items():
if lib not in args.system_libraries:
if args.undo:
# Restore original file, and also remove the backup.
# This is meant to restore the source tree to its original state.
os.rename(os.path.join(source_tree_root, path + '.orig'),
os.path.join(source_tree_root, path))
# Create a backup copy for --undo.
shutil.copyfile(os.path.join(source_tree_root, path),
os.path.join(source_tree_root, path + '.orig'))
# Copy the GN file from directory of this script to target path.
shutil.copyfile(os.path.join(my_dirname, '' % lib),
os.path.join(source_tree_root, path))
unhandled_libraries = set(args.system_libraries) - handled_libraries
if unhandled_libraries:
print('Unrecognized system libraries requested: %s' % ', '.join(
sorted(unhandled_libraries)), file=sys.stderr)
return 1
return 0
if __name__ == '__main__':