def _eclipseinit(self, files=None, libFiles=None): """ Generates an Eclipse project for each HotSpot build configuration. """ roots = ['cpu', 'os', 'os_cpu', 'share'] for jvmVariant in _jdkJvmVariants: for debugLevel in _jdkDebugLevels: name = jvmVariant + '-' + debugLevel eclProjectDir = join(self.dir, 'eclipse', name) mx.ensure_dir_exists(eclProjectDir) out = mx.XMLDoc() out.open('projectDescription') out.element('name', data='hotspot:' + name) out.element('comment', data='') out.element('projects', data='') out.open('buildSpec') out.open('buildCommand') out.element( 'name', data= 'org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder') out.element('triggers', data='full,incremental') out.element('arguments', data='') out.close('buildCommand') out.close('buildSpec') out.open('natures') out.element('nature', data='org.eclipse.cdt.core.cnature') out.element('nature', data='org.eclipse.cdt.core.ccnature') out.element( 'nature', data= 'org.eclipse.cdt.managedbuilder.core.managedBuildNature') out.element( 'nature', data= 'org.eclipse.cdt.managedbuilder.core.ScannerConfigNature') out.close('natures') if roots: out.open('linkedResources') for r in roots: f = join(_suite.dir, r) out.open('link') out.element('name', data=r) out.element('type', data='2' if isdir(f) else '1') out.element( 'locationURI', data=mx.get_eclipse_project_rel_locationURI( f, eclProjectDir)) out.close('link') out.open('link') out.element('name', data='gensrc') out.element('type', data='2') generated = join( _get_hotspot_build_dir(jvmVariant, debugLevel), 'gensrc') out.element('locationURI', data=mx.get_eclipse_project_rel_locationURI( generated, eclProjectDir)) out.close('link') out.close('linkedResources') out.close('projectDescription') projectFile = join(eclProjectDir, '.project') mx.update_file(projectFile, out.xml(indent='\t', newl='\n')) if files: files.append(projectFile) cprojectTemplate = join(self.dir, 'templates', 'eclipse', 'cproject') cprojectFile = join(eclProjectDir, '.cproject') with open(cprojectTemplate) as f: content = f.read() mx.update_file(cprojectFile, content) if files: files.append(cprojectFile) settingsDir = join(eclProjectDir, ".settings") mx.ensure_dir_exists(settingsDir) for name, source in self._get_eclipse_settings_sources( ).iteritems(): out = StringIO.StringIO() print >> out, '# GENERATED -- DO NOT EDIT' print >> out, '# Source:', source with open(source) as f: print >> out, f.read() content = out.getvalue() mx.update_file(join(settingsDir, name), content) if files: files.append(join(settingsDir, name))
def _eclipseinit(self, files=None, libFiles=None): """ Generates an Eclipse project for each HotSpot build configuration. """ roots = [ 'ASSEMBLY_EXCEPTION', 'LICENSE', 'README', 'THIRD_PARTY_README', 'agent', 'make', 'src', 'test' ] for jvmVariant in _jdkJvmVariants: for debugLevel in _jdkDebugLevels: name = jvmVariant + '-' + debugLevel eclProjectDir = join(self.dir, 'eclipse', name) mx.ensure_dir_exists(eclProjectDir) out = mx.XMLDoc() out.open('projectDescription') out.element('name', data='hotspot:' + name) out.element('comment', data='') out.element('projects', data='') out.open('buildSpec') out.open('buildCommand') out.element('name', data='org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder') out.element('triggers', data='full,incremental') out.element('arguments', data='') out.close('buildCommand') out.close('buildSpec') out.open('natures') out.element('nature', data='org.eclipse.cdt.core.cnature') out.element('nature', data='org.eclipse.cdt.core.ccnature') out.element('nature', data='org.eclipse.cdt.managedbuilder.core.managedBuildNature') out.element('nature', data='org.eclipse.cdt.managedbuilder.core.ScannerConfigNature') out.close('natures') if roots: out.open('linkedResources') for r in roots: f = join(_suite.dir, r) out.open('link') out.element('name', data=r) out.element('type', data='2' if isdir(f) else '1') out.element('locationURI', data=mx.get_eclipse_project_rel_locationURI(f, eclProjectDir)) out.close('link') out.open('link') out.element('name', data='gensrc') out.element('type', data='2') generated = join(_get_hotspot_build_dir(jvmVariant, debugLevel), 'gensrc') out.element('locationURI', data=mx.get_eclipse_project_rel_locationURI(generated, eclProjectDir)) out.close('link') out.close('linkedResources') out.close('projectDescription') projectFile = join(eclProjectDir, '.project') mx.update_file(projectFile, out.xml(indent='\t', newl='\n')) if files: files.append(projectFile) cprojectTemplate = join(self.dir, 'templates', 'eclipse', 'cproject') cprojectFile = join(eclProjectDir, '.cproject') with open(cprojectTemplate) as f: content = f.read() mx.update_file(cprojectFile, content) if files: files.append(cprojectFile) settingsDir = join(eclProjectDir, ".settings") mx.ensure_dir_exists(settingsDir) for name, source in self._get_eclipse_settings_sources().iteritems(): out = StringIO.StringIO() print >> out, '# GENERATED -- DO NOT EDIT' print >> out, '# Source:', source with open(source) as f: print >> out, f.read() content = out.getvalue() mx.update_file(join(settingsDir, name), content) if files: files.append(join(settingsDir, name))