.ycm_extra_conf.py
author Sven Sauleau <ssauleau@igalia.com>
Tue, 05 Mar 2019 12:19:31 +0000
changeset 522212 64cc60d52a04d0c97162b18b4c3c744a11684e41
parent 512391 8dcbc414dda673564951f3a28099643f3a8d1ed6
permissions -rw-r--r--
Bug 1526694 [wpt PR 15276] - [wasm] update js-api test runner and expectations, a=testonly Automatic update from web-platform-tests [wasm] update js-api test runner and expectations wasm-module-builder: - consistently adds the end opcode in function bodies (using addBody). - add missing setTableLength method table/get-set: - Avoid unrelated errors like: Cannot destructure property `fn` of 'undefined' or 'null'. Bug: 926311, v8:8319 Change-Id: Ia7db1ee5c3a9b1c1d6092cdce8885ddee4dd9b0e Reviewed-on: https://chromium-review.googlesource.com/c/1458099 Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Sven Sauleau <ssauleau@igalia.com> Cr-Commit-Position: refs/heads/master@{#633121} -- wpt-commits: 22400f9755a49a50632a8f2067cb06bca74efff8 wpt-pr: 15276

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from __future__ import absolute_import, print_function
import json
import os
import shlex
import subprocess
import sys

old_bytecode = sys.dont_write_bytecode
sys.dont_write_bytecode = True

path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'mach'))

# If mach is not here, we're on the objdir go to the srcdir.
if not os.path.exists(path):
    with open(os.path.join(os.path.dirname(__file__), 'mozinfo.json')) as info:
        config = json.loads(info.read())
    path = os.path.join(config['topsrcdir'], 'mach')

sys.dont_write_bytecode = old_bytecode

def _is_likely_cpp_header(filename):
    if not filename.endswith('.h'):
        return False

    if filename.endswith('Inlines.h') or filename.endswith('-inl.h'):
        return True

    cpp_file = filename[:-1] + 'cpp'
    return os.path.exists(cpp_file)

def FlagsForFile(filename):
    output = subprocess.check_output([path, 'compileflags', filename])
    output = output.decode('utf-8')

    flag_list = shlex.split(output)

    # This flag is added by Fennec for android build and causes ycmd to fail to parse the file.
    # Removing this flag is a workaround until ycmd starts to handle this flag properly.
    # https://github.com/Valloric/YouCompleteMe/issues/1490
    final_flags = [x for x in flag_list if not x.startswith('-march=armv')]

    if _is_likely_cpp_header(filename):
        final_flags += ["-x", "c++"]

    return {
        'flags': final_flags,
        'do_cache': True
    }

if __name__ == '__main__':
    print(FlagsForFile(sys.argv[1]))