gbuild-to-ide cleanup GbuildParser

Removed .files replaced by
.modules[*]['targets']

Affected generators updated.

Change-Id: I4bf4cb5a23ba0b48b11adb1795c0a4f9dfbb0d3a
This commit is contained in:
jan Iversen
2017-01-14 10:02:28 +01:00
parent b6e6d2d31d
commit 9cb3b064e5

View File

@@ -49,8 +49,7 @@ class GbuildParser:
self.binpath = os.path.dirname(os.environ['GPERF']) # woha, this is quite a hack self.binpath = os.path.dirname(os.environ['GPERF']) # woha, this is quite a hack
(self.srcdir, self.builddir, self.instdir, self.workdir) = (os.environ['SRCDIR'], os.environ['BUILDDIR'], (self.srcdir, self.builddir, self.instdir, self.workdir) = (os.environ['SRCDIR'], os.environ['BUILDDIR'],
os.environ['INSTDIR'], os.environ['WORKDIR']) os.environ['INSTDIR'], os.environ['WORKDIR'])
(self.modules, self.files) = (collections.OrderedDict(), []) (self.modules, self.target_by_path) = (collections.OrderedDict(), collections.OrderedDict())
self.target_by_path = collections.OrderedDict()
_includepattern = re.compile('-I(\S+)') _includepattern = re.compile('-I(\S+)')
_isystempattern = re.compile('-isystem\s*(\S+)') _isystempattern = re.compile('-isystem\s*(\S+)')
@@ -87,6 +86,7 @@ class GbuildParser:
return [cxxflag.strip() for cxxflag in GbuildParser._warningpattern.sub('', '%s %s' % (flagsline, flagslineappend)).split(' ') if len(cxxflag) > 1] return [cxxflag.strip() for cxxflag in GbuildParser._warningpattern.sub('', '%s %s' % (flagsline, flagslineappend)).split(' ') if len(cxxflag) > 1]
def parse(self): def parse(self):
moduleDict = {}
for jsontype in ['Library', 'Executable', 'CppunitTest']: for jsontype in ['Library', 'Executable', 'CppunitTest']:
for jsonfilename in os.listdir(os.path.join(self.workdir, 'GbuildToJson', jsontype)): for jsonfilename in os.listdir(os.path.join(self.workdir, 'GbuildToJson', jsontype)):
with open(os.path.join(self.workdir, 'GbuildToJson', jsontype, jsonfilename), 'r') as f: with open(os.path.join(self.workdir, 'GbuildToJson', jsontype, jsonfilename), 'r') as f:
@@ -94,36 +94,37 @@ class GbuildParser:
(foundincludes, foundisystem) = GbuildParser.__split_includes(jsondata['INCLUDE']) (foundincludes, foundisystem) = GbuildParser.__split_includes(jsondata['INCLUDE'])
match = GbuildParser._buildpattern[jsontype].match(os.path.basename(jsondata['MAKEFILE'])).group(1) match = GbuildParser._buildpattern[jsontype].match(os.path.basename(jsondata['MAKEFILE'])).group(1)
location = os.path.dirname(jsondata['MAKEFILE'])
newObj = GbuildLinkTarget(match, newObj = GbuildLinkTarget(match,
os.path.dirname(jsondata['MAKEFILE']), location,
foundincludes, foundincludes,
foundisystem, foundisystem,
GbuildParser.__split_defs(jsondata['DEFS']), GbuildParser.__split_defs(jsondata['DEFS']),
GbuildParser.__split_objs(jsondata['CXXOBJECTS']), sorted(GbuildParser.__split_objs(jsondata['CXXOBJECTS'])),
GbuildParser.__split_flags(jsondata['CXXFLAGS'], jsondata['CXXFLAGSAPPEND']), GbuildParser.__split_flags(jsondata['CXXFLAGS'], jsondata['CXXFLAGSAPPEND']),
jsondata['LINKED_LIBS'].strip().split(' '), jsondata['LINKED_LIBS'].strip().split(' '),
jsondata['ASMOBJECTS'], sorted(jsondata['ASMOBJECTS']),
GbuildParser.__split_flags(jsondata['CFLAGS'], jsondata['CFLAGSAPPEND']), GbuildParser.__split_flags(jsondata['CFLAGS'], jsondata['CFLAGSAPPEND']),
jsondata['GENCOBJECTS'], sorted(jsondata['GENCOBJECTS']),
jsondata['GENCXXOBJECTS'], sorted(jsondata['GENCXXOBJECTS']),
jsondata['ILIBTARGET'], jsondata['ILIBTARGET'],
jsondata['LINKED_STATIC_LIBS'], jsondata['LINKED_STATIC_LIBS'],
jsondata['LINKTARGET'], jsondata['LINKTARGET'],
GbuildParser.__split_flags(jsondata['OBJCFLAGS'], jsondata['OBJCFLAGSAPPEND']), GbuildParser.__split_flags(jsondata['OBJCFLAGS'], jsondata['OBJCFLAGSAPPEND']),
jsondata['OBJCOBJECTS'], sorted(jsondata['OBJCOBJECTS']),
GbuildParser.__split_flags(jsondata['OBJCXXFLAGS'], jsondata['OBJCXXFLAGSAPPEND']), GbuildParser.__split_flags(jsondata['OBJCXXFLAGS'], jsondata['OBJCXXFLAGSAPPEND']),
jsondata['OBJCXXOBJECTS'], sorted(jsondata['OBJCXXOBJECTS']),
jsondata['YACCOBJECTS'], sorted(jsondata['YACCOBJECTS']),
jsontype) jsontype)
self.files.append(newObj) module = location.split('/')[-1]
moduleDict = {}
for target in self.files:
module = target.location.split('/')[-1]
if not module in moduleDict: if not module in moduleDict:
moduleDict[module] = {'targets': set()} moduleDict[module] = {'targets': set()}
moduleDict[module]['targets'] |= set([target]) moduleDict[module]['targets'] |= set([newObj])
for module in sorted(moduleDict):
self.modules[module] = moduleDict[module]
for m in self.modules:
for target in self.modules[m]['targets']:
for cxx in target.cxxobjects: for cxx in target.cxxobjects:
path = '/'.join(cxx.split('/')[:-1]) path = '/'.join(cxx.split('/')[:-1])
if path not in self.target_by_path: if path not in self.target_by_path:
@@ -134,8 +135,6 @@ class GbuildParser:
if path != '' and len(set(self.target_by_path[path])) > 1: if path != '' and len(set(self.target_by_path[path])) > 1:
print('fdo#70422: multiple target use dir %s: %s' % ( print('fdo#70422: multiple target use dir %s: %s' % (
path, ', '.join([target.target_name for target in set(self.target_by_path[path])]))) path, ', '.join([target.target_name for target in set(self.target_by_path[path])])))
for module in sorted(moduleDict):
self.modules[module] = moduleDict[module]
return self return self
@@ -273,15 +272,15 @@ class DebugIntegrationGenerator(IdeIntegrationGenerator):
def emit(self): def emit(self):
print(self.gbuildparser.srcdir) print(self.gbuildparser.srcdir)
print(self.gbuildparser.builddir) print(self.gbuildparser.builddir)
for f in self.gbuildparser.files: for f in self.gbuildparser.modules:
print(f) for j in self.gbuildparser.modules[f]['targets']:
print(j)
VisualStudioIntegrationGenerator(self.gbuildparser, self.ide).emit() VisualStudioIntegrationGenerator(self.gbuildparser, self.ide).emit()
XcodeIntegrationGenerator(self.gbuildparser, self.ide).emit() XcodeIntegrationGenerator(self.gbuildparser, self.ide).emit()
EclipseCDTIntegrationGenerator(self.gbuildparser, self.ide).emit() EclipseCDTIntegrationGenerator(self.gbuildparser, self.ide).emit()
KdevelopIntegrationGenerator(self.gbuildparser, self.ide).emit() KdevelopIntegrationGenerator(self.gbuildparser, self.ide).emit()
VisualStudioIntegrationGenerator(self.gbuildparser, self.ide).emit()
VimIntegrationGenerator(self.gbuildparser, self.ide).emit() VimIntegrationGenerator(self.gbuildparser, self.ide).emit()
QtCreatorIntegrationGenerator(self.gbuildparser, self.ide).emit() QtCreatorIntegrationGenerator(self.gbuildparser, self.ide).emit()
@@ -293,7 +292,8 @@ class VimIntegrationGenerator(IdeIntegrationGenerator):
def emit(self): def emit(self):
global_list = [] global_list = []
for lib in self.gbuildparser.files: for m in self.gbuildparser.modules:
for lib in self.gbuildparser.modules[m]['targets']:
entries = [] entries = []
for file in lib.cxxobjects: for file in lib.cxxobjects:
filePath = os.path.join(self.gbuildparser.srcdir, file) + ".cxx" filePath = os.path.join(self.gbuildparser.srcdir, file) + ".cxx"
@@ -1018,7 +1018,8 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
def __init__(self, gbuildparser, ide): def __init__(self, gbuildparser, ide):
IdeIntegrationGenerator.__init__(self, gbuildparser, ide) IdeIntegrationGenerator.__init__(self, gbuildparser, ide)
self.target_by_location = {} self.target_by_location = {}
for target in self.gbuildparser.files: for m in self.gbuildparser.modules:
for target in self.gbuildparser.modules[m]['targets']:
if target.location not in self.target_by_location: if target.location not in self.target_by_location:
self.target_by_location[target.location] = set() self.target_by_location[target.location] = set()
self.target_by_location[target.location] |= set([target]) self.target_by_location[target.location] |= set([target])
@@ -1474,7 +1475,10 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
self.data_libs = {} self.data_libs = {}
all_libs = self.gbuildparser.files all_libs = []
for m in self.gbuildparser.modules:
for f in self.gbuildparser.modules[m]['targets']:
all_libs.append(f)
for lib in all_libs: for lib in all_libs:
self._log("\nlibrary : %s, loc=%s" % (lib.target_name, lib.location)) self._log("\nlibrary : %s, loc=%s" % (lib.target_name, lib.location))
lib_name = os.path.basename(lib.location) lib_name = os.path.basename(lib.location)