@@ -157,10 +157,18 @@ Here are the steps for a cross-repo indexing setup.
157
157
First, do a recursive clone of the boost monorepo.
158
158
159
159
``` bash
160
+ # Use a Clang-based toolchain to avoid any GCC-specific options being
161
+ # accidentally used.
162
+ sudo apt-get install clang
163
+
160
164
git clone https://github.com/boostorg/boost --recursive
161
165
cd boost
162
166
git checkout boost-1.82.0
163
- cmake -B build -DENABLE_TESTING=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
167
+ git submodule update
168
+ # This will create a b2 binary which will be used for building
169
+ # the code. Bear will then be used to intercept the compilation
170
+ # commands. Not all of Boost's code is buildable using CMake.
171
+ ./bootstrap.sh
164
172
```
165
173
166
174
Invoke the indexer for each project with this Python script:
@@ -185,11 +193,32 @@ with open('package-map.json', 'w') as f:
185
193
json.dump(pmap, f)
186
194
187
195
for d in dirs:
196
+ # Delete any build artifacts so that bear is able to regenerate the compilation database
197
+ subprocess.run([" rm -rf bin.v2" ], shell = True )
198
+ # Skip work if the index was uploaded
188
199
if os.path.isfile(d + " /index.scip" ):
189
200
continue
201
+ if not os.path.isfile(d + " /compile_commands.json" ):
202
+ targets = " "
203
+ if os.path.isfile(d + " /test/Jamfile.v2" ) or os.path.isfile(d + " /test/Jamfile" ):
204
+ targets += " test"
205
+ if os.path.isfile(d + " /example/Jamfile.v2" ) or os.path.isfile(d + " /example/Jamfile" ):
206
+ targets += " example"
207
+ if targets == " " :
208
+ print (" Directory {} doesn't have any targets for b2, skipping" .format(d))
209
+ continue
210
+ print (" Generating compilation database for {} " .format(d))
211
+ # Turn off PCHs as they're used by the math library, but PCHs are not stable
212
+ # across compiler versions, so we'd need to install the exact matching Clang
213
+ # and use that to compile Boost for PCHs to be read correctly.
214
+ #
215
+ # 'pch=off' doesn't seem to be documented anywhere official except for:
216
+ # https://github.com/boostorg/math/issues/619#issuecomment-829333938
217
+ subprocess.run([" bear -- ../../b2 --toolset=clang pch=off" + targets],
218
+ cwd = d, shell = True , capture_output = True )
190
219
print (" Indexing {} " .format(d))
191
- res = subprocess.run([" scip-clang --package-map-path=../../package-map.json --compdb-path=../../build/ compile_commands.json" ], cwd = d, shell = True )
220
+ res = subprocess.run([" scip-clang --package-map-path=../../package-map.json --compdb-path=compile_commands.json" ], cwd = d, shell = True )
192
221
if res.returncode != 0 :
222
+ print (" Indexing failed for {} ; skipping upload" .format(d))
193
223
continue
194
- subprocess.run([" src code-intel upload" ], cwd = d, shell = True , env = {" SRC_ACCESS_TOKEN" : os.getenv(" SRC_ACCESS_TOKEN" ), " PATH" : os.getenv(" PATH" )})
195
224
```
0 commit comments