diff --git a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CcConfigurationBase.java b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CcConfigurationBase.java index 7d056af0..e2fc158e 100644 --- a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CcConfigurationBase.java +++ b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CcConfigurationBase.java @@ -64,14 +64,6 @@ public String get(ConfigTypes type) { return config.get(type); } - /** - * @return True if the python values are set. - */ - public boolean isPythonConfigured() { - return !(!config.containsKey(ConfigTypes.PYTHON_PATH) - || (config.containsKey(ConfigTypes.PYTHON_PATH) && config.get(ConfigTypes.PYTHON_PATH).isEmpty())); - } - /** * Returns the default configuration for the plug-in. * @return An Unmodifiable view of the default configuration Map. diff --git a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CommonGui.java b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CommonGui.java index da751a3c..f8fd06c2 100644 --- a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CommonGui.java +++ b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CommonGui.java @@ -5,11 +5,21 @@ import java.util.List; import java.util.Map; +import org.codechecker.eclipse.plugin.Logger; +import org.codechecker.eclipse.plugin.config.Config.ConfigTypes; +import org.codechecker.eclipse.plugin.config.global.CcGlobalConfiguration; +import org.codechecker.eclipse.plugin.config.project.CodeCheckerProject; +import org.codechecker.eclipse.plugin.itemselector.CheckerView; +import org.codechecker.eclipse.plugin.runtime.CodeCheckEnvironmentChecker; +import org.codechecker.eclipse.plugin.utils.CheckerItem; +import org.codechecker.eclipse.plugin.utils.CheckerItem.LAST_ACTION; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; @@ -18,9 +28,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; @@ -30,14 +38,6 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; -import org.codechecker.eclipse.plugin.Logger; -import org.codechecker.eclipse.plugin.config.Config.ConfigTypes; -import org.codechecker.eclipse.plugin.config.global.CcGlobalConfiguration; -import org.codechecker.eclipse.plugin.config.project.CodeCheckerProject; -import org.codechecker.eclipse.plugin.itemselector.CheckerView; -import org.codechecker.eclipse.plugin.runtime.CodeCheckEnvironmentChecker; -import org.codechecker.eclipse.plugin.utils.CheckerItem; -import org.codechecker.eclipse.plugin.utils.CheckerItem.LAST_ACTION; /** * Global and project level preferences pages. @@ -63,7 +63,7 @@ public class CommonGui { private CcConfigurationBase config; private CodeCheckerProject cCProject; private Text codeCheckerDirectoryField;// codechecker dir - private Text pythonEnvField;// CodeChecker python env + private Text numThreads;// #of analysis threads private Text cLoggers;// #C compiler commands to catch @@ -151,9 +151,10 @@ public Control createContents(final Composite parent) { checkerConfigSection.setText("Configuration"); codeCheckerDirectoryField = addTextField(toolkit, client, "CodeChecker package root directory", ""); - codeCheckerDirectoryField.addListener(SWT.FocusOut, new Listener() { + codeCheckerDirectoryField.addModifyListener(new ModifyListener() { + @Override - public void handleEvent(Event event) { + public void modifyText(ModifyEvent e) { try { Map changedConfig = getConfigFromFields(); CodeCheckEnvironmentChecker.getCheckerEnvironment(changedConfig, @@ -187,21 +188,6 @@ public void widgetSelected(SelectionEvent event) { } }); - pythonEnvField = addTextField(toolkit, client, "Python virtualenv root directory (optional)", ""); - final Button pythonEnvFieldBrowse = new Button(client, SWT.PUSH); - pythonEnvFieldBrowse.setText(BROSWE); - pythonEnvFieldBrowse.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - DirectoryDialog dlg = new DirectoryDialog(client.getShell()); - dlg.setFilterPath(codeCheckerDirectoryField.getText()); - dlg.setText("Browse python environment"); - String dir = dlg.open(); - if (dir != null) { - pythonEnvField.setText(dir); - } - } - }); - numThreads = addTextField(toolkit, client, "Number of analysis threads", "4"); toolkit.createLabel(client, ""); cLoggers = addTextField(toolkit, client, "Compiler commands to log", "gcc:g++:clang:clang++"); @@ -371,7 +357,6 @@ public Map loadConfig(boolean resetToDefault) { */ public void setFields(Map config) { codeCheckerDirectoryField.setText(config.get(ConfigTypes.CHECKER_PATH)); - pythonEnvField.setText(config.get(ConfigTypes.PYTHON_PATH)); checkerListArg = config.get(ConfigTypes.CHECKER_LIST); cLoggers.setText(config.get(ConfigTypes.COMPILERS)); numThreads.setText(config.get(ConfigTypes.ANAL_THREADS)); @@ -384,7 +369,6 @@ public void setFields(Map config) { public Map getConfigFromFields() { Map conf = new HashMap<>(); conf.put(ConfigTypes.CHECKER_PATH, codeCheckerDirectoryField.getText()); - conf.put(ConfigTypes.PYTHON_PATH, pythonEnvField.getText()); conf.put(ConfigTypes.CHECKER_LIST, checkerListArg); conf.put(ConfigTypes.ANAL_THREADS, numThreads.getText()); conf.put(ConfigTypes.COMPILERS, cLoggers.getText()); @@ -397,7 +381,6 @@ public Map getConfigFromFields() { public void saveConfig() { Map conf = new HashMap(); conf.put(ConfigTypes.CHECKER_PATH, codeCheckerDirectoryField.getText()); - conf.put(ConfigTypes.PYTHON_PATH, pythonEnvField.getText()); conf.put(ConfigTypes.CHECKER_LIST, checkerListArg); conf.put(ConfigTypes.ANAL_THREADS, numThreads.getText()); conf.put(ConfigTypes.COMPILERS, cLoggers.getText()); diff --git a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/Config.java b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/Config.java index a60d3c55..bc75f3de 100644 --- a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/Config.java +++ b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/Config.java @@ -5,9 +5,8 @@ import java.util.Map; import java.util.Set; -import org.eclipse.core.runtime.IStatus; - import org.codechecker.eclipse.plugin.Logger; +import org.eclipse.core.runtime.IStatus; /** * Classes for handling actual configuration entries, and logging. @@ -23,7 +22,6 @@ public class Config { public enum ConfigTypes { // Common configuration values CHECKER_PATH("codechecker_path"), - PYTHON_PATH(""), COMPILERS("gcc:g++:clang:clang++"), ANAL_THREADS("4"), CHECKER_LIST("enabled_checkers"), diff --git a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/EnvironmentVariables.java b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/EnvironmentVariables.java index d014b88f..5737a434 100644 --- a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/EnvironmentVariables.java +++ b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/EnvironmentVariables.java @@ -1,8 +1,5 @@ package org.codechecker.eclipse.plugin.config; -import java.util.EnumSet; -import java.util.Set; - import org.eclipse.cdt.core.envvar.IEnvironmentVariable; /** @@ -14,14 +11,7 @@ public enum EnvironmentVariables { CC_LOGGER_GCC_LIKE("clang", IEnvironmentVariable.ENVVAR_REPLACE), LD_PRELOAD("ldlogger.so", IEnvironmentVariable.ENVVAR_REPLACE), CC_LOGGER_FILE("logfile", IEnvironmentVariable.ENVVAR_REPLACE), - CC_LOGGER_BIN("/bin/ldlogger", IEnvironmentVariable.ENVVAR_REPLACE), - //python variables comes after this; - PATH("/bin:", IEnvironmentVariable.ENVVAR_PREPEND), - VIRTUAL_ENV("pythonEnv", IEnvironmentVariable.ENVVAR_REPLACE); - - public static Set BASE_TYPE = EnumSet.range(LD_LIBRARY_PATH, CC_LOGGER_BIN); - public static Set PYTHON_TYPE = EnumSet.range(PATH, VIRTUAL_ENV); - public static Set ALL = EnumSet.range(LD_LIBRARY_PATH, VIRTUAL_ENV); + CC_LOGGER_BIN("/bin/ldlogger", IEnvironmentVariable.ENVVAR_REPLACE); private String defaultValue; private int method; diff --git a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/project/CodeCheckerProject.java b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/project/CodeCheckerProject.java index cfe12121..322f3c2c 100644 --- a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/project/CodeCheckerProject.java +++ b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/project/CodeCheckerProject.java @@ -90,7 +90,7 @@ public void cleanUp() { */ private void setEnvironment() { //Initialize to defaults. - for (EnvironmentVariables ev :EnvironmentVariables.BASE_TYPE) { + for (EnvironmentVariables ev : EnvironmentVariables.values()) { environmentVariables.put(ev, ev.getDefaultValue()); } String checkerDir = current.get(ConfigTypes.CHECKER_PATH); @@ -107,14 +107,6 @@ private void setEnvironment() { Paths.get(codeCheckerWorkspace.toString(), COMPILATION_COMMANDS).toString()); - if (current.isPythonConfigured()) { - for (EnvironmentVariables ev :EnvironmentVariables.PYTHON_TYPE) { - environmentVariables.put(ev, ev.getDefaultValue()); - } - environmentVariables.put(EnvironmentVariables.PATH, - current.get(ConfigTypes.PYTHON_PATH) + EnvironmentVariables.PATH.getDefaultValue()); - environmentVariables.put(EnvironmentVariables.VIRTUAL_ENV, current.get(ConfigTypes.PYTHON_PATH)); - } modifyProjectEnvironmentVariables(); } diff --git a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/CodeCheckEnvironmentChecker.java b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/CodeCheckEnvironmentChecker.java index bd083b58..e51754b1 100644 --- a/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/CodeCheckEnvironmentChecker.java +++ b/bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/CodeCheckEnvironmentChecker.java @@ -4,15 +4,12 @@ import java.util.HashMap; import java.util.Map; -import org.codechecker.eclipse.plugin.Logger; import org.codechecker.eclipse.plugin.config.Config.ConfigTypes; import org.codechecker.eclipse.plugin.config.global.CcGlobalConfiguration; import org.codechecker.eclipse.plugin.config.project.CodeCheckerProject; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; /** * This class checks for Environments used by CodeChecker. @@ -24,14 +21,12 @@ public class CodeCheckEnvironmentChecker { private static final String HELP_ARGUMENT = "-h"; private static final int WAIT_TIME_MULTIPLYER = 1000; // in milliseconds + private static final Map SYS_ENV = System.getenv(); - public final Optional pythonEnvironment; public final String checkerDir; // root directory of CodeChecker public final String codeCheckerCommand; // CodecCheker executable path - public final ImmutableMap environmentBefore; - - public Map commandSubstitutionMap; + private Map commandSubstitutionMap; private Map config; private CodeCheckerProject project; @@ -51,22 +46,10 @@ public CodeCheckEnvironmentChecker(CodeCheckerProject project) { else config = CcGlobalConfiguration.getInstance().get(); - if (!config.containsKey(ConfigTypes.PYTHON_PATH) - || (config.containsKey(ConfigTypes.PYTHON_PATH) && config.get(ConfigTypes.PYTHON_PATH).isEmpty())){ - pythonEnvironment=Optional.absent(); - SLogger.log(LogI.INFO, "pythonenv is not set"); - } - else{ - SLogger.log(LogI.INFO, "pythonenv is set to:" + config.get(ConfigTypes.PYTHON_PATH)); - pythonEnvironment=Optional.of(config.get(ConfigTypes.PYTHON_PATH)); - } - //checkerList=getConfigValue(ConfigTypes.CHECKER_LIST); checkerDir=getConfigValue(ConfigTypes.CHECKER_PATH); - environmentBefore = getInitialEnvironment(pythonEnvironment); codeCheckerCommand = checkerDir+"/bin/CodeChecker"; - commandSubstitutionMap = new HashMap() {{ put("CC_BIN", new File(codeCheckerCommand)); }}; @@ -105,8 +88,7 @@ private String getConfigValue(ConfigTypes key) { public static void getCheckerEnvironment( Map config, String codeCheckerBinaryPath) { - ShellExecutorHelper she = new ShellExecutorHelper( - getInitialEnvironment(Optional.of(config.get(ConfigTypes.PYTHON_PATH)))); + ShellExecutorHelper she = new ShellExecutorHelper(SYS_ENV); String cmd = "'${CC_BINARY}' " + HELP_ARGUMENT; @SuppressWarnings("serial") @@ -130,34 +112,6 @@ public static void getCheckerEnvironment( } } - /** - * Returns new environment if using Python virtual environment or System env if not. - * @param pythonEnvironment Path to Python virtual environment activator. - * @return The environment to be used. - */ - private static ImmutableMap getInitialEnvironment(Optional pythonEnvironment) { - if (pythonEnvironment.isPresent()) { - ShellExecutorHelper she = new ShellExecutorHelper(System.getenv()); - File pyEnv = new File(pythonEnvironment.get() + "/bin/activate"); - String cmd = "source '${PY_ENV}' ; env"; - @SuppressWarnings("serial") - Map substitutionMap = new HashMap() {{ put("PY_ENV", pyEnv); }}; - Optional output = she.quickReturnOutput(cmd, substitutionMap); - if (!output.isPresent()) { - Logger.log(IStatus.ERROR, "Couldn't check the python environment!"); - throw new IllegalArgumentException("Couldn't check the given python environment!"); - } else { - ImmutableMap environment = (new EnvironmentParser()).parse(output - .get()); - return environment; - } - - } else { - SLogger.log(LogI.INFO, "Python Env not specified. Using original system env."); - return ImmutableMap.copyOf(System.getenv()); - } - } - @Override public boolean equals(Object obj) { if (obj == null) return false; @@ -194,7 +148,7 @@ public String createAnalyzeCommmand(String buildLog) { * @return CodeChecker check command output */ public String processLog(String buildLog, boolean logToConsole, IProgressMonitor monitor, int taskCount) { - ShellExecutorHelper she = new ShellExecutorHelper(environmentBefore); + ShellExecutorHelper she = new ShellExecutorHelper(SYS_ENV); String cmd = createAnalyzeCommmand(buildLog); SLogger.log(LogI.INFO, "SERVER_SER_MSG >> processLog >> "+ cmd); Optional ccOutput = she.progressableWaitReturnOutput(cmd, commandSubstitutionMap, logToConsole, monitor, taskCount); @@ -213,7 +167,7 @@ public String processLog(String buildLog, boolean logToConsole, IProgressMonitor * @return A String containing the checkers. One at a line. */ public String getCheckerList() { - ShellExecutorHelper she = new ShellExecutorHelper(environmentBefore); + ShellExecutorHelper she = new ShellExecutorHelper(SYS_ENV); String cmd = "'${CC_BIN}' checkers"; Optional ccOutput = she.waitReturnOutput(cmd, commandSubstitutionMap, false); return ccOutput.or(""); diff --git a/readme.md b/readme.md index e73d79ff..3c4c46fd 100644 --- a/readme.md +++ b/readme.md @@ -29,7 +29,6 @@ Run `mvn -f mavendeps/pom.xml p2:site && mvn clean verify` in the root of the pr Make sure that before staring Eclipse: * CodeChecker/bin directory is included in PATH (e.g.: `export PATH="/home//CodeChecker/bin/:$PATH"`) -* Python virtualenv with CodeChecker dependencies is sourced (e.g.: `source /home//venv/bin/activate`) __Currently the plugin is only usable with a CDT project.__ diff --git a/tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/IndicatorTest.java b/tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/IndicatorTest.java index d2918f5b..c6f73cd9 100644 --- a/tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/IndicatorTest.java +++ b/tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/IndicatorTest.java @@ -8,7 +8,6 @@ import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; import org.eclipse.swtbot.swt.finder.widgets.SWTBotCLabel; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; import org.hamcrest.core.IsNull; import org.junit.Before; import org.junit.BeforeClass; @@ -74,13 +73,7 @@ public void testNoCodeCheckerFound() { @Test public void testCodeCheckerFound() { Path ccDir = Utils.prepareCodeChecker(); - - SWTBotText text = bot.textWithLabel("CodeChecker package root directory"); - text.setText(ccDir.toString()); - text.setFocus(); - bot.textWithLabel("Python virtualenv root directory (optional)").setFocus(); - - bot.sleep(SHORT_WAIT_TIME); + GuiUtils.setCCBinDir(ccDir, bot); SWTBotCLabel label = null; try { diff --git a/tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/utils/GuiUtils.java b/tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/utils/GuiUtils.java index 3f8cb014..aab527ef 100644 --- a/tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/utils/GuiUtils.java +++ b/tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/utils/GuiUtils.java @@ -44,7 +44,7 @@ public final class GuiUtils { public static final String ENVIR_LOGGER_BIN = "CC_LOGGER_BIN"; public static final String ENVIR_LOGGER_FILE = "CC_LOGGER_FILE"; public static final String LDOGGER = "ldlogger"; - public static final String PY_DIR_WIDGET = "Python virtualenv root directory (optional)"; + public static final String THREAD_WIDGET = "Number of analysis threads"; public static final String GLOBAL_RADIO = "Use global configuration"; public static final String PROJECT_RADIO = "Use project configuration"; @@ -110,10 +110,10 @@ public static void applyCloseProperties(SWTBotShell propertiesShell, SWTWorkbenc public static void setCCBinDir(Path ccDir, SWTWorkbenchBot bot) { SWTBotText text = bot.textWithLabel(GuiUtils.CC_DIR_WIDGET); text.setText(ccDir.toString()); - text.setFocus(); - bot.textWithLabel(GuiUtils.PY_DIR_WIDGET).setFocus(); + // text.setFocus(); + // bot.textWithLabel(THREAD_WIDGET).setFocus(); - bot.sleep(SHORT_WAIT_TIME); + // bot.sleep(SHORT_WAIT_TIME); } /**