diff --git a/debug/org.eclipse.cdt.debug.application/.classpath b/debug/org.eclipse.cdt.debug.application/.classpath index f96aed716d9..8de1f1073f5 100644 --- a/debug/org.eclipse.cdt.debug.application/.classpath +++ b/debug/org.eclipse.cdt.debug.application/.classpath @@ -2,6 +2,7 @@ + diff --git a/debug/org.eclipse.cdt.debug.application/.gitignore b/debug/org.eclipse.cdt.debug.application/.gitignore index 1e8a55af15b..661cce99bb8 100644 --- a/debug/org.eclipse.cdt.debug.application/.gitignore +++ b/debug/org.eclipse.cdt.debug.application/.gitignore @@ -1,170 +1,2 @@ /bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin -/bin +scripts/config.ini diff --git a/debug/org.eclipse.cdt.debug.application/build.properties b/debug/org.eclipse.cdt.debug.application/build.properties index 1641833f33f..e7020d34963 100644 --- a/debug/org.eclipse.cdt.debug.application/build.properties +++ b/debug/org.eclipse.cdt.debug.application/build.properties @@ -1,4 +1,5 @@ -source.. = src/ +source.. = src/,\ + src-config-generator/ output.. = bin/ bin.includes = plugin.xml,\ META-INF/,\ diff --git a/debug/org.eclipse.cdt.debug.application/configGenerator.xml b/debug/org.eclipse.cdt.debug.application/configGenerator.xml new file mode 100644 index 00000000000..6f5e41896b0 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.application/configGenerator.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.application/pom.xml b/debug/org.eclipse.cdt.debug.application/pom.xml new file mode 100644 index 00000000000..3133b72d58e --- /dev/null +++ b/debug/org.eclipse.cdt.debug.application/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + org.eclipse.cdt + org.eclipse.cdt.debug-parent + 9.3.0-SNAPSHOT + + + 1.1.0-SNAPSHOT + org.eclipse.cdt.debug.application + eclipse-plugin + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + generate-configuration + prepare-package + + + + + + + + + run + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh b/debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh index 4875453390c..1583013e8d4 100644 --- a/debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh +++ b/debug/org.eclipse.cdt.debug.application/scripts/cdtdebug.sh @@ -82,24 +82,17 @@ fi ECLIPSE_HOME=$(cd "$SCRIPT_DIR/../../.." && pwd) # install.sh will modify this line. DO NOT REMOVE THE FOLLOWING MARKER: @#@# ECLIPSE_EXEC="$ECLIPSE_HOME/eclipse" -# On Mac OS X, the application layout is a bit different (Eclipse.app) +# On macOS, the application layout is a bit different (Eclipse.app) case $ECLIPSE_HOME in *MacOS) ECLIPSE_HOME="$ECLIPSE_HOME/../Eclipse" ;; esac PLUGIN_DIR="$ECLIPSE_HOME/plugins" OSGI_JAR=`find "$PLUGIN_DIR" -maxdepth 1 -name 'org.eclipse.osgi_*.jar' -not -name '*source*' -exec basename {} \; | tail -1` -SWT_JAR=`find "$PLUGIN_DIR" -maxdepth 1 -name 'org.eclipse.swt.*.jar' -not -name '*source*' -exec basename {} \; | tail -1` -SWT_PLUGIN=`echo $SWT_JAR | sed -e "s/_[0-9]*\..*.jar//"` -FS_JAR=`find "$PLUGIN_DIR" -maxdepth 1 -name 'org.eclipse.core.filesystem.*.jar' -not -name '*source*' -exec basename {} \; | grep -v java7 | tail -1` -FS_PLUGIN=`echo $FS_JAR | sed -e "s/_[0-9]*\..*.jar//"` -LINUX_JAR=`find "$PLUGIN_DIR" -maxdepth 1 -name 'org.eclipse.cdt.core.linux.*.jar' -not -name '*source*' -exec basename {} \; | tail -1` -LINUX_PLUGIN=`echo $LINUX_JAR | sed -e "s/_[0-9]*\..*.jar//"` # Run eclipse with the Stand-alone Debugger product specified "$ECLIPSE_EXEC" -clean -product org.eclipse.cdt.debug.application.product \ -data "$HOME/workspace-cdtdebug" -configuration file\:"$HOME/cdtdebugger" \ -dev file\:"$HOME/cdtdebugger/dev.properties" $options \ - -vmargs -Dosgi.jar=$OSGI_JAR -Dswt.plugin=$SWT_PLUGIN -Dfs.plugin=$FS_PLUGIN \ - -Dlinux.plugin=$LINUX_PLUGIN -Declipse.home="$ECLIPSE_HOME" + -vmargs -Dosgi.jar=$OSGI_JAR -Declipse.home="$ECLIPSE_HOME" diff --git a/debug/org.eclipse.cdt.debug.application/scripts/config.ini b/debug/org.eclipse.cdt.debug.application/scripts/config.ini deleted file mode 100644 index 7c55466fb27..00000000000 --- a/debug/org.eclipse.cdt.debug.application/scripts/config.ini +++ /dev/null @@ -1,7 +0,0 @@ -#Configuration File -#Fri Dec 20 17:38:27 EST 2013 -osgi.install.area=file\:$eclipse.home$ -osgi.framework=file\:$eclipse.home$/plugins/$osgi.jar$ -osgi.bundles=org.eclipse.cdt.core.linux,org.eclipse.linuxtools.cdt.libhover.library.docs,org.eclipse.cdt.core.native,org.eclipse.core.net,org.eclipse.e4.core.di.extensions,org.eclipse.cdt.debug.ui.memory.floatingpoint,org.eclipse.ui.editors,org.eclipse.equinox.ds@1\:start,org.eclipse.search,org.eclipse.text,org.eclipse.jface.databinding,org.eclipse.cdt.debug.ui.memory.search,org.eclipse.debug.core,org.apache.batik.util,org.eclipse.cdt.debug.ui.memory.memorybrowser,org.eclipse.e4.ui.widgets,org.eclipse.cdt.debug.core,org.eclipse.ui,org.eclipse.cdt.make.core,javax.annotation,org.eclipse.equinox.registry,org.eclipse.cdt.dsf.ui,org.eclipse.cdt.debug.ui.memory.traditional,org.eclipse.cdt.ui,org.eclipse.ui.ide,org.w3c.dom.svg,org.eclipse.jface,org.eclipse.ltk.ui.refactoring,org.w3c.dom.smil,org.eclipse.e4.ui.model.workbench,org.eclipse.equinox.bidi,org.eclipse.e4.ui.workbench,org.eclipse.e4.ui.di,org.eclipse.debug.ui,org.eclipse.e4.ui.bindings,org.eclipse.core.contenttype,org.eclipse.e4.ui.workbench.swt,org.eclipse.ui.views,org.eclipse.emf.ecore.change,org.eclipse.equinox.app,org.eclipse.e4.ui.services,org.eclipse.ant.core,org.eclipse.equinox.p2.core,org.eclipse.cdt.core,org.eclipse.cdt.debug.application,org.eclipse.cdt.debug.application.doc,org.eclipse.core.resources,org.eclipse.team.ui,org.eclipse.equinox.common@2\:start,org.eclipse.equinox.p2.engine,org.eclipse.cdt.debug.ui,org.eclipse.ui.views.properties.tabbed,org.eclipse.ui.views.log,org.eclipse.help,org.eclipse.help.ui,org.eclipse.help.base,org.eclipse.help.webapp,org.eclipse.equinox.jsp.jasper,org.eclipse.equinox.jsp.jasper.registry,org.apache.jasper.glassfish,org.apache.lucene.core,org.apache.lucene.analysis,org.eclipse.equinox.http.jetty,org.eclipse.equinox.http.registry,org.eclipse.jetty.http,org.eclipse.equinox.http.servlet,org.eclipse.jetty.io,org.eclipse.jetty.server,org.eclipse.jetty.servlet,org.eclipse.jetty.util,org.eclipse.jetty.continuation,org.eclipse.jetty.security,javax.servlet.jsp,javax.el,org.eclipse.core.filesystem,org.eclipse.equinox.event,org.eclipse.cdt.dsf.gdb.ui,org.eclipse.ltk.core.refactoring,com.ibm.icu,org.eclipse.swt,org.eclipse.core.filebuffers,org.eclipse.e4.ui.workbench.addons.swt,javax.inject,$swt.plugin$,org.eclipse.core.databinding.observable,org.eclipse.core.jobs,org.eclipse.ui.forms,org.eclipse.e4.core.contexts,javax.xml,org.eclipse.core.variables,org.eclipse.ui.navigator,org.eclipse.e4.core.commands,org.eclipse.core.databinding,org.eclipse.core.commands,org.eclipse.ui.workbench,org.eclipse.equinox.util,org.eclipse.cdt.launch,org.w3c.css.sac,org.eclipse.e4.ui.workbench.renderers.swt,org.eclipse.cdt.managedbuilder.core,org.eclipse.jface.text,org.eclipse.cdt.managedbuilder.gnu.ui,org.eclipse.equinox.p2.metadata,org.eclipse.emf.ecore.xmi,org.eclipse.emf.common,org.eclipse.cdt.gdb,org.eclipse.compare.core,$linux.plugin$,org.eclipse.ui.console,org.eclipse.cdt.dsf.gdb,javax.servlet,org.eclipse.equinox.p2.repository,org.eclipse.linuxtools.cdt.libhover.glibc,org.eclipse.equinox.security,org.eclipse.compare,org.eclipse.core.runtime@start,org.eclipse.cdt.dsf,org.eclipse.osgi.services,org.eclipse.e4.ui.workbench3,org.eclipse.equinox.preferences,org.w3c.dom.events,org.eclipse.linuxtools.cdt.libhover,org.eclipse.ui.navigator.resources,org.eclipse.e4.ui.css.core,org.eclipse.ui.workbench.texteditor,org.eclipse.core.expressions,org.eclipse.e4.ui.css.swt.theme,org.eclipse.core.databinding.property,org.eclipse.emf.ecore,org.eclipse.e4.core.services,org.eclipse.cdt.gdb.ui,org.apache.batik.util.gui,org.eclipse.e4.core.di,$fs.plugin$,org.eclipse.team.core,org.eclipse.cdt.debug.ui.memory.transport,org.eclipse.equinox.p2.metadata.repository,org.eclipse.e4.ui.css.swt,org.apache.batik.css,org.eclipse.e4.emf.xpath,org.apache.commons.jxpath,org.tukaani.xz,org.eclipse.e4.core.di.annotations,com.google.gson,org.eclipse.launchbar.core,org.eclipse.launchbar.ui,org.eclipse.tools.templates.core,org.eclipse.tools.templates.ui,org.eclipse.tm.terminal.control -osgi.configuration.cascaded=false -osgi.bundles.defaultStartLevel=4 diff --git a/debug/org.eclipse.cdt.debug.application/src-config-generator/org/eclipse/cdt/debug/application/ConfigGenerator.java b/debug/org.eclipse.cdt.debug.application/src-config-generator/org/eclipse/cdt/debug/application/ConfigGenerator.java new file mode 100644 index 00000000000..e2b6ab47b6b --- /dev/null +++ b/debug/org.eclipse.cdt.debug.application/src-config-generator/org/eclipse/cdt/debug/application/ConfigGenerator.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2016 Ericsson. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.cdt.debug.application; + +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Stream; + +/** + * A "script" that generates the config.ini used by the stand-alone debugger + * script. This is done by parsing the debug.product file to find the plug-ins. + */ +public class ConfigGenerator { + private static final Pattern PLUGIN_LINE_PATTERN = Pattern.compile("\\s* PLUGINS_WITH_START_LEVEL = new HashMap<>(); + /** Plug-ins that we don't want to load when using the script VS using the product */ + private static final Set PLUGINS_NOT_IN_SCRIPT_VERSION = new HashSet<>(); + + static { + PLUGINS_WITH_START_LEVEL.put("org.eclipse.equinox.ds", "@1\\:start"); //$NON-NLS-1$ //$NON-NLS-2$ + PLUGINS_WITH_START_LEVEL.put("org.eclipse.equinox.common", "@2\\:start"); //$NON-NLS-1$ //$NON-NLS-2$ + PLUGINS_WITH_START_LEVEL.put("org.eclipse.core.runtime", "@start"); //$NON-NLS-1$ //$NON-NLS-2$ + // We don't want the user to do "Check for updates", etc. + PLUGINS_NOT_IN_SCRIPT_VERSION.add("org.eclipse.update.configurator"); //$NON-NLS-1$ + PLUGINS_NOT_IN_SCRIPT_VERSION.add("org.eclipse.equinox.p2.ui"); //$NON-NLS-1$ + PLUGINS_NOT_IN_SCRIPT_VERSION.add("org.eclipse.equinox.p2.ui.sdk"); //$NON-NLS-1$ + } + + public static void main(String[] args) { + if (args.length < 4) { + printUsage(); + System.exit(1); + } + + String productFilePath = args[1]; + List pluginList = parsePluginList(productFilePath); + if (pluginList.isEmpty()) { + System.err.println("No plugins. Something must have gone wrong."); //$NON-NLS-1$ + System.exit(1); + } + + Path configOutputPath = Paths.get(args[3]); + generateConfigIni(pluginList, configOutputPath); + System.exit(0); + } + + private static void generateConfigIni(List pluginList, Path configOutputPath) { + try (FileWriter r = new FileWriter(configOutputPath.toFile())) { + r.write("osgi.install.area=file\\:$eclipse.home$\n"); //$NON-NLS-1$ + r.write("osgi.framework=file\\:$eclipse.home$/plugins/$osgi.jar$\n"); //$NON-NLS-1$ + r.write("osgi.bundles="); //$NON-NLS-1$ + + // Write all plug-in names + for (int i =0; i < pluginList.size(); i++) { + String pluginName = pluginList.get(i); + if (PLUGINS_NOT_IN_SCRIPT_VERSION.contains(pluginName)) { + continue; + } + + r.write(pluginName); + + // Add start level if necessary + if (PLUGINS_WITH_START_LEVEL.containsKey(pluginName)) { + r.write(PLUGINS_WITH_START_LEVEL.get(pluginName)); + } + + r.write(','); + } + r.write('\n'); + r.write("osgi.configuration.cascaded=false\n"); //$NON-NLS-1$ + r.write("osgi.bundles.defaultStartLevel=4\n"); //$NON-NLS-1$ + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } + } + + private static List parsePluginList(String productPath) { + List pluginList = new ArrayList<>(); + try (Stream stream = Files.lines(Paths.get(productPath))) { + stream.forEach((line) -> { + Matcher m = PLUGIN_LINE_PATTERN.matcher(line); + if (m.matches()) { + pluginList.add(m.group(1)); + } + }); + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } + return pluginList; + } + + private static void printUsage() { + System.err.println("Usage:"); //$NON-NLS-1$ + System.err.println(" ConfigGenerator -product /path/to/foo.product -out /path/to/config.ini"); //$NON-NLS-1$ + } +}