gbuild-to-ide: moduleDict targets -> all paths replaced with relative

in moduleDict[<module>][<target>] all absolute paths are replaced
with a relative path:
-include/libs relative to core(contained in json) directory
-json objects, makefile, relative to <module> directory

Change-Id: I5dd64942c2a4d6fc2f01037ee7417de91c41906a
Reviewed-on: https://gerrit.libreoffice.org/33506
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: jan iversen <jani@documentfoundation.org>
This commit is contained in:
Federico Bassini
2017-01-24 22:03:27 +01:00
committed by jan iversen
parent 96def52140
commit 92c2c5f62d

View File

@@ -40,15 +40,23 @@ class GbuildParser:
'CppunitTest': re.compile('CppunitTest_(.*)\.mk')} 'CppunitTest': re.compile('CppunitTest_(.*)\.mk')}
_allheaders=[] _allheaders=[]
@staticmethod @staticmethod
def __split_includes(includes): def __split_includes(json_srcdir,includes):
foundisystem = GbuildParser._isystempattern.findall(includes) foundisystem = GbuildParser._isystempattern.findall(includes)
foundincludes = [includeswitch.strip() for includeswitch in GbuildParser._includepattern.findall(includes) if foundincludes=[]
len(includeswitch) > 2] for includeswitch in GbuildParser._includepattern.findall(includes):
if len(includeswitch) > 2:
if includeswitch.strip()[:len(json_srcdir)] == json_srcdir:
foundincludes.append(includeswitch.strip()[len(json_srcdir)+1:])
else:
foundincludes.append(includeswitch.strip())
#foundincludes = [includeswitch.strip()[len(json_srcdir)+1:] for includeswitch in GbuildParser._includepattern.findall(includes) if
# len(includeswitch) > 2]
return (foundincludes, foundisystem) return (foundincludes, foundisystem)
@staticmethod @staticmethod
def __split_objs(objsline): def __split_objs(module,objsline):
return [obj for obj in objsline.strip().split(' ') if len(obj) > 0 and obj != 'CXXOBJECTS' and obj != '+='] return [obj[len(module)+1:] for obj in objsline.strip().split(' ') if len(obj) > 0 and obj != 'CXXOBJECTS' and obj != '+=']
@staticmethod @staticmethod
def __split_defs(defsline): def __split_defs(defsline):
@@ -95,9 +103,12 @@ class GbuildParser:
jsondata = json.load(f) jsondata = json.load(f)
match = GbuildParser._buildpattern[jsontype].match(os.path.basename(jsondata['MAKEFILE'])).group(1) match = GbuildParser._buildpattern[jsontype].match(os.path.basename(jsondata['MAKEFILE'])).group(1)
jsondata['location'] = os.path.dirname(jsondata['MAKEFILE']) jsondata['location'] = os.path.dirname(jsondata['MAKEFILE'])
module = jsondata['location'].split('/')[-1] module = jsondata['location'].split('/')[-1]
(jsondata['include'], jsondata['include_sys']) = GbuildParser.__split_includes(jsondata['INCLUDE']) json_srcdir=jsondata['location'][:-(len(module)+1)]
jsondata['MAKEFILE']=jsondata['MAKEFILE'][len(jsondata['location'])+1:]
jsondata['ILIBTARGET']='../' + jsondata['ILIBTARGET'][len(json_srcdir)+1:]
(jsondata['include'], jsondata['include_sys']) = GbuildParser.__split_includes(json_srcdir, jsondata['INCLUDE'])
jsondata['name'] = match jsondata['name'] = match
jsondata['build_type'] = jsontype jsondata['build_type'] = jsontype
jsondata['target_name'] = module + '_' + jsontype + '_' + match jsondata['target_name'] = module + '_' + jsontype + '_' + match
@@ -106,7 +117,7 @@ class GbuildParser:
for i in ['CXXFLAGS', 'CFLAGS', 'OBJCFLAGS', 'OBJCXXFLAGS']: for i in ['CXXFLAGS', 'CFLAGS', 'OBJCFLAGS', 'OBJCXXFLAGS']:
jsondata[i] = GbuildParser.__split_flags(jsondata[i], jsondata[i+'APPEND']) jsondata[i] = GbuildParser.__split_flags(jsondata[i], jsondata[i+'APPEND'])
for i in jsonSrc: for i in jsonSrc:
jsondata[i] = sorted(GbuildParser.__split_objs(jsondata[i])) jsondata[i] = sorted(GbuildParser.__split_objs(module, jsondata[i]))
if not module in moduleDict: if not module in moduleDict:
moduleDict[module] = {'targets': [],'headers':{}} moduleDict[module] = {'targets': [],'headers':{}}