0

So far, I have managed to operate iwyu on a single cpp file using the following command:

$ include-what-you-use $CXXFLAGS test.cpp

However, now I want to perform analysis on my project. I have written a script in python that selects all cpp and h files in my project:

import os
import shutil

def findF(path, list):
    for files in os.listdir(path):
        tmpPath = os.path.join(path, files)
        if os.path.isdir(tmpPath): #recurse the function if the path is a directory
            findF(tmpPath, list)
        elif os.path.isfile(tmpPath): # find the cpp and h file
            if tmpPath.endswith('.cpp')|tmpPath.endswith('.h'):
                list.append(files)
                #print("cpp file & h file: " + files)

t = []
findF('E:\intern\mrtrix3', t)
print(t)

Now this script will return a list that contains a bunch of file names, for example t=['test1.cpp', 'test2.cpp', 'test3.cpp'.....'test99.cpp']

I wonder how can I apply such list to iwyu so that iwyu can iterates these files, and perform analysis?

I hope my inquiry makes sense. Thank you!

Sibo
  • 11
  • 1
  • 1
    Please make sure that you copy-paste Python code correctly, and that the proper and correct indentation is included in the code. For an indentation-sensitive language like Python that's very important. – Some programmer dude Feb 20 '23 at 07:32
  • Also note that `|` is a ***bitwise*** OR operation, not a logical one. For a logical, boolean OR use `or`. – Some programmer dude Feb 20 '23 at 07:35
  • 1
    I would avoid reinventing the wheel and use e.g. a makefile for this job. It is already really good at doing things that look like compiler calls for a series of files. You even get incremental analysis for almost free. – bitmask Feb 20 '23 at 07:36
  • @Someprogrammerdude thanks for the reminder, first time posting stuff here. sorry about this – Sibo Feb 20 '23 at 07:48
  • just send each file individually to iwyu? – Alan Birtles Feb 20 '23 at 08:16

0 Answers0