Skip to content

Commit 41f5b86

Browse files
docs: Update script for indexing boost (#384)
1 parent 4e7e057 commit 41f5b86

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

docs/IndexingProjects.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,18 @@ Here are the steps for a cross-repo indexing setup.
157157
First, do a recursive clone of the boost monorepo.
158158

159159
```bash
160+
# Use a Clang-based toolchain to avoid any GCC-specific options being
161+
# accidentally used.
162+
sudo apt-get install clang
163+
160164
git clone https://github.com/boostorg/boost --recursive
161165
cd boost
162166
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
164172
```
165173

166174
Invoke the indexer for each project with this Python script:
@@ -185,11 +193,32 @@ with open('package-map.json', 'w') as f:
185193
json.dump(pmap, f)
186194

187195
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
188199
if os.path.isfile(d + "/index.scip"):
189200
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)
190219
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)
192221
if res.returncode != 0:
222+
print("Indexing failed for {}; skipping upload".format(d))
193223
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")})
195224
```

0 commit comments

Comments
 (0)