Bug 1494162 - Part 6: Lazy load the modules in the ElementContainer. r=pbro
[gecko.git] / .ycm_extra_conf.py
blob4539ae535a6fda3b7e56cb1b717384b16b89eccd
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import imp
6 import os
7 import shlex
8 import sys
9 try:
10 from StringIO import StringIO
11 except ImportError:
12 from io import StringIO
14 old_bytecode = sys.dont_write_bytecode
15 sys.dont_write_bytecode = True
17 path = os.path.join(os.path.dirname(__file__), 'mach')
19 if not os.path.exists(path):
20 path = os.path.join(os.path.dirname(__file__), 'config.status')
21 config = imp.load_module('_buildconfig', open(path), path, ('', 'r', imp.PY_SOURCE))
22 path = os.path.join(config.topsrcdir, 'mach')
23 mach_module = imp.load_module('_mach', open(path), path, ('', 'r', imp.PY_SOURCE))
25 sys.dont_write_bytecode = old_bytecode
27 def FlagsForFile(filename):
28 mach = mach_module.get_mach()
29 out = StringIO()
31 # Mach calls sys.stdout.fileno(), so we need to fake it when capturing it.
32 # Returning an invalid file descriptor does the trick.
33 out.fileno = lambda: -1
34 out.encoding = None
35 mach.run(['compileflags', filename], stdout=out, stderr=out)
37 flag_list = shlex.split(out.getvalue())
39 # This flag is added by Fennec for android build and causes ycmd to fail to parse the file.
40 # Removing this flag is a workaround until ycmd starts to handle this flag properly.
41 # https://github.com/Valloric/YouCompleteMe/issues/1490
42 final_flags = [x for x in flag_list if not x.startswith('-march=armv')]
44 return {
45 'flags': final_flags,
46 'do_cache': True