Reputation: 32202
I'm using X-Code 4.2 and wish to use the VIM editor and clang-complete vim script to do code completion. It works fine if I manually set up the clang-complete configuration to reflect the settings in my X-Code project. To make this work more smoothly I'd like to do the following.
get_compile_options some_src.m
where some_src.m is a valid source file in my XCode project. The output from get_compile_options should be all the build flags that XCode would use to build this into an object file. Any ideas on how to accomplish this.
Upvotes: 2
Views: 1013
Reputation: 3545
I think that I found better solution, you can use xctool.
You can pass path to your xcode project, scheme (target), and get json with compile commands.
$1 = path to .xcodeproj file
$2 = scheme (target)
$3 = path for generated json
#!/bin/bash
XCTOOL_DIR=/Documents/xctool-master #the location of your xctool
$XCTOOL_DIR/xctool.sh -workspace "$1"/project.xcworkspace \
-scheme "$2" \
-reporter json-compilation-database:"$3"/compile_commands.json build
compile_commands.json is json compilation database it has format:
[
{ "directory": "/home/user/llvm/build",
"command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc",
"file": "file.cc" },
...
]
and you can parse it with usual json parsers, also you can use other reporters
Upvotes: 1
Reputation: 575
AFAIK there is no fair method to accomplish this, but you may add special target into Xcode project, disable dsym generation, resources copying, add user-defined option 'CC=<your custom compiler>' where '<your custom compiler>' will be your script which records parameters passed into it. 'some_src.m' will be right after '-c' option. This way you will collect options for each file by compiling your special target. I have successfully used this approach with patched version of clang.
Upvotes: 2