.ycm_extra_conf.py
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Thu, 16 Sep 2021 18:56:42 +0000
changeset 659970 e0d283567b5e145a07b2940a54d3d72ab165e7cb
parent 620830 994ae8e4833c90447d91f0e26a718573cff5a514
permissions -rw-r--r--
no bug - Bumping Firefox l10n changesets r=release a=l10n-bump ach -> 26cabbca589371c494110054d6c7743eebfbc52e af -> 101b5616c6c722919d40f16ec96c7fe36094a84e an -> ad869af072ce10e0e6dacb13bdb34435ce83b745 ar -> f98bf2d8c63c09782f090543bd920e74dfaf7df0 ast -> 1a024e9472f6fd36746e8be70ac0cccf0f846446 az -> b8c8bff8fff2d20424428114800143e4fe3b58f5 be -> a60696cfe5b2a1ffb1cc44a01e56b5dcccc91aec bg -> 624cffdd020ab51b39dd160d0d6e031f70d9697d bn -> 8c12895dfd7a118f55f6ebce866da17fdc9417f7 br -> 124e50af4891cd5fcb20fd4fb294b348f2ce0dd8 bs -> 5b773b6e8126d39f562421d11679222766832d8d ca -> 2735af66c37849b9c84a7f24594d89149cdebf2c ca-valencia -> 616541a8b358734fb44e8c69332133e3a6b9eec4 cak -> c194b45e1448bd3c0299d56bcb99a1ef59e2ccde cs -> 36cbda0128bcc791f13b419fd950160d24e647f5 cy -> 926bb87b0dd6b5008d5dbc5c95d940ced7548565 da -> f53d177076972e642480ffa2292a72bc926c8dec de -> 053e574f21daddd696ad3652398a7018b8990440 dsb -> b1e3712bd3fb7f9c193146bd7681df3ad16cb1f8 el -> bcffa9dc9735e715e711681f1411422446af24bf en-CA -> 340bf2650762b0396dead0c4dad3d22e830acb5a en-GB -> 1a4726c9a741cfabfa9144dd16a8b404fe341180 eo -> cc1efb188fa2fd4dbb512addb0de73298a8d10cc es-AR -> 8bb4af1da0829d9ec93ddaae9a87fe788c8e998f es-CL -> a0f995a47609a34b6e84ca9924cc080adc806d8c es-ES -> 1ce6b93bd78a0928986dcf961e0a1ebf0266ece1 es-MX -> 09d264bb51502ff119e3e1358362c7a1bb05e4ad et -> d07d93f91849add19a6289ea706afd4fc8af10e2 eu -> c709f53ef1b8095ecbfe367c1b800e09799f6769 fa -> 44dc58792383a1f128077fae51bdec499bbef17b ff -> 5e7f3778eeef427f57592470e9f4b3706ddfe1b4 fi -> b39a4de72caf7e999cba340b52a1ae3496671613 fr -> 5d26c10c9a7578beb98bab3b2cdeb4fdaf3d2bb5 fy-NL -> ec422bc3ed212b8629cdaf96aa4cae0db174df3c ga-IE -> e68aba6f07d3a5c6741e08c0677dccdb47ad5cf4 gd -> 2c7d652a1637d95a590414f0b541902f4f4bc3c4 gl -> e8218a82373841ae4f8bc451a1211ca918b56f3e gn -> c790186781f820ab117aa4c70a1807ca886f031d gu-IN -> 58a3b334b189ff6ff488a4e3c28bd2b6be149694 he -> b884c74f78712c9e0ba531beac5b3ee1f46ddce8 hi-IN -> c030acf6d448a3f15281b46795196a0bd816399e hr -> 34d76eda67b91f1ee692c6566635580ab147466b hsb -> 563dea94e147acdc289369ef02dd59d804e06ac6 hu -> a182794b00f2623b3ad4f3b2897d2a73cdaa89b6 hy-AM -> ab1a801bcdc1be9bb914c4dfac2cbed6bb8c13f7 ia -> 614eaf63d1f03d707682f28d5fb685f8c77fa860 id -> cf473e8c2f2c789496320ae8a13f81b41e2cf484 is -> b90173d63427ef412ee5c140840d749d9b304fc3 it -> 57c75f3ff9fdd116c1fb28343439be4bf64e2893 ja -> 21db0b2cb6ea43ee8410bc9b82da6ae1620a6731 ja-JP-mac -> 405a0365467fac53e752ce0738db44af6e722fe0 ka -> 5a9a1ec4788a5c07b32895f490e23394b9425c9b kab -> 570abc3c1d7c432e31e7fbec6bbbeb7dc99e7500 kk -> 88de05f1c3ac9c7a05f8165daf2f9df82a4fa690 km -> 80c16e28261ddf75433bf72e202ecbcb0bcc23f4 kn -> b2e8302a41345278445d8375d294957354a0d0cb ko -> c04640226c79da88b9a1deee89680d198967486d lij -> b7f1ddbff1d52e4879b7cf9e9f3305515ad72305 lt -> 1cb92c91c63ee5c33f50fd3b72f2066ff2f3d9dc lv -> 1ef9538fcb641da3f31e04da0fc0d9b4d10f5a29 mk -> bbf041407953216a8499c504783003e76bc96647 mr -> a3f74021068b75ef1f15cdc88124e144a66d609c ms -> 8f7e9c056ebd4baf32bac885803cd8cf118e9b42 my -> 433738aa8b49ea0c466c3d348ca53416ac2ebbbf nb-NO -> 77ed8a9a77c2380e343b3d3826dedf1ece5084e9 ne-NP -> 746d578508bfdefb2cf34a33f84b1454b8cb35c5 nl -> 99c8bdc6ccfcb0cf9f813d7978ea2edc815be5d1 nn-NO -> cdc591f759d678285d400ae6f9b67fb0feb4a194 oc -> 4fdce95555b358f8800b3991d563e5544de8fe05 pa-IN -> 9f0ea1111269f3c7f5b865afb7ecf6ca10604dd1 pl -> cf9d0b0e1c63651066c0dd97f3f0924ff53b2597 pt-BR -> 9910fc50ed302d4ac541c0ea8a1f6dbf1c25b4a6 pt-PT -> da72fb37c0778a9391f3fc9eec0af496f7094275 rm -> f27a34905d2b073d70059c5096dd6195d019a796 ro -> ec1d0e90d9e027e2d43928398d57b64dd31b0b87 ru -> 1e91aed7a8cf29994c82fde9c9398fdb9e5f1f26 sco -> 1e098f589265490eedfb50cc60a4510ad09781a2 si -> 2a0e8de9af9d5052a381eb54c0524d99c284ccfb sk -> ae28153c8b124e6413ac1e5c18e3901ae354d5e2 sl -> 57675e59a33d5b23819e9dcfbfb91315292c5d33 son -> 8b14a8a0fa17d51674facbaa9d4c23b5b6b60783 sq -> a5c02f928f5be824386434232a3b4a3de263c1d9 sv-SE -> e4d07221f52ee026650b002ef5ae9120efe75223 szl -> df5799a912db7790a915e568af90066fc9f51ddb ta -> 58415c2901fd939260e88a5deca8a562f29c68fc te -> ea900a03628675eaa51b201864f6155a08b26392 th -> 0ee01ad2ba3ac982233f02768a2809c167a53531 tl -> 463a35ad99437c5b212a18c9df91f101e7e4df11 tr -> b54277a728565f0557c54523c7ad7a9b4817111c trs -> c3b285c07676a47db638c2e73a520dd4802c3efc uk -> ffc5dfd626dcad64198a3394accc2a847f7b87f5 ur -> cedefb2241559d27f1256a676a26e3c8b63b297d uz -> 12c9bf5b2b5a41b810078edaf7cf67684484a020 vi -> 056227b3bb0edf548bd64d3acdc7cade31f6f117 xh -> dccca2cb8ed0347d307bf329c4311a9594a32de2 zh-CN -> 3853fb7701720a9e2826da543d8a40c7b1e0529b zh-TW -> 11580bc9587d5a6a2f40be1dfca88b116790aaad

# 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 Settings(**kwargs):
    if kwargs["language"] == "cfamily":
        return FlagsForFile(kwargs["filename"])
    # This is useful for generic language server protocols, like rust-analyzer,
    # to discover the right project root instead of guessing based on where the
    # closest Cargo.toml is.
    return {
        "project_directory": ".",
    }


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]))