gbuild-to-ide clean replaced GbuildLinkTarget with dict
The class GbuildLinkTarget was removed and replaced by a dict. This is first step in avoiding typing the json key names multiple times Change-Id: I3a2006979929c5d21549693e51eb47df7233400d
This commit is contained in:
@@ -22,26 +22,6 @@ import traceback
|
|||||||
import collections
|
import collections
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
class GbuildLinkTarget:
|
|
||||||
def __init__(self, name, location, sources, include, include_sys, defs, cxxobjects, cxxflags, linked_libs,
|
|
||||||
asmobjects, cflags, gencobjects, gencxxobjects, ilibtarget, linked_static_libs, linktarget,
|
|
||||||
objcflags, objcobjects, objcxxflags, objcxxobjects, yaccobjects, build_type):
|
|
||||||
(self.name, self.location, self.include,
|
|
||||||
self.include_sys, self.defs, self.cxxobjects,
|
|
||||||
self.cxxflags, self.linked_libs,
|
|
||||||
self.asmobjects, self.cflags, self.gencobjects,
|
|
||||||
self.gencxxobjects, self.ilibtarget, self.linked_static_libs,
|
|
||||||
self.linktarget, self.objcflags, self.objcobjects,
|
|
||||||
self.objcxxflags, self.objcxxobjects, self.yaccobjects,
|
|
||||||
self.build_type) = (name, location, include,
|
|
||||||
include_sys, defs, cxxobjects,
|
|
||||||
cxxflags, linked_libs, asmobjects,
|
|
||||||
cflags, gencobjects, gencxxobjects,
|
|
||||||
ilibtarget, linked_static_libs, linktarget,
|
|
||||||
objcflags, objcobjects, objcxxflags,
|
|
||||||
objcxxobjects, yaccobjects, build_type)
|
|
||||||
self.target_name = self.build_type + '_' + self.name
|
|
||||||
self.sources = sources
|
|
||||||
|
|
||||||
|
|
||||||
class GbuildParser:
|
class GbuildParser:
|
||||||
@@ -96,8 +76,6 @@ class GbuildParser:
|
|||||||
'ASMOBJECTS': '.s',
|
'ASMOBJECTS': '.s',
|
||||||
'YACCOBJECTS': '.y',
|
'YACCOBJECTS': '.y',
|
||||||
'GENCOBJECTS': '.c',
|
'GENCOBJECTS': '.c',
|
||||||
|
|
||||||
# not in GbuildLinkTarget
|
|
||||||
'COBJECTS': '.c',
|
'COBJECTS': '.c',
|
||||||
'FLEXOBJECTS': '.l',
|
'FLEXOBJECTS': '.l',
|
||||||
'JAVAOBJECTS': '.java',
|
'JAVAOBJECTS': '.java',
|
||||||
@@ -115,41 +93,31 @@ 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'])
|
||||||
sources = {}
|
|
||||||
for i in jsonSrc:
|
|
||||||
if i in jsondata and len(jsondata[i]) > 0:
|
|
||||||
sources[i] = sorted(GbuildParser.__split_objs(jsondata[i]))
|
|
||||||
else:
|
|
||||||
sources[i] = []
|
|
||||||
|
|
||||||
# TODO: extend GbuildLinkTarget with new json keys
|
# build Central data object (holds all json information is a easy accessible form
|
||||||
# Find a better way instead on a zillion parameters
|
obj = {'name' : match,
|
||||||
newObj = GbuildLinkTarget(match,
|
'location' : location,
|
||||||
location,
|
'include' : foundincludes,
|
||||||
sources,
|
'include_sys' : foundisystem,
|
||||||
foundincludes,
|
'defs' : GbuildParser.__split_defs(jsondata['DEFS']),
|
||||||
foundisystem,
|
'cxxflags' : GbuildParser.__split_flags(jsondata['CXXFLAGS'], jsondata['CXXFLAGSAPPEND']),
|
||||||
GbuildParser.__split_defs(jsondata['DEFS']),
|
'linked_libs' : jsondata['LINKED_LIBS'].strip().split(' '),
|
||||||
sources['CXXOBJECTS'],
|
'cflags' : GbuildParser.__split_flags(jsondata['CFLAGS'], jsondata['CFLAGSAPPEND']),
|
||||||
GbuildParser.__split_flags(jsondata['CXXFLAGS'], jsondata['CXXFLAGSAPPEND']),
|
'ilibtarget' : jsondata['ILIBTARGET'],
|
||||||
jsondata['LINKED_LIBS'].strip().split(' '),
|
'linked_static_libs' : jsondata['LINKED_STATIC_LIBS'],
|
||||||
sources['ASMOBJECTS'],
|
'linktarget' : jsondata['LINKTARGET'],
|
||||||
GbuildParser.__split_flags(jsondata['CFLAGS'], jsondata['CFLAGSAPPEND']),
|
'objcflags' : GbuildParser.__split_flags(jsondata['OBJCFLAGS'], jsondata['OBJCFLAGSAPPEND']),
|
||||||
sources['GENCOBJECTS'],
|
'objcxxflags': GbuildParser.__split_flags(jsondata['OBJCXXFLAGS'], jsondata['OBJCXXFLAGSAPPEND']),
|
||||||
sources['GENCXXOBJECTS'],
|
'build_type' : jsontype,
|
||||||
jsondata['ILIBTARGET'],
|
'target_name' : jsontype + '_' + match
|
||||||
jsondata['LINKED_STATIC_LIBS'],
|
}
|
||||||
jsondata['LINKTARGET'],
|
for i in jsonSrc:
|
||||||
GbuildParser.__split_flags(jsondata['OBJCFLAGS'], jsondata['OBJCFLAGSAPPEND']),
|
obj[i] = sorted(GbuildParser.__split_objs(jsondata[i]))
|
||||||
sources['OBJCOBJECTS'],
|
|
||||||
GbuildParser.__split_flags(jsondata['OBJCXXFLAGS'], jsondata['OBJCXXFLAGSAPPEND']),
|
|
||||||
sources['OBJCXXOBJECTS'],
|
|
||||||
sources['YACCOBJECTS'],
|
|
||||||
jsontype)
|
|
||||||
module = location.split('/')[-1]
|
module = location.split('/')[-1]
|
||||||
if not module in moduleDict:
|
if not module in moduleDict:
|
||||||
moduleDict[module] = {'targets': set(),'headers':{}}
|
moduleDict[module] = {'targets': [],'headers':{}}
|
||||||
moduleDict[module]['targets'] |= set([newObj])
|
moduleDict[module]['targets'].append(obj)
|
||||||
moduleDict[module]['headers'] =self.headers_of(module)
|
moduleDict[module]['headers'] =self.headers_of(module)
|
||||||
|
|
||||||
|
|
||||||
@@ -204,10 +172,10 @@ class EclipseCDTIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
for lib in self.target_path.keys():
|
for lib in self.target_path.keys():
|
||||||
if lib.startswith(module+'/'):
|
if lib.startswith(module+'/'):
|
||||||
modulelibs.append(lib)
|
modulelibs.append(lib)
|
||||||
include = set()
|
include = []
|
||||||
for lib in modulelibs:
|
for lib in modulelibs:
|
||||||
for target in self.target_path[lib]:
|
for target in self.target_path[lib]:
|
||||||
include |= set(target.include)
|
include.extend(target[0]['include'])
|
||||||
includedirfile.write('\n'.join(include))
|
includedirfile.write('\n'.join(include))
|
||||||
includedirfile.close()
|
includedirfile.close()
|
||||||
|
|
||||||
@@ -226,8 +194,8 @@ class EclipseCDTIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
defineset = set()
|
defineset = set()
|
||||||
for lib in modulelibs:
|
for lib in modulelibs:
|
||||||
for target in self.target_path[lib]:
|
for target in self.target_path[lib]:
|
||||||
for i in target.defs.keys():
|
for i in target[0]['defs'].keys():
|
||||||
tmp = str(i) +','+str(target.defs[i])
|
tmp = str(i) +','+str(target[0]['defs'][i])
|
||||||
if tmp not in defineset:
|
if tmp not in defineset:
|
||||||
defineset.add(tmp)
|
defineset.add(tmp)
|
||||||
macrofile.write('\n'.join(defineset))
|
macrofile.write('\n'.join(defineset))
|
||||||
@@ -314,11 +282,11 @@ class EclipseCDTIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
if m == 'include':
|
if m == 'include':
|
||||||
continue
|
continue
|
||||||
for target in self.gbuildparser.modules[m]['targets']:
|
for target in self.gbuildparser.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_path:
|
if path not in self.target_path:
|
||||||
self.target_path[path] = set()
|
self.target_path[path] = []
|
||||||
self.target_path[path] |= set([target])
|
self.target_path[path].append([target])
|
||||||
self.create_include_path()
|
self.create_include_path()
|
||||||
self.create_macros()
|
self.create_macros()
|
||||||
self.create_settings_file()
|
self.create_settings_file()
|
||||||
@@ -354,9 +322,9 @@ class VimIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
for m in self.gbuildparser.modules:
|
for m in self.gbuildparser.modules:
|
||||||
for lib in self.gbuildparser.modules[m]['targets']:
|
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"
|
||||||
entry = {'directory': lib.location, 'file': filePath, 'command': self.generateCommand(lib, filePath)}
|
entry = {'directory': lib['location'], 'file': filePath, 'command': self.generateCommand(lib, filePath)}
|
||||||
entries.append(entry)
|
entries.append(entry)
|
||||||
global_list.extend(entries)
|
global_list.extend(entries)
|
||||||
export_file = open('compile_commands.json', 'w')
|
export_file = open('compile_commands.json', 'w')
|
||||||
@@ -364,7 +332,7 @@ class VimIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
|
|
||||||
def generateCommand(self, lib, file):
|
def generateCommand(self, lib, file):
|
||||||
command = 'clang++ -Wall'
|
command = 'clang++ -Wall'
|
||||||
for key, value in lib.defs.items():
|
for key, value in lib['defs'].items():
|
||||||
command += ' -D'
|
command += ' -D'
|
||||||
command += key
|
command += key
|
||||||
if value is not None:
|
if value is not None:
|
||||||
@@ -375,13 +343,13 @@ class VimIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
# one is not the same for all source files in the lib.
|
# one is not the same for all source files in the lib.
|
||||||
command += ' -I' + os.path.dirname(file)
|
command += ' -I' + os.path.dirname(file)
|
||||||
|
|
||||||
for include in lib.include:
|
for include in lib['include']:
|
||||||
command += ' -I'
|
command += ' -I'
|
||||||
command += include
|
command += include
|
||||||
for isystem in lib.include_sys:
|
for isystem in lib['include_sys']:
|
||||||
command += ' -isystem '
|
command += ' -isystem '
|
||||||
command += isystem
|
command += isystem
|
||||||
for cxxflag in lib.cxxflags:
|
for cxxflag in lib['cxxflags']:
|
||||||
command += ' '
|
command += ' '
|
||||||
command += cxxflag
|
command += cxxflag
|
||||||
command += ' -c '
|
command += ' -c '
|
||||||
@@ -534,7 +502,7 @@ VersionControl=kdevgit
|
|||||||
includedirfile = open(os.path.join(path, '.kdev_include_paths'), 'w')
|
includedirfile = open(os.path.join(path, '.kdev_include_paths'), 'w')
|
||||||
include = set()
|
include = set()
|
||||||
for target in self.target_path[path]:
|
for target in self.target_path[path]:
|
||||||
include |= set(target.include)
|
include |= set(target['include'])
|
||||||
includedirfile.write('\n'.join(include))
|
includedirfile.write('\n'.join(include))
|
||||||
includedirfile.close()
|
includedirfile.close()
|
||||||
|
|
||||||
@@ -545,11 +513,11 @@ VersionControl=kdevgit
|
|||||||
self.target_path = {}
|
self.target_path = {}
|
||||||
for m in self.gbuildparser.modules:
|
for m in self.gbuildparser.modules:
|
||||||
for target in self.gbuildparser.modules[m]['targets']:
|
for target in self.gbuildparser.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_path:
|
if path not in self.target_path:
|
||||||
self.target_path[path] = set()
|
self.target_path[path] = []
|
||||||
self.target_path[path] |= set([target])
|
self.target_path[path].append(target)
|
||||||
|
|
||||||
for path in self.target_path:
|
for path in self.target_path:
|
||||||
self.write_includepaths(path)
|
self.write_includepaths(path)
|
||||||
@@ -664,24 +632,24 @@ class XcodeIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
|
|
||||||
|
|
||||||
def generate_target(self, modulename):
|
def generate_target(self, modulename):
|
||||||
if modulename.build_type == 'Library':
|
if modulename['build_type'] == 'Library':
|
||||||
product = 'com.apple.product-type.library.dynamic'
|
product = 'com.apple.product-type.library.dynamic'
|
||||||
elif modulename.build_type == 'Executable':
|
elif modulename['build_type'] == 'Executable':
|
||||||
product = 'com.apple.product-type.executable'
|
product = 'com.apple.product-type.executable'
|
||||||
elif modulename.build_type == 'CppunitTest':
|
elif modulename['build_type'] == 'CppunitTest':
|
||||||
product = 'com.apple.product-type.cppunit'
|
product = 'com.apple.product-type.cppunit'
|
||||||
else:
|
else:
|
||||||
product = 'com.apple.product-type.something'
|
product = 'com.apple.product-type.something'
|
||||||
|
|
||||||
result = {'isa': 'PBXLegacyTarget',
|
result = {'isa': 'PBXLegacyTarget',
|
||||||
'buildConfigurationList': self.configurationListId,
|
'buildConfigurationList': self.configurationListId,
|
||||||
'buildArgumentsString': modulename.target_name,
|
'buildArgumentsString': modulename['target_name'],
|
||||||
'buildPhases': [],
|
'buildPhases': [],
|
||||||
'dependencies': [],
|
'dependencies': [],
|
||||||
'buildToolPath': 'make',
|
'buildToolPath': 'make',
|
||||||
'buildWorkingDirectory': self.gbuildparser.builddir,
|
'buildWorkingDirectory': self.gbuildparser.builddir,
|
||||||
'name': modulename.target_name,
|
'name': modulename['target_name'],
|
||||||
'productName': modulename.name,
|
'productName': modulename['name'],
|
||||||
'passBuildSettingsEnvironment': 1}
|
'passBuildSettingsEnvironment': 1}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -729,7 +697,7 @@ class XcodeIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
'ONLY_ACTIVE_ARCH': 'YES',
|
'ONLY_ACTIVE_ARCH': 'YES',
|
||||||
'PRODUCT_NAME': '$(TARGET_NAME)',
|
'PRODUCT_NAME': '$(TARGET_NAME)',
|
||||||
'SDKROOT': 'macosx',
|
'SDKROOT': 'macosx',
|
||||||
'HEADER_SEARCH_PATHS': modulename.include},
|
'HEADER_SEARCH_PATHS': modulename['include']},
|
||||||
'name': 'Debug'}
|
'name': 'Debug'}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -744,7 +712,7 @@ class XcodeIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
self.sourceRefList = {}
|
self.sourceRefList = {}
|
||||||
self.sourceList = {}
|
self.sourceList = {}
|
||||||
|
|
||||||
for i in module.cxxobjects:
|
for i in module['CXXOBJECTS']:
|
||||||
ref = self.generate_id()
|
ref = self.generate_id()
|
||||||
self.sourceList[self.generate_id()] = ref
|
self.sourceList[self.generate_id()] = ref
|
||||||
self.sourceRefList[ref] = {'lastKnownFileType': 'sourcecode.cpp.cpp',
|
self.sourceRefList[ref] = {'lastKnownFileType': 'sourcecode.cpp.cpp',
|
||||||
@@ -827,7 +795,7 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
module_directory = os.path.join(self.solution_directory, module)
|
module_directory = os.path.join(self.solution_directory, module)
|
||||||
if module != 'include': #FIXME
|
if module != 'include': #FIXME
|
||||||
for target in self.gbuildparser.modules[module]['targets']:
|
for target in self.gbuildparser.modules[module]['targets']:
|
||||||
project_path = os.path.join(module_directory, '%s.vcxproj' % target.target_name)
|
project_path = os.path.join(module_directory, '%s.vcxproj' % target['target_name'])
|
||||||
project_guid = self.write_project(project_path, target)
|
project_guid = self.write_project(project_path, target)
|
||||||
p = VisualStudioIntegrationGenerator.Project(project_guid, target, project_path)
|
p = VisualStudioIntegrationGenerator.Project(project_guid, target, project_path)
|
||||||
projects.append(p)
|
projects.append(p)
|
||||||
@@ -842,24 +810,23 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
dependency_libs = {}
|
dependency_libs = {}
|
||||||
for linked_lib in linked_libs:
|
for linked_lib in linked_libs:
|
||||||
for library_project in library_projects:
|
for library_project in library_projects:
|
||||||
if library_project.target.name == linked_lib:
|
if library_project.target['name'] == linked_lib:
|
||||||
dependency_libs[library_project.guid] = library_project
|
dependency_libs[library_project.guid] = library_project
|
||||||
return dependency_libs
|
return dependency_libs
|
||||||
|
|
||||||
def write_solution(self, solution_path, projects):
|
def write_solution(self, solution_path, projects):
|
||||||
print('Solution %s:' % os.path.splitext(os.path.basename(solution_path))[0], end='')
|
print('Solution %s:' % os.path.splitext(os.path.basename(solution_path))[0], end='')
|
||||||
library_projects = [project for project in projects if project.target.build_type == 'Library']
|
library_projects = [project for project in projects if project.target['build_type'] == 'Library']
|
||||||
with open(solution_path, 'w') as f:
|
with open(solution_path, 'w') as f:
|
||||||
f.write('Microsoft Visual Studio Solution File, Format Version 12.00\n')
|
f.write('Microsoft Visual Studio Solution File, Format Version 12.00\n')
|
||||||
for project in projects:
|
for project in projects:
|
||||||
target = project.target
|
target = project.target
|
||||||
print(' %s' % target.target_name, end='')
|
print(' %s' % target['target_name'], end='')
|
||||||
proj_path = os.path.relpath(project.path, os.path.abspath(os.path.dirname(solution_path)))
|
proj_path = os.path.relpath(project.path, os.path.abspath(os.path.dirname(solution_path)))
|
||||||
f.write('Project("{%s}") = "%s", "%s", "{%s}"\n' %
|
f.write('Project("{%s}") = "%s", "%s", "{%s}"\n' %
|
||||||
(VisualStudioIntegrationGenerator.nmake_project_guid,
|
(VisualStudioIntegrationGenerator.nmake_project_guid,
|
||||||
target.target_name, proj_path, project.guid))
|
target['target_name'], proj_path, project.guid))
|
||||||
libs_in_solution = self.get_dependency_libs(target.linked_libs,
|
libs_in_solution = self.get_dependency_libs(target['linked_libs'], library_projects)
|
||||||
library_projects)
|
|
||||||
if libs_in_solution:
|
if libs_in_solution:
|
||||||
f.write('\tProjectSection(ProjectDependencies) = postProject\n')
|
f.write('\tProjectSection(ProjectDependencies) = postProject\n')
|
||||||
for lib_guid in libs_in_solution.keys():
|
for lib_guid in libs_in_solution.keys():
|
||||||
@@ -910,7 +877,7 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
proj_keyword_node = ET.SubElement(globals_node, '{%s}Keyword' % ns)
|
proj_keyword_node = ET.SubElement(globals_node, '{%s}Keyword' % ns)
|
||||||
proj_keyword_node.text = 'MakeFileProj'
|
proj_keyword_node.text = 'MakeFileProj'
|
||||||
proj_name_node = ET.SubElement(globals_node, '{%s}ProjectName' % ns)
|
proj_name_node = ET.SubElement(globals_node, '{%s}ProjectName' % ns)
|
||||||
proj_name_node.text = target.target_name
|
proj_name_node.text = target['target_name']
|
||||||
|
|
||||||
ET.SubElement(proj_node, '{%s}Import' % ns, Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props')
|
ET.SubElement(proj_node, '{%s}Import' % ns, Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props')
|
||||||
for configuration in self.configurations:
|
for configuration in self.configurations:
|
||||||
@@ -940,9 +907,9 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
nmake_params = {
|
nmake_params = {
|
||||||
'sh': os.path.join(self.gbuildparser.binpath, 'dash.exe'),
|
'sh': os.path.join(self.gbuildparser.binpath, 'dash.exe'),
|
||||||
'builddir': self.gbuildparser.builddir,
|
'builddir': self.gbuildparser.builddir,
|
||||||
'location': target.location,
|
'location': target['location'],
|
||||||
'makecmd': self.gbuildparser.makecmd,
|
'makecmd': self.gbuildparser.makecmd,
|
||||||
'target': target.target_name}
|
'target': target['target_name']}
|
||||||
nmake_build_node = ET.SubElement(conf_node, '{%s}NMakeBuildCommandLine' % ns)
|
nmake_build_node = ET.SubElement(conf_node, '{%s}NMakeBuildCommandLine' % ns)
|
||||||
nmake_build_node.text = cfg_targets['build'] % nmake_params
|
nmake_build_node.text = cfg_targets['build'] % nmake_params
|
||||||
nmake_clean_node = ET.SubElement(conf_node, '{%s}NMakeCleanCommandLine' % ns)
|
nmake_clean_node = ET.SubElement(conf_node, '{%s}NMakeCleanCommandLine' % ns)
|
||||||
@@ -952,23 +919,23 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
nmake_output_node = ET.SubElement(conf_node, '{%s}NMakeOutput' % ns)
|
nmake_output_node = ET.SubElement(conf_node, '{%s}NMakeOutput' % ns)
|
||||||
nmake_output_node.text = os.path.join(self.gbuildparser.instdir, 'program', 'soffice.exe')
|
nmake_output_node.text = os.path.join(self.gbuildparser.instdir, 'program', 'soffice.exe')
|
||||||
nmake_defs_node = ET.SubElement(conf_node, '{%s}NMakePreprocessorDefinitions' % ns)
|
nmake_defs_node = ET.SubElement(conf_node, '{%s}NMakePreprocessorDefinitions' % ns)
|
||||||
nmake_defs_node.text = ';'.join(list(target.defs) + ['$(NMakePreprocessorDefinitions)'])
|
nmake_defs_node.text = ';'.join(list(target['defs']) + ['$(NMakePreprocessorDefinitions)'])
|
||||||
include_path_node = ET.SubElement(conf_node, '{%s}IncludePath' % ns)
|
include_path_node = ET.SubElement(conf_node, '{%s}IncludePath' % ns)
|
||||||
include_path_node.text = ';'.join(target.include + ['$(IncludePath)'])
|
include_path_node.text = ';'.join(target['include'] + ['$(IncludePath)'])
|
||||||
|
|
||||||
ET.SubElement(proj_node, '{%s}ItemDefinitionGroup' % ns)
|
ET.SubElement(proj_node, '{%s}ItemDefinitionGroup' % ns)
|
||||||
|
|
||||||
cxxobjects_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns)
|
cxxobjects_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns)
|
||||||
for cxxobject in target.cxxobjects:
|
for cxxobject in target['CXXOBJECTS']:
|
||||||
cxxabspath = os.path.join(self.gbuildparser.srcdir, cxxobject)
|
cxxabspath = os.path.join(self.gbuildparser.srcdir, cxxobject)
|
||||||
cxxfile = cxxabspath + '.cxx'
|
cxxfile = cxxabspath + '.cxx'
|
||||||
if os.path.isfile(cxxfile):
|
if os.path.isfile(cxxfile):
|
||||||
ET.SubElement(cxxobjects_node, '{%s}ClCompile' % ns, Include=cxxfile)
|
ET.SubElement(cxxobjects_node, '{%s}ClCompile' % ns, Include=cxxfile)
|
||||||
else:
|
else:
|
||||||
print('Source %s in project %s does not exist' % (cxxfile, target.target_name))
|
print('Source %s in project %s does not exist' % (cxxfile, target['target_name']))
|
||||||
|
|
||||||
includes_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns)
|
includes_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns)
|
||||||
for cxxobject in target.cxxobjects:
|
for cxxobject in target['CXXOBJECTS']:
|
||||||
include_abs_path = os.path.join(self.gbuildparser.srcdir, cxxobject)
|
include_abs_path = os.path.join(self.gbuildparser.srcdir, cxxobject)
|
||||||
hxxfile = include_abs_path + '.hxx'
|
hxxfile = include_abs_path + '.hxx'
|
||||||
if os.path.isfile(hxxfile):
|
if os.path.isfile(hxxfile):
|
||||||
@@ -981,7 +948,7 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
ET.SubElement(proj_node, '{%s}ImportGroup' % ns, Label='ExtensionTargets')
|
ET.SubElement(proj_node, '{%s}ImportGroup' % ns, Label='ExtensionTargets')
|
||||||
self.write_pretty_xml(proj_node, project_path)
|
self.write_pretty_xml(proj_node, project_path)
|
||||||
self.write_filters(project_path + '.filters',
|
self.write_filters(project_path + '.filters',
|
||||||
os.path.join(self.gbuildparser.srcdir, os.path.basename(target.location)),
|
os.path.join(self.gbuildparser.srcdir, os.path.basename(target['location'])),
|
||||||
[cxx_node.get('Include') for cxx_node in cxxobjects_node.findall('{%s}ClCompile' % ns)],
|
[cxx_node.get('Include') for cxx_node in cxxobjects_node.findall('{%s}ClCompile' % ns)],
|
||||||
[include_node.get('Include') for include_node in includes_node.findall('{%s}ClInclude' % ns)])
|
[include_node.get('Include') for include_node in includes_node.findall('{%s}ClInclude' % ns)])
|
||||||
return project_guid
|
return project_guid
|
||||||
@@ -1039,9 +1006,9 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
self.target_by_location = {}
|
self.target_by_location = {}
|
||||||
for m in self.gbuildparser.modules:
|
for m in self.gbuildparser.modules:
|
||||||
for target in self.gbuildparser.modules[m]['targets']:
|
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']] = []
|
||||||
self.target_by_location[target.location] |= set([target])
|
self.target_by_location[target['location']].append(target)
|
||||||
|
|
||||||
self._do_log = False # set to 'True' to activate log of QtCreatorIntegrationGenerator
|
self._do_log = False # set to 'True' to activate log of QtCreatorIntegrationGenerator
|
||||||
if self._do_log:
|
if self._do_log:
|
||||||
@@ -1499,12 +1466,12 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
for f in self.gbuildparser.modules[m]['targets']:
|
for f in self.gbuildparser.modules[m]['targets']:
|
||||||
all_libs.append(f)
|
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'])
|
||||||
lib_folder = os.path.relpath(lib.location, self.base_folder)
|
lib_folder = os.path.relpath(lib['location'], self.base_folder)
|
||||||
|
|
||||||
def lopath(path):
|
def lopath(path):
|
||||||
return os.path.relpath(path, lib.location)
|
return os.path.relpath(path, lib['location'])
|
||||||
|
|
||||||
defines_list = []
|
defines_list = []
|
||||||
sources_list = []
|
sources_list = []
|
||||||
@@ -1515,7 +1482,7 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
# in a specific "Headers" folder in QtCreator's Project panel.
|
# in a specific "Headers" folder in QtCreator's Project panel.
|
||||||
# We will list here only headers files of current lib.
|
# We will list here only headers files of current lib.
|
||||||
headers_list = []
|
headers_list = []
|
||||||
for file_ in lib.cxxobjects:
|
for file_ in lib['CXXOBJECTS']:
|
||||||
# the file has no extension : search it
|
# the file has no extension : search it
|
||||||
# self._log("\n file : %s" % file_)
|
# self._log("\n file : %s" % file_)
|
||||||
ext = self.get_source_extension(file_)
|
ext = self.get_source_extension(file_)
|
||||||
@@ -1528,20 +1495,20 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
headers_list.append(lopath(file_ + ext))
|
headers_list.append(lopath(file_ + ext))
|
||||||
|
|
||||||
# List all include paths
|
# List all include paths
|
||||||
for hdir in lib.include:
|
for hdir in lib['include']:
|
||||||
hf_lopath = lopath(hdir)
|
hf_lopath = lopath(hdir)
|
||||||
includepath_list.append(hf_lopath)
|
includepath_list.append(hf_lopath)
|
||||||
|
|
||||||
# List headers files from current lib
|
# List headers files from current lib
|
||||||
for hdir in lib.include:
|
for hdir in lib['include']:
|
||||||
if hdir.startswith(lib.location):
|
if hdir.startswith(lib['location']):
|
||||||
for hf in os.listdir(hdir):
|
for hf in os.listdir(hdir):
|
||||||
if hf.endswith(('.h', '.hxx', '.hpp', '.hrc')):
|
if hf.endswith(('.h', '.hxx', '.hpp', '.hrc')):
|
||||||
hf_lopath = lopath(os.path.join(hdir, hf))
|
hf_lopath = lopath(os.path.join(hdir, hf))
|
||||||
headers_list.append(hf_lopath)
|
headers_list.append(hf_lopath)
|
||||||
|
|
||||||
# List defines
|
# List defines
|
||||||
for key, value in lib.defs.items():
|
for key, value in lib['defs'].items():
|
||||||
define = key
|
define = key
|
||||||
if value is not None:
|
if value is not None:
|
||||||
define += '=' + value
|
define += '=' + value
|
||||||
@@ -1559,7 +1526,7 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
|
|||||||
'headers': set(headers_list),
|
'headers': set(headers_list),
|
||||||
'includepath': set(includepath_list),
|
'includepath': set(includepath_list),
|
||||||
'defines': set(defines_list),
|
'defines': set(defines_list),
|
||||||
'loc': lib.location,
|
'loc': lib['location'],
|
||||||
'name': lib_name
|
'name': lib_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user