File: find-files-not-referenced-by-makefile.py

package info (click to toggle)
libreoffice 1%3A7.0.4-4%2Bdeb11u10
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,255,188 kB
  • sloc: cpp: 4,130,031; xml: 364,887; java: 276,583; python: 65,680; ansic: 36,276; perl: 32,034; javascript: 16,964; yacc: 10,836; sh: 10,721; makefile: 9,112; cs: 6,600; objc: 1,972; lex: 1,887; awk: 1,002; pascal: 940; asm: 928; php: 79; csh: 20; sed: 5
file content (53 lines) | stat: -rwxr-xr-x 1,945 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python2

# Look for CXX files that are not referenced by any makefile

import subprocess
import sys

sourceFiles = set()

a = subprocess.Popen("git ls-files", stdout=subprocess.PIPE, shell=True)
with a.stdout as txt:
    for filename in txt:
        if filename.find(".cxx") != -1 \
            and filename.find("precompiled") == -1 \
            and filename.find("/workben") == -1 \
            and not filename.startswith("odk/examples/") \
            and not filename.startswith("bridges/") \
            and not filename.startswith("compilerplugins/") \
            and filename.find("/qa/") == -1 \
            and filename.find("/test/") == -1 \
            and not filename.startswith("testtools/") \
            and not filename.startswith("vcl/") \
            and not filename.startswith("cli_ure/"):
            sourceFiles.add(filename.strip())

a = subprocess.Popen("git ls-files */*.mk", stdout=subprocess.PIPE, shell=True)
with a.stdout as txt:
    for makefilename in txt:
        makefilename = makefilename.strip()
        with open(makefilename, "r") as makefile:
            moduleName = makefilename[:makefilename.find("/")]
            state = 0
            for line in makefile:
                line = line.strip()
                if state == 0 and "_add_exception_objects" in line:
                    state = 1
                elif state == 1 and line != "))":
                    s = line.replace("\\","").replace(")", "").strip()
                    # parse line like: $(call gb_Helper_optional,AVMEDIA,svx/source/sidebar/media/MediaPlaybackPanel) \
                    idx = s.rfind(",")
                    if idx != -1:
                        s = s[idx+1:].strip()
                    sourceFiles.discard(s + ".cxx")
                elif state == 1:
                    state = 0




print "files not listed in makefile"
print "----------------------------"
for x in sorted(sourceFiles):
    print x