Mercurial > codeOptimizer
comparison codeOptimizer.py @ 2:10f1d7de9bc3
New module for reading configurations.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Sun, 16 Sep 2012 21:29:22 +0200 |
| parents | a1224150b8f6 |
| children | f65c2d63ab66 |
comparison
equal
deleted
inserted
replaced
| 1:a1224150b8f6 | 2:10f1d7de9bc3 |
|---|---|
| 2 | 2 |
| 3 import sys | 3 import sys |
| 4 | 4 |
| 5 from Compilable import Compilable | 5 from Compilable import Compilable |
| 6 from DepGraph import DepGraph | 6 from DepGraph import DepGraph |
| 7 from Options import Config | |
| 7 | 8 |
| 8 | 9 |
| 9 | 10 |
| 10 def isHppfile(name): | 11 def isHppfile(name): |
| 11 if name.endswith(".hpp"): | 12 if name.endswith(".hpp"): |
| 17 def isCppfile(name): | 18 def isCppfile(name): |
| 18 if name.endswith(".cpp"): | 19 if name.endswith(".cpp"): |
| 19 return True | 20 return True |
| 20 return False | 21 return False |
| 21 | 22 |
| 22 | 23 try: |
| 23 infiles = sys.argv[1:] | 24 options = Config(sys.argv[1]) |
| 25 except: | |
| 26 print sys.argv[1] + ' is not a valid xml file' | |
| 27 infiles = sys.argv[2:] | |
| 24 | 28 |
| 25 files = {} | 29 files = {} |
| 26 unknown = [] | 30 unknown = [] |
| 27 | 31 |
| 28 flags = '-DHAS_BOOST -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_XML_LIB -DQT_SQL_LIB -O3 -Wall -I/opt/local/include -I/Users/bfg/QtSDK/Desktop/Qt/4.8.1/gcc/include -F/Users/bfg/QtSDK/Desktop/Qt/4.8.1/gcc/lib -I/Users/bfg/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtOpenGL -I/Users/bfg/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtXml -I/Users/bfg/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtSql -I/Users/bfg/projects/dedupe' | |
| 29 | |
| 30 for file in infiles: | 32 for file in infiles: |
| 31 if isHppfile(file) or isCppfile(file): | 33 if isHppfile(file) or isCppfile(file): |
| 32 c = Compilable(file) | 34 c = Compilable(file) |
| 33 c.setFlags(flags) | 35 c.setFlags(options.getCxxflags(file)) |
| 34 files[file] = c | 36 files[file] = c |
| 35 else: | 37 else: |
| 36 unknown.append(file) | 38 unknown.append(file) |
| 37 | 39 |
| 38 if len(unknown) > 0: | 40 if len(unknown) > 0: |
| 50 files = depgraph.directedGraph() | 52 files = depgraph.directedGraph() |
| 51 | 53 |
| 52 for file in files: | 54 for file in files: |
| 53 if not file.worksWithoutModifications(): | 55 if not file.worksWithoutModifications(): |
| 54 print file.path | 56 print file.path |
| 55 raise SystemExit(str.join(file.path) + " does not compile at all") | 57 raise SystemExit(file.path + " does not compile at all") |
| 56 | 58 |
| 57 for file in files: | 59 for file in files: |
| 58 removable = file.removeRemovableIncludes() | 60 removable = file.removeRemovableIncludes() |
| 59 if removable: | 61 if removable: |
| 60 print 'Removable lines in ' + file.path | 62 print 'Removable lines in ' + file.path |
