summaryrefslogtreecommitdiff
path: root/.ycm_extra_conf.py
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2015-07-05 16:25:37 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2015-07-05 16:28:58 +0300
commitc15c26eb3d1c3ed70d82f8fd5ad57d80b4839a6b (patch)
treec07b7c4b8f6558810dd40ed35f9c1c17c0d2010d /.ycm_extra_conf.py
parentec93fba84a7ad8440db79e1567dbffd350d5387f (diff)
downloadqtlocation-mapboxgl-c15c26eb3d1c3ed70d82f8fd5ad57d80b4839a6b.tar.gz
Update YCM to support OSX
Besides a couple file path modifiers, we need to manually add the OSX SDK system root path.
Diffstat (limited to '.ycm_extra_conf.py')
-rw-r--r--.ycm_extra_conf.py63
1 files changed, 51 insertions, 12 deletions
diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py
index 2f6dc24594..be5e3a5c1f 100644
--- a/.ycm_extra_conf.py
+++ b/.ycm_extra_conf.py
@@ -80,14 +80,18 @@ def MakeRelativePathsInFlagsAbsolute(flags, working_directory):
return new_flags
+def FlagsForFileDefault():
+ return {
+ 'flags': default_flags,
+ 'do_cache': False,
+ }
+
+
def FlagsForFileLinux(filename):
working_directory = os.path.join('build', 'linux')
if not os.path.exists(os.path.join(DirectoryOfThisScript(), working_directory)):
- return {
- 'flags': default_flags,
- 'do_cache': False,
- }
+ return FlagsForFileDefault()
relative_source_path = filename.replace(DirectoryOfThisScript() + '/', '')
relative_obj_path = os.path.splitext(relative_source_path)[0] + '.o'
@@ -98,10 +102,7 @@ def FlagsForFileLinux(filename):
stdout, stderr = p.communicate()
if p.returncode:
- return {
- 'flags': default_flags,
- 'do_cache': False,
- }
+ return FlagsForFileDefault()
flags = stdout.split(' ')
flags_relative = MakeRelativePathsInFlagsAbsolute(flags, os.path.join(DirectoryOfThisScript(), working_directory))
@@ -113,11 +114,49 @@ def FlagsForFileLinux(filename):
}
+def FlagsForFileDarwin(filename):
+ working_directory = os.path.join('build', 'osx')
+
+ if not os.path.exists(os.path.join(DirectoryOfThisScript(), working_directory)):
+ return FlagsForFileDefault()
+
+ relative_source_path = filename.replace(DirectoryOfThisScript() + '/', '')
+ relative_obj_path = os.path.splitext(relative_source_path)[0] + '.o'
+
+ make_cmd = 'make -pn |grep "%s :=" |grep "NDEBUG" |tail -n 1 | cut -d\' \' -f4-' % relative_obj_path
+
+ p = subprocess.Popen([make_cmd], shell=True, stdout=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+
+ if p.returncode:
+ return FlagsForFileDefault()
+
+ flags = stdout.split(' ')
+ flags_relative = MakeRelativePathsInFlagsAbsolute(flags, os.path.join(DirectoryOfThisScript(), working_directory))
+ flags_final = [flag for flag in flags_relative if flag.startswith("-")]
+
+ # Append OSX sysroot SDK path
+ xcrun_cmd = 'xcrun --show-sdk-path'
+
+ p = subprocess.Popen([xcrun_cmd], shell=True, stdout=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+
+ if p.returncode:
+ return FlagsForFileDefault()
+
+ flags_final.append('-isysroot ' + stdout)
+
+ return {
+ 'flags': flags_final,
+ 'do_cache': True,
+ }
+
+
def FlagsForFile(filename, **kwargs):
if sys.platform.startswith('linux'):
return FlagsForFileLinux(filename)
- return {
- 'flags': default_flags,
- 'do_cache': False,
- }
+ if sys.platform.startswith('darwin'):
+ return FlagsForFileDarwin(filename)
+
+ return FlagsForFileDefault()