diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 10:35:01 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 10:35:01 +0000 |
commit | b32da81ecbc4097f3ea29771fe293ae8e0c7f189 (patch) | |
tree | 7d4bbce567506f07d0698ec83becaa6fe0b4d656 /tools/compile_test | |
parent | 1531c30305c882a7103929ba6f73ef30d9ee11d3 (diff) | |
download | chromium_src-b32da81ecbc4097f3ea29771fe293ae8e0c7f189.zip chromium_src-b32da81ecbc4097f3ea29771fe293ae8e0c7f189.tar.gz chromium_src-b32da81ecbc4097f3ea29771fe293ae8e0c7f189.tar.bz2 |
Linux: add a tool and code to make use_system_ffmpeg option more compatible
This introduces a compile-time detection of ffmpeg configuration
(which codecs are available).
See https://groups.google.com/a/chromium.org/d/msg/chromium-dev/fm5Oe_AC3Sc/qkbmC7txaSkJ
for more context.
No functional change for Google Chrome.
BUG=none
Review URL: https://codereview.chromium.org/12302029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/compile_test')
-rwxr-xr-x | tools/compile_test/compile_test.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tools/compile_test/compile_test.py b/tools/compile_test/compile_test.py new file mode 100755 index 0000000..a52c072 --- /dev/null +++ b/tools/compile_test/compile_test.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# Copyright (c) 2013 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. + +""" +Tries to compile given code, produces different output depending on success. + +This is similar to checks done by ./configure scripts. +""" + + +import optparse +import os +import shutil +import subprocess +import sys +import tempfile + + +def DoMain(argv): + parser = optparse.OptionParser() + parser.add_option('--code') + parser.add_option('--on-success', default='') + parser.add_option('--on-failure', default='') + + options, args = parser.parse_args(argv) + + if not options.code: + parser.error('Missing required --code switch.') + + cxx = os.environ.get('CXX', 'g++') + + tmpdir = tempfile.mkdtemp() + try: + cxx_path = os.path.join(tmpdir, 'test.cc') + with open(cxx_path, 'w') as f: + f.write(options.code.decode('string-escape')) + + o_path = os.path.join(tmpdir, 'test.o') + + cxx_popen = subprocess.Popen([cxx, cxx_path, '-o', o_path, '-c'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + cxx_stdout, cxx_stderr = cxx_popen.communicate() + if cxx_popen.returncode == 0: + print options.on_success + else: + print options.on_failure + finally: + shutil.rmtree(tmpdir) + + return 0 + + +if __name__ == '__main__': + sys.exit(DoMain(sys.argv[1:])) |