diff options
author | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:58:36 +0900 |
---|---|---|
committer | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:58:36 +0900 |
commit | 25b26f6ed69014262fc536f6cadd1add400bff20 (patch) | |
tree | b8d2e7f35889963c81c5120c372c4b4ae53b1382 /org.tizen.codecoverage | |
parent | b46fd4f6e8283f5da6795b12ecf77adcf49525fe (diff) | |
download | codecoverage-eplugin-tizen_2.0.tar.gz codecoverage-eplugin-tizen_2.0.tar.bz2 codecoverage-eplugin-tizen_2.0.zip |
Tizen 2.0 Releasesubmit/tizen_2.0/20130215.192339tizen_2.0
Diffstat (limited to 'org.tizen.codecoverage')
-rw-r--r-- | org.tizen.codecoverage/.classpath | 7 | ||||
-rw-r--r-- | org.tizen.codecoverage/.project | 28 | ||||
-rw-r--r-- | org.tizen.codecoverage/.settings/org.eclipse.jdt.core.prefs | 72 | ||||
-rw-r--r-- | org.tizen.codecoverage/32_TIZEN_SDK_icon.png | bin | 0 -> 5237 bytes | |||
-rw-r--r-- | org.tizen.codecoverage/META-INF/MANIFEST.MF | 22 | ||||
-rw-r--r-- | org.tizen.codecoverage/NOTICE | 2 | ||||
-rw-r--r-- | org.tizen.codecoverage/OSGI-INF/l10n/bundle.properties | 2 | ||||
-rw-r--r-- | org.tizen.codecoverage/about.ini | 32 | ||||
-rw-r--r-- | org.tizen.codecoverage/about.mappings | 6 | ||||
-rw-r--r-- | org.tizen.codecoverage/about.properties | 12 | ||||
-rw-r--r-- | org.tizen.codecoverage/build.properties | 11 | ||||
-rw-r--r-- | org.tizen.codecoverage/icons/toolbar_icon.gif | bin | 0 -> 610 bytes | |||
-rw-r--r-- | org.tizen.codecoverage/plugin.xml | 31 | ||||
-rw-r--r-- | org.tizen.codecoverage/src/org/tizen/codecoverage/Activator.java | 70 | ||||
-rw-r--r-- | org.tizen.codecoverage/src/org/tizen/codecoverage/actions/GcovAction.java | 112 | ||||
-rw-r--r-- | org.tizen.codecoverage/src/org/tizen/codecoverage/helper/GcovHelper.java | 176 |
16 files changed, 583 insertions, 0 deletions
diff --git a/org.tizen.codecoverage/.classpath b/org.tizen.codecoverage/.classpath new file mode 100644 index 0000000..ad32c83 --- /dev/null +++ b/org.tizen.codecoverage/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/org.tizen.codecoverage/.project b/org.tizen.codecoverage/.project new file mode 100644 index 0000000..ee5a68f --- /dev/null +++ b/org.tizen.codecoverage/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.tizen.codecoverage</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.tizen.codecoverage/.settings/org.eclipse.jdt.core.prefs b/org.tizen.codecoverage/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8e500c1 --- /dev/null +++ b/org.tizen.codecoverage/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,72 @@ +#Fri Dec 02 17:57:57 KST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning diff --git a/org.tizen.codecoverage/32_TIZEN_SDK_icon.png b/org.tizen.codecoverage/32_TIZEN_SDK_icon.png Binary files differnew file mode 100644 index 0000000..e511542 --- /dev/null +++ b/org.tizen.codecoverage/32_TIZEN_SDK_icon.png diff --git a/org.tizen.codecoverage/META-INF/MANIFEST.MF b/org.tizen.codecoverage/META-INF/MANIFEST.MF new file mode 100644 index 0000000..d12708f --- /dev/null +++ b/org.tizen.codecoverage/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %Bundle-Name +Bundle-SymbolicName: org.tizen.codecoverage;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.tizen.codecoverage.Activator +Bundle-Vendor: %Bundle-Vendor +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.resources, + org.eclipse.cdt.core, + org.eclipse.cdt.debug.core, + org.eclipse.debug.core, + org.eclipse.linuxtools.gcov, + org.tizen.common +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Import-Package: org.tizen.common.connection, + org.tizen.nativecpp.editors.manifest, + org.eclipse.cdt.managedbuilder.core, + org.tizen.sdblib +Export-Package: org.tizen.codecoverage.helper diff --git a/org.tizen.codecoverage/NOTICE b/org.tizen.codecoverage/NOTICE new file mode 100644 index 0000000..87d9729 --- /dev/null +++ b/org.tizen.codecoverage/NOTICE @@ -0,0 +1,2 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
diff --git a/org.tizen.codecoverage/OSGI-INF/l10n/bundle.properties b/org.tizen.codecoverage/OSGI-INF/l10n/bundle.properties new file mode 100644 index 0000000..e035427 --- /dev/null +++ b/org.tizen.codecoverage/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,2 @@ +Bundle-Vendor = The Linux Foundation +Bundle-Name = Tizen Native Development Tools Code Coverage diff --git a/org.tizen.codecoverage/about.ini b/org.tizen.codecoverage/about.ini new file mode 100644 index 0000000..fc8fa16 --- /dev/null +++ b/org.tizen.codecoverage/about.ini @@ -0,0 +1,32 @@ +# about.ini +# contains information about a feature +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# "%key" are externalized strings defined in about.properties +# This file does not need to be translated. + +# Property "aboutText" contains blurb for "About" dialog (translated) +aboutText=%blurb + +# Property "windowImage" contains path to window icon (16x16) +# needed for primary features only + +# Property "featureImage" contains path to feature image (32x32) +featureImage=32_TIZEN_SDK_icon.png + +# Property "aboutImage" contains path to product image (500x330 or 115x164) +# needed for primary features only + +# Property "appName" contains name of the application (translated) +# needed for primary features only + +# Property "welcomePage" contains path to welcome page (special XML-based format) +# welcomePage=$nl$/welcome.xml + +# Property "welcomePerspective" contains the id of the perspective in which the +# welcome page is to be opened. +# optional + +# Property "tipsAndTricksHref" contains the Help topic href to a tips and tricks page +# optional +# tipsAndTricksHref=/org.tizen.doc.user/tips/tizen_tips.htm + diff --git a/org.tizen.codecoverage/about.mappings b/org.tizen.codecoverage/about.mappings new file mode 100644 index 0000000..1acdd7b --- /dev/null +++ b/org.tizen.codecoverage/about.mappings @@ -0,0 +1,6 @@ +# about.mappings +# contains fill-ins for about.properties and bundle.properties +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file does not need to be translated. +0=Tizen Native Development Tools Code Coverage +1=date-time diff --git a/org.tizen.codecoverage/about.properties b/org.tizen.codecoverage/about.properties new file mode 100644 index 0000000..5c2e80a --- /dev/null +++ b/org.tizen.codecoverage/about.properties @@ -0,0 +1,12 @@ +# about.properties +# contains externalized strings for about.ini +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# fill-ins are supplied by about.mappings +# This file should be translated. + +blurb={0}\n\ +\n\ +Version : {featureVersion}\n\ +Build id : {1}\n\ +\n\ +Visit https://developer.tizen.org \n
\ No newline at end of file diff --git a/org.tizen.codecoverage/build.properties b/org.tizen.codecoverage/build.properties new file mode 100644 index 0000000..b644643 --- /dev/null +++ b/org.tizen.codecoverage/build.properties @@ -0,0 +1,11 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/,\ + OSGI-INF/,\ + 32_TIZEN_SDK_icon.png,\ + about.ini,\ + about.mappings,\ + about.properties diff --git a/org.tizen.codecoverage/icons/toolbar_icon.gif b/org.tizen.codecoverage/icons/toolbar_icon.gif Binary files differnew file mode 100644 index 0000000..62a7d86 --- /dev/null +++ b/org.tizen.codecoverage/icons/toolbar_icon.gif diff --git a/org.tizen.codecoverage/plugin.xml b/org.tizen.codecoverage/plugin.xml new file mode 100644 index 0000000..475aa6d --- /dev/null +++ b/org.tizen.codecoverage/plugin.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> +<extension + point="org.eclipse.ui.perspectiveExtensions"> + <perspectiveExtension + targetID="org.tizen.nativeapp.perspective"> + <actionSet + id="org.tizen.gcov.actionSet"> + </actionSet> + </perspectiveExtension> +</extension> +<extension + point="org.eclipse.ui.actionSets"> + <actionSet + description="GcovActionSet" + id="org.tizen.gcov.actionSet" + label="GcovActionSet" + visible="false"> + <action + class="org.tizen.codecoverage.actions.GcovAction" + icon="icons/toolbar_icon.gif" + id="org.tizen.gcov.actions.gcovAction" + label="GcovAction" + style="push" + toolbarPath="tizen/CodeCoverage" + tooltip="Code Coverage"> + </action> + </actionSet> +</extension> +</plugin> diff --git a/org.tizen.codecoverage/src/org/tizen/codecoverage/Activator.java b/org.tizen.codecoverage/src/org/tizen/codecoverage/Activator.java new file mode 100644 index 0000000..d0eb6c8 --- /dev/null +++ b/org.tizen.codecoverage/src/org/tizen/codecoverage/Activator.java @@ -0,0 +1,70 @@ +/* + * Code Coverage + * + * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JeongHwan kim <jeonghwan0613.kim@samsung.com> + * JuYoung Kim <j0.kim@samsung.com> + * + * 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 + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +package org.tizen.codecoverage; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.score.gcov"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/org.tizen.codecoverage/src/org/tizen/codecoverage/actions/GcovAction.java b/org.tizen.codecoverage/src/org/tizen/codecoverage/actions/GcovAction.java new file mode 100644 index 0000000..2469d46 --- /dev/null +++ b/org.tizen.codecoverage/src/org/tizen/codecoverage/actions/GcovAction.java @@ -0,0 +1,112 @@ +/* + * Code Coverage + * + * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JeongHwan kim <jeonghwan0613.kim@samsung.com> + * JuYoung Kim <j0.kim@samsung.com> + * + * 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 + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +package org.tizen.codecoverage.actions; + +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.linuxtools.gcov.view.CovView; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; +import org.tizen.codecoverage.helper.GcovHelper; + + +/** + * Our sample action implements workbench action delegate. The action proxy will + * be created by the workbench and shown in the UI. When the user tries to use + * the action, this delegate will be created and execution will be delegated to + * it. + * + * @see IWorkbenchWindowActionDelegate + */ +public class GcovAction implements IWorkbenchWindowActionDelegate { + // private IWorkbenchWindow window; + + private IProject project; + /** + * The constructor. + */ + public GcovAction() { + project = null; + } + + /** + * The action has been activated. The argument of the method represents the + * 'real' action sitting in the workbench UI. + * + * @see IWorkbenchWindowActionDelegate#run + */ + public void run(IAction action) { + GcovHelper.run(project); + } + + /** + * Selection in the workbench has been changed. We can change the state of + * the 'real' action here if we want, but this can only happen after the + * delegate has been created. + * + * @see IWorkbenchWindowActionDelegate#selectionChanged + */ + public void selectionChanged(IAction action, ISelection selection) { + Object obj = null; + + if (selection instanceof TreeSelection) { + TreeSelection _selection = (TreeSelection) selection; + + if (_selection != null) { + obj = _selection.getFirstElement(); + } + } + + if (obj != null) { + if (obj instanceof IResource) { + project = ((IResource) obj).getProject(); + } else if (obj instanceof ICElement) { + IResource resource = ((ICElement) obj).getResource(); + project = ((IResource) resource).getProject(); + } + } + } + + /** + * We can use this method to dispose of any system resources we previously + * allocated. + * + * @see IWorkbenchWindowActionDelegate#dispose + */ + public void dispose() { + } + + /** + * We will cache window object in order to be able to provide parent shell + * for the message dialog. + * + * @see IWorkbenchWindowActionDelegate#init + */ + public void init(IWorkbenchWindow window) { + } +} diff --git a/org.tizen.codecoverage/src/org/tizen/codecoverage/helper/GcovHelper.java b/org.tizen.codecoverage/src/org/tizen/codecoverage/helper/GcovHelper.java new file mode 100644 index 0000000..ff487f4 --- /dev/null +++ b/org.tizen.codecoverage/src/org/tizen/codecoverage/helper/GcovHelper.java @@ -0,0 +1,176 @@ +/* + * Code Coverage + * + * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * JeongHwan kim <jeonghwan0613.kim@samsung.com> + * JuYoung Kim <j0.kim@samsung.com> + * + * 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 + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +package org.tizen.codecoverage.helper; + +import java.util.List; + +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.linuxtools.gcov.parser.CovManager; +import org.eclipse.linuxtools.gcov.view.CovView; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.tizen.common.connection.ConnectionPlugin; +import org.tizen.nativecpp.editors.manifest.PackageModel; +import org.tizen.sdblib.IDevice; +import org.tizen.sdblib.SyncService; +import org.tizen.sdblib.SyncService.SyncResult; + +public class GcovHelper { + final static String DATA_DIR = "/data/"; + + static public void run(IProject project) { + // null check project + if (project == null || !project.exists()) { + final String message = "Please select a project."; + Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell(); + MessageDialog.openInformation(s, "Project not found", message); + return; + } + + IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice(); + if (currentDevice == null) { +// final String message = "Target device is not running"; +// Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell(); +// MessageDialog.openError(s, "Gcov Error", message); + return; + } + + String binary = GcovHelper.getBinary(project); + if (binary == null) { + final String message = "Gcov failed. Binary file not found.\n" + + "Please check Build Settings"; + Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell(); + MessageDialog.openError(s, "Gcov Error", message); + return; + } + + try { + GcovHelper.downloadGcdaFile(binary); + } catch (Exception e) { + final String message = "Gcov failed. Coverage data file not found."; + Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell(); + MessageDialog.openError(s, "Gcov Error", message); + return; + } + CovView.displayCovResults(binary); + } + + private static String getBinary(IResource binary, String target) { + if (binary.getLocation().toOSString().contains( target ) && binary.getLocation().lastSegment().contains(binary.getProject().getName())) { + return binary.getLocation().toOSString(); + } + return null; + } + // FIXME searching a selected binary is not complete + // This part is affected IDE launch part + // TODO Fix this method + public static String getBinary(IProject project) { + String binary = null; + ICProject cproject = CoreModel.getDefault().create(project); + if (cproject == null) { + return binary; + } + IBinary[] bins = null; + try { + bins = cproject.getBinaryContainer().getBinaries(); + } catch (CModelException e) { + e.printStackTrace(); + } + + IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice(); + if (currentDevice.isEmulator()) { + for( IBinary bin : bins ) { + binary = getBinary( bin.getResource(), "Emulator" ); + break; + } + } else { + for( IBinary bin : bins ) { + binary = getBinary( bin.getResource(), "Device" ); + break; + } + } + return binary; + } + + static IProject getProject(IPath file) { + IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file); + return c.getProject(); + } + + public static void downloadGcdaFile(String binaryPath) throws Exception { + CovManager cvrgeMnger = null; + List<String> gcdaPaths = null; + cvrgeMnger = new CovManager(binaryPath); + try { + gcdaPaths = cvrgeMnger.getGCDALocations(); + } catch (Exception e) { + final String message = "Gcov failed. Binary not found."; + Shell s = PlatformUI.getWorkbench().getDisplay().getActiveShell(); + MessageDialog.openError(s, "Gcov Error", message); + return; + } + // download gcda file + IPath file = new Path(binaryPath); + IProject project = getProject(file); + String targetPath = getGcdaPath(project); + + @SuppressWarnings("restriction") + IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice(); + @SuppressWarnings("restriction") + SyncService syncService = currentDevice.getSyncService(); + + for (String gcdaPath: gcdaPaths) { + int start = gcdaPath.lastIndexOf('/') + 1; + int end = gcdaPath.length(); + String gcdaFile = gcdaPath.substring(start, end); + String srcFile = targetPath + gcdaFile; + String dstFile = gcdaPath; + @SuppressWarnings("restriction") + SyncResult syncSuccess = syncService.pullFile(srcFile, dstFile, SyncService.getNullProgressMonitor()); + if (syncSuccess.getCode() != SyncService.RESULT_OK) { + Exception e = new Exception(); + throw e; + } + } + } + + static public String getGcdaPath(IProject project) { + String installPath = getPackageInstallPath(project); + String gcdaPath = installPath + DATA_DIR; + return gcdaPath; + } + + static String getPackageInstallPath(IProject project) { + PackageModel packageModel = PackageModel.newInstance(project); + String installPath = packageModel.getAppInstallPath(); + return installPath; + } +} |