gbuild-to-ide prepare for missing file types.

Expanded the parser to understand the new json keys.

Change-Id: I8ff91a9113a7b539a1d85e8ea936555825260ba0
This commit is contained in:
jan Iversen
2017-01-17 19:50:03 +01:00
parent 3674aedb6e
commit 6cd57bc27e

View File

@@ -23,7 +23,7 @@ import collections
import subprocess import subprocess
class GbuildLinkTarget: class GbuildLinkTarget:
def __init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, linked_libs, def __init__(self, name, location, sources, include, include_sys, defs, cxxobjects, cxxflags, linked_libs,
asmobjects, cflags, gencobjects, gencxxobjects, ilibtarget, linked_static_libs, linktarget, asmobjects, cflags, gencobjects, gencxxobjects, ilibtarget, linked_static_libs, linktarget,
objcflags, objcobjects, objcxxflags, objcxxobjects, yaccobjects, build_type): objcflags, objcobjects, objcxxflags, objcxxobjects, yaccobjects, build_type):
(self.name, self.location, self.include, (self.name, self.location, self.include,
@@ -41,6 +41,7 @@ class GbuildLinkTarget:
objcflags, objcobjects, objcxxflags, objcflags, objcobjects, objcxxflags,
objcxxobjects, yaccobjects, build_type) objcxxobjects, yaccobjects, build_type)
self.target_name = self.build_type + '_' + self.name self.target_name = self.build_type + '_' + self.name
self.sources = sources
class GbuildParser: class GbuildParser:
@@ -92,14 +93,12 @@ class GbuildParser:
'GENCXXOBJECTS': '.cxx', # remark is in workdir/GenCxxObject 'GENCXXOBJECTS': '.cxx', # remark is in workdir/GenCxxObject
'OBJCOBJECTS': '.m', 'OBJCOBJECTS': '.m',
'OBJCXXOBJECTS': '.mm', 'OBJCXXOBJECTS': '.mm',
'COBJECTS': '.c',
# gbuildtojson defines but does not fill these:
'ASMOBJECTS': '.s', 'ASMOBJECTS': '.s',
'GENCOBJECTS': '.c',
'YACCOBJECTS': '.y', 'YACCOBJECTS': '.y',
'GENCOBJECTS': '.c',
# gbuildtojson need to be extended to fill these: # not in GbuildLinkTarget
'COBJECTS': '.c',
'FLEXOBJECTS': '.l', 'FLEXOBJECTS': '.l',
'JAVAOBJECTS': '.java', 'JAVAOBJECTS': '.java',
'PYTHONOBJECTS': '.py' 'PYTHONOBJECTS': '.py'
@@ -116,35 +115,36 @@ 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']) location = os.path.dirname(jsondata['MAKEFILE'])
filesSorted = {} sources = {}
for i in jsonSrc: for i in jsonSrc:
if i in jsondata and len(jsondata[i]) > 0: if i in jsondata and len(jsondata[i]) > 0:
filesSorted[i] = sorted(GbuildParser.__split_objs(jsondata[i])) sources[i] = sorted(GbuildParser.__split_objs(jsondata[i]))
else: else:
filesSorted[i] = [] sources[i] = []
# TODO: extend GbuildLinkTarget with new json keys # TODO: extend GbuildLinkTarget with new json keys
# Find a better way instead on a zillion parameters # Find a better way instead on a zillion parameters
newObj = GbuildLinkTarget(match, newObj = GbuildLinkTarget(match,
location, location,
sources,
foundincludes, foundincludes,
foundisystem, foundisystem,
GbuildParser.__split_defs(jsondata['DEFS']), GbuildParser.__split_defs(jsondata['DEFS']),
filesSorted['CXXOBJECTS'], sources['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(' '),
filesSorted['ASMOBJECTS'], sources['ASMOBJECTS'],
GbuildParser.__split_flags(jsondata['CFLAGS'], jsondata['CFLAGSAPPEND']), GbuildParser.__split_flags(jsondata['CFLAGS'], jsondata['CFLAGSAPPEND']),
filesSorted['GENCOBJECTS'], sources['GENCOBJECTS'],
filesSorted['GENCXXOBJECTS'], sources['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']),
filesSorted['OBJCOBJECTS'], sources['OBJCOBJECTS'],
GbuildParser.__split_flags(jsondata['OBJCXXFLAGS'], jsondata['OBJCXXFLAGSAPPEND']), GbuildParser.__split_flags(jsondata['OBJCXXFLAGS'], jsondata['OBJCXXFLAGSAPPEND']),
filesSorted['OBJCXXOBJECTS'], sources['OBJCXXOBJECTS'],
filesSorted['YACCOBJECTS'], sources['YACCOBJECTS'],
jsontype) jsontype)
module = location.split('/')[-1] module = location.split('/')[-1]
if not module in moduleDict: if not module in moduleDict:
@@ -655,8 +655,6 @@ class XcodeIntegrationGenerator(IdeIntegrationGenerator):
self.write_object(key, file, 1) self.write_object(key, file, 1)
file.write(',') file.write(',')
file.write(')') file.write(')')
elif isinstance(object, GbuildLinkTarget):
file.write('""')
def generate_target(self, modulename): def generate_target(self, modulename):