Skip to content

Commit d019447

Browse files
authored
Add script to fix include style (AliceO2Group#12033)
1 parent 465be28 commit d019447

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Scripts/format_includes.awk

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/awk -f
2+
3+
# Fix include style.
4+
# NB: Run before sorting.
5+
6+
{
7+
if ($1 ~ /^#include/) {
8+
h = substr($2, 2, length($2) - 2)
9+
if ( h ~ /^(PWG[A-Z]{2}|Common|ALICE3|DPG|EventFiltering|Tools|Tutorials)\/.*\.h/ ) { $2 = "\""h"\"" } # O2Physics
10+
else if ( h ~ /^(Algorithm|CCDB|Common[A-Z]|DataFormats|DCAFitter|Detectors|EMCAL|Field|Framework|FT0|FV0|GlobalTracking|ITS|MathUtils|MFT|MCH|MID|PHOS|PID|ReconstructionDataFormats|SimulationDataFormat|TOF|TPC|ZDC).*\/.*\.h/ ) { $2 = "<"h">" } # O2
11+
else if ( h ~ /^(T[A-Z]|Math\/|Roo[A-Z])[[:alnum:]\/]+\.h/ ) { $2 = "<"h">" } # ROOT
12+
else if ( h ~ /^KF[A-Z][[:alnum:]]+\.h/ ) { $2 = "<"h">" } # KFParticle
13+
else if ( h ~ /^(fastjet\/|onnxruntime)/ ) { $2 = "<"h">" } # FastJet, ONNX
14+
else if ( h ~ /^.*DataModel\// ) { $2 = "\""h"\"" } # incomplete path to DataModel
15+
else if ( h ~ /^([[:alnum:]_]+\/)+[[:alnum:]_]+\.h/ ) { $2 = "<"h">" } # other third-party
16+
else if ( $2 ~ /^".*\./ ) { } # other local-looking file
17+
else if ( h ~ /^[[:lower:]_]+\.h/ ) { $2 = "<"h">" } # C system
18+
else if ( h ~ /^[[:lower:]_\/]+/ ) { $2 = "<"h">" } # C++ system
19+
}
20+
print
21+
}

0 commit comments

Comments
 (0)