diff options
29 files changed, 2882 insertions, 44 deletions
diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/.classpath b/org.tizen.dynamicanalysis.ide.native.eplugin/.classpath new file mode 100644 index 0000000..ad32c83 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/.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.dynamicanalysis.ide.native.eplugin/.project b/org.tizen.dynamicanalysis.ide.native.eplugin/.project new file mode 100644 index 0000000..f86ad36 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.tizen.dynamicanalysis.ide.eplugin</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.dynamicanalysis.ide.native.eplugin/.settings/org.eclipse.jdt.core.prefs b/org.tizen.dynamicanalysis.ide.native.eplugin/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3218d70 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Thu Jan 05 15:34:31 KST 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/32_TIZEN_SDK_icon.png b/org.tizen.dynamicanalysis.ide.native.eplugin/32_TIZEN_SDK_icon.png Binary files differnew file mode 100644 index 0000000..e511542 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/32_TIZEN_SDK_icon.png diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/META-INF/MANIFEST.MF b/org.tizen.dynamicanalysis.ide.native.eplugin/META-INF/MANIFEST.MF new file mode 100644 index 0000000..da36a8e --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/META-INF/MANIFEST.MF @@ -0,0 +1,37 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Tizen Dynamic Analyzer Plugin +Bundle-SymbolicName: org.tizen.dynamicanalysis.ide.eplugin;singleton:=true +Bundle-Version: 2.1.0.qualifier +Bundle-Activator: org.tizen.dynamicanalysis.ide.eplugin.Activator +Bundle-Vendor: The Linux Foundation +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ui, + org.tizen.common, + org.eclipse.core.resources;bundle-version="3.7.100", + org.eclipse.ui.ide;bundle-version="3.7.0", + org.eclipse.core.filesystem;bundle-version="1.3.100", + org.eclipse.cdt.core;bundle-version="5.3.1", + org.eclipse.debug.core;bundle-version="3.7.0", + org.eclipse.debug.ui;bundle-version="3.7.101", + org.eclipse.cdt.managedbuilder.core;bundle-version="8.0.1", + org.tizen.nativecommon;bundle-version="1.0.0", + org.eclipse.cdt.ui;bundle-version="5.3.2", + org.eclipse.cdt.launch, + org.eclipse.cdt.debug.core +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Import-Package: org.eclipse.cdt.debug.core.sourcelookup, + org.eclipse.cdt.debug.internal.ui.launch, + org.eclipse.cdt.debug.mi.core, + org.eclipse.cdt.launch, + org.eclipse.cdt.launch.internal.ui, + org.eclipse.jface.text, + org.eclipse.ui.texteditor, + org.tizen.common.connection, + org.tizen.common.gom.launch, + org.tizen.common.sign.preferences, + org.tizen.common.sign.util, + org.tizen.sdblib, + org.tizen.sdblib.service, + org.tizen.sdblib.util diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/OSGI-INF/l10n/bundle.properties b/org.tizen.dynamicanalysis.ide.native.eplugin/OSGI-INF/l10n/bundle.properties new file mode 100644 index 0000000..adb5f38 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/OSGI-INF/l10n/bundle.properties @@ -0,0 +1 @@ +Bundle-Vendor = Samsung Electronics diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/about.ini b/org.tizen.dynamicanalysis.ide.native.eplugin/about.ini new file mode 100644 index 0000000..fc8fa16 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/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.dynamicanalysis.ide.native.eplugin/about.mappings b/org.tizen.dynamicanalysis.ide.native.eplugin/about.mappings new file mode 100644 index 0000000..d28243a --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/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 Dynamic Analyzer IDE Plugin +1=date-time diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/about.properties b/org.tizen.dynamicanalysis.ide.native.eplugin/about.properties new file mode 100644 index 0000000..5c2e80a --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/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.dynamicanalysis.ide.native.eplugin/build.properties b/org.tizen.dynamicanalysis.ide.native.eplugin/build.properties new file mode 100644 index 0000000..30a2dac --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/build.properties @@ -0,0 +1,15 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + OSGI-INF/,\ + icon/ + + +daProfileShortcutID = org.tizen.dynamicanalysis.ide.eplugin.profileShortcutID +daProfileConfigTypeID = org.tizen.dynamicanalysis.ide.eplugin.profileConfigTypeID +daProfileDelegateID = org.tizen.dynamicanalysis.ide.eplugin.profileDelegateID +daProfileConfigTypeImageID = org.tizen.dynamicanalysis.ide.eplugin.profileConfigTypeImageID +daProfileConfigTabGroupID = org.tizen.dynamicanalysis.ide.eplugin.profileConfigTabGroupID +daProfileConfigTabsID = org.tizen.dynamicanalysis.ide.eplugin.profileConfigTabsID diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/icon/alt_window_16.png b/org.tizen.dynamicanalysis.ide.native.eplugin/icon/alt_window_16.png Binary files differnew file mode 100755 index 0000000..99ce735 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/icon/alt_window_16.png diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/plugin.xml b/org.tizen.dynamicanalysis.ide.native.eplugin/plugin.xml new file mode 100755 index 0000000..41b9e8a --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/plugin.xml @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<!-- ide-native-eplugin --> +<plugin> + <extension + point="org.eclipse.ui.startup"> + <startup + class="org.tizen.dynamicanalysis.ide.eplugin.communication.ServerStartup"> + </startup> + </extension> + + <extension + point="org.eclipse.debug.ui.launchShortcuts"> + <shortcut + class="org.tizen.dynamicanalysis.ide.eplugin.launch.TizenNativeApplicationDAShortcut" + icon="icon/alt_window_16.png" + id="%daProfileShortcutID" + label="Profile With Dynamic Analyzer" + modes="profile"> + <contextualLaunch> + <enablement> + <with variable="selection"> + <count value="1"/> + <iterate> + <and> + <or> + <instanceof value="org.eclipse.cdt.core.model.IBinary"/> + <instanceof value="org.eclipse.cdt.core.model.ICProject"/> + <test + forcePluginActivation="true" + property="org.eclipse.cdt.launch.isExecutable"/> + <test + forcePluginActivation="true" + property="org.eclipse.cdt.launch.isCProject"/> + <and> + <instanceof value="org.eclipse.ui.IFileEditorInput"/> + <adapt type="org.eclipse.core.resources.IResource"> + <adapt type="org.eclipse.cdt.core.model.ICElement"/> + </adapt> + </and> + </or> + <not> + <adapt type="org.eclipse.core.resources.IResource"> + <test + property="org.eclipse.core.resources.projectNature" + value="org.tizen.tizentest.nature"> + </test> + </adapt> + </not> + </and> + </iterate> + </with> + </enablement> + </contextualLaunch> + <description + mode="profile" + description="Profile With Dynamic Analyzer"/> + <configurationType + id="%daProfileConfigTypeID"> + </configurationType> + </shortcut> + </extension> + + <extension + point="org.eclipse.debug.core.launchConfigurationTypes"> + <launchConfigurationType + id="%daProfileConfigTypeID" + name="Profile With Dynamic Analyzer" + public="true"> + </launchConfigurationType> + </extension> + + <extension + point="org.eclipse.debug.core.launchDelegates"> + <launchDelegate + delegate="org.tizen.dynamicanalysis.ide.eplugin.launch.TizenNativeApplicationDADelegate" + id="%daProfileDelegateID" + modes="profile" + name="Profile With Dynamic Analyzer" + sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator" + sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer" + type="%daProfileConfigTypeID"> + </launchDelegate> + </extension> + + <extension + point="org.eclipse.debug.ui.launchConfigurationTypeImages"> + <launchConfigurationTypeImage + configTypeID="%daProfileConfigTypeID" + icon="icon/alt_window_16.png" + id="%daProfileConfigTypeImageID"> + </launchConfigurationTypeImage> + </extension> + + <extension + point="org.eclipse.debug.ui.launchConfigurationTabGroups"> + <launchConfigurationTabGroup + class="org.tizen.dynamicanalysis.ide.eplugin.launch.TizenNativeApplicationDAConfigurationTabGroup" + id="%daProfileConfigTabGroupID" + type="%daProfileConfigTypeID"> + </launchConfigurationTabGroup> + </extension> + + + <extension + id="org.tizen.dynamicanalysis.ide.eplugin.dacustom" + name="org.tizen.dynamicanalysis.ide.eplugin.dacustom" + point="org.tizen.common.connection.tools"> + <tools + packagename="dacustom" + sourcepath="/on-demand"> + </tools> + </extension> + +</plugin> diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/Activator.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/Activator.java new file mode 100644 index 0000000..35db85c --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/Activator.java @@ -0,0 +1,59 @@ +/* +* Dynamic Analyzer +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Jungwook Ryu <jungwook.ryu@samsung.com> +* Jaewon Lim <jaewon81.lim@samsung.com> +* Juyoung Kim <j0.kim@samsung.com> +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Contributors: +* - S-Core Co., Ltd +* +*/ + +package org.tizen.dynamicanalysis.ide.eplugin; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.tizen.dynamicanalysis.ide.eplugin.communication.ServerStartup; + +public class Activator implements BundleActivator { + public static final String PLUGIN_ID = "org.tizen.dynamicanalyzer";//$NON-NLS-1$ + public static final String PROFILE_MODE = "profile";//$NON-NLS-1$ + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + ServerStartup.stopServerThread(); + } +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/DALog.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/DALog.java new file mode 100755 index 0000000..b5f7896 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/DALog.java @@ -0,0 +1,220 @@ +/* +* Dynamic Analyzer +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Jungwook Ryu <jungwook.ryu@samsung.com> +* Hyunjong Park <phjwithyou.park@samsung.com> +* Juyoung Kim <j0.kim@samsung.com> +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Contributors: +* - S-Core Co., Ltd +* +*/ + +package org.tizen.dynamicanalysis.ide.eplugin; + +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.tizen.common.core.application.InstallPathConfig; + +public class DALog { + + private static boolean LOG_TO_FILE = true; + + static File file = null; + static FileOutputStream fos = null; + static DataOutputStream dos = null; + static boolean setInit = false; + static final String IDE_LOG_NAME = "da_ide_log_";//$NON-NLS-1$ + static final int IDE_LOG_SAVE_COUNT = 3; + + private static boolean init() { + + if (LOG_TO_FILE) { + if(null == InstallPathConfig.getUserDataPath()){ + LOG_TO_FILE = false; + System.out.println("exception -NULL InstallPathConfig.getUserDataPath()"); + return false; + } + StringBuffer logPath = new StringBuffer(); + logPath.append(InstallPathConfig.getUserDataPath()) + .append(File.separatorChar).append("dynamic-analyzer")//$NON-NLS-1$ + .append(File.separatorChar).append("logs");//$NON-NLS-1$ + File logsSaveFolderPath = new File(logPath.toString()); + if (!logsSaveFolderPath.exists()) { + if (!logsSaveFolderPath.mkdirs()) { + // if it failed creating folder + return false; + } + } + + if(manageIDELogFileCount(logsSaveFolderPath)){ + SimpleDateFormat format = new SimpleDateFormat( + "yyyy_MM_dd_HH-mm-ss", //$NON-NLS-1$ + Locale.KOREA); + Date date = new Date(); + String logFileName = IDE_LOG_NAME + format.format(date); + + logPath.append(File.separatorChar).append(logFileName); + + file = new File(logPath.toString()); + file.getParentFile().mkdirs(); + try { + fos = new FileOutputStream(file); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + dos = new DataOutputStream(fos); + }else{ + LOG_TO_FILE = false; + } + } + return true; + } + + private static boolean manageIDELogFileCount(File logsSaveFolderPath) { + File[] logFiles = logsSaveFolderPath.listFiles(); + if(null == logFiles){ + System.out.println("exception - manageIDELogFileCount"); + LOG_TO_FILE = false; + return false; + } + List<File> listLogFile = sortIDELogFile(logFiles); + int logSize = listLogFile.size(); + for (int i = IDE_LOG_SAVE_COUNT - 1; i < logSize; i++) { + if (!listLogFile.get(i).delete()) { + // if it failed deleting the file, do nothing this time. it will try again later. + } + } + return true; + } + + private static List<File> sortIDELogFile(File[] logFiles) { + List<File> ideLogFile = new ArrayList<File>(); + for (File file : logFiles) { + if (file.getName().contains(IDE_LOG_NAME)) { + ideLogFile.add(file); + } + } + Collections.sort(ideLogFile, new Comparator<File>() { + public int compare(File object1, File object2) { + return object2.getName().compareTo(object1.getName()); + } + }); + return ideLogFile; + } + + public static void printLog(final String logMsg) { + + if (LOG_TO_FILE) { + if (setInit == false) { + setInit = true; + if(!init()){ + return; + } + } + + try { + dos.writeBytes(logMsg); + } catch (IOException e) { + e.printStackTrace(); + } + try { + dos.writeChars("\n");//$NON-NLS-1$ + } catch (IOException e) { + e.printStackTrace(); + } + try { + dos.flush(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + System.out.println(logMsg); + } + + } + + public static void printLog(Exception errMsg) { + + if (LOG_TO_FILE) { + if (setInit == false) { + setInit = true; + init(); + } + try { + dos.writeBytes(printStackTraceToString(errMsg)); + } catch (IOException e) { + e.printStackTrace(); + } + try { + dos.writeChars("\n");//$NON-NLS-1$ + } catch (IOException e) { + e.printStackTrace(); + } + try { + dos.flush(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + errMsg.printStackTrace(); + } + + } + + private static String printStackTraceToString(Throwable e) { + StringBuilder sb = new StringBuilder(); + String returnString = null; + sb.append(e.toString()); + sb.append("\n");//$NON-NLS-1$ + StackTraceElement element[] = e.getStackTrace(); + for (int idx = 0; idx < element.length; idx++) { + sb.append("\tat ");//$NON-NLS-1$ + sb.append(element[idx].toString()); + sb.append("\n");//$NON-NLS-1$ + } + returnString = sb.toString(); + return returnString; + } + + public static void dlgErrorMessage(final String title, final String message) { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + MessageDialog.openError(window.getShell(), title, message); + } + }); + } + +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/DAServerManager.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/DAServerManager.java new file mode 100644 index 0000000..f65990b --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/DAServerManager.java @@ -0,0 +1,451 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Jaewon Lim <jaewon81.lim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.communication; + +import java.io.BufferedWriter; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.RandomAccessFile; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.Socket; +import java.net.UnknownHostException; +import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; +import java.util.List; + +import org.eclipse.ui.PlatformUI; +import org.tizen.common.core.application.InstallPathConfig; +import org.tizen.dynamicanalysis.ide.eplugin.DALog; +import org.tizen.dynamicanalysis.ide.eplugin.launch.ProjectType; +import org.tizen.dynamicanalysis.ide.eplugin.nl.Labels; + +public class DAServerManager extends Thread { + private final static int MAXBUFSIZE = 1024; + + private static DAServerManager instance; + + private Socket ideClientSocket = null; + private BufferedWriter writer = null; + private int serverPort = 0; + private boolean reservedTraceApplication = false; + + private String reservedDeviceName = ""; //$NON-NLS-1$ + private ProjectType reservedProjectType; //$NON-NLS-1$ + private String reservedBinaryOfTarget; //$NON-NLS-1$ + private String reservedExecutablePath; //$NON-NLS-1$ + private List<String> reservedLocalPackagePathList; //$NON-NLS-1$ + + private final String IDE_DA_COMMUNICATION_TYPE_1 = "STATUS"; //$NON-NLS-1$ + private final String IDE_DA_COMMUNICATION_TYPE_2 = "RUN"; //$NON-NLS-1$ + private final String IDE_DA_COMMUNICATION_TYPE_3 = "SOURCE"; //$NON-NLS-1$ + + private final String IDE_DA_COMMUNICATION_SEPARATOR = "`,"; //$NON-NLS-1$ + private final String IDE_DA_COMMUNICATION_TYPE_1_RECORD = "record"; //$NON-NLS-1$ + private final String IDE_DA_COMMUNICATION_TYPE_1_STOP = "stop"; //$NON-NLS-1$ + + private final static String DANAIC_ANALYZER = "dynamic-analyzer"; //$NON-NLS-1$ + private final static String SAVE = "save"; //$NON-NLS-1$ + + private final static String ACTIVE_DA_PLUGIN = "active_da_plugin"; //$NON-NLS-1$ + private final String CURRENT_ACTIVE_IDE_PORT = "current_active_ide_port"; //$NON-NLS-1$ + + private static boolean recvDAReadyStatus = false; + + public synchronized static DAServerManager getInstance() { + if (instance == null) { + instance = new DAServerManager(); + } + return instance; + } + + private DAServerManager() { + } + + public Socket getClientSocket() { + return ideClientSocket; + } + + public void reserveTraceApplication(String deviceName, ProjectType projectType, + String binaryOfTarget, String executablePath, List<String> localPackagePathList) { + reservedTraceApplication = true; + reservedDeviceName = deviceName; + reservedProjectType = projectType; + reservedBinaryOfTarget = binaryOfTarget; + reservedExecutablePath = executablePath; + reservedLocalPackagePathList = localPackagePathList; + } + + // main + public void run() throws IndexOutOfBoundsException { + if (checkInstalledTizenSDK() != true) { + DALog.printLog("failed - Tizen SDK is not installed "); + } else { + while (true) { + resetSocket(); + + DALog.printLog(" Start IDE"); + + while (true) { + if (checkDASingleton() == true) { // Active IDE + break; + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + DALog.printLog("IDE is terminated!"); + } + } + + // Read IDE Port + if (readActiveServerPort() != true) { + DALog.printLog("Failed Read Active IDE Port");//$NON-NLS-1$ + continue; + } + + // Connect IDE Socket + if (setServerSocket() != true) { + DALog.printLog("Failed Connect IDE Socket");//$NON-NLS-1$ + continue; + } + + DALog.printLog("Connected DA"); + // Communication IDE - DA + while (true) { + + checkReservedTraceApplication(); + + // Waiting Receive Message + waitingDataReceive(); + + DALog.printLog("Disconneced DA"); //$NON-NLS-1$ + resetSocket(); + break; + } + } + } + } + + public static boolean checkDASingleton() { + boolean isActiveDA = false; + StringBuffer savePath = new StringBuffer(); + savePath.append(InstallPathConfig.getUserDataPath()) + .append(File.separatorChar).append(DANAIC_ANALYZER) + .append(File.separatorChar).append(SAVE) + .append(File.separatorChar); + + File folder = new File(savePath.toString()); + if (!folder.exists()) { + if (!folder.mkdirs()) { + // if it failed creating folder + return false; + } + } + + savePath.append(ACTIVE_DA_PLUGIN); + + FileLock fileLock = null; + FileChannel fchannel = null; + + File file = new File(savePath.toString()); + try { + fchannel = new RandomAccessFile(file, "rw").getChannel();//$NON-NLS-1$ + fileLock = fchannel.tryLock(); + if (fileLock == null) { + isActiveDA = true; + } + } catch (FileNotFoundException e1) { + e1.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fchannel != null) { + try { + fchannel.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + return isActiveDA; + } + + private boolean checkInstalledTizenSDK() { + String installPath = InstallPathConfig.getUserDataPath(); + File logs = new File(installPath.toString()); + if (!logs.exists()) { + return false; + } + return true; + } + + private void checkReservedTraceApplication() { + if (reservedTraceApplication == true) { + reservedTraceApplication = false; + runTraceApplication(reservedDeviceName, reservedProjectType, reservedBinaryOfTarget, + reservedExecutablePath, reservedLocalPackagePathList); + } + } + + private void waitingDataReceive() { + int dataSize = 0; + try { + InputStream in = ideClientSocket.getInputStream(); + while (true) { + byte arr[] = new byte[MAXBUFSIZE]; + + dataSize = in.read(arr); // Waiting Receive Message From DA + if (dataSize > 0) { + String msg = new String(arr); + commandReceiveMessage(msg); + arr = null; + } else { + break; + } + } + } catch (IOException e) { + DALog.printLog("DAServerManager - waitingDataReceive - IOException"); + } + } + + public String getPortFile() { + StringBuffer savePath = new StringBuffer(); + savePath.append(InstallPathConfig.getUserDataPath()) + .append(File.separatorChar).append(DANAIC_ANALYZER) + .append(File.separatorChar).append(SAVE); + + File saveDir = new File(savePath.toString()); + if (!saveDir.exists()) { + if (!saveDir.mkdirs()) { + // if it failed creating folder, Do nothing. + // Exception should be handled in caller. + } + } + + savePath.append(File.separatorChar).append(CURRENT_ACTIVE_IDE_PORT); + return savePath.toString(); + } + + private boolean readActiveServerPort() { + boolean bSuccess = true; + // read port from current_active_ide_port + FileInputStream fis = null; + DataInputStream dis = null; + try { + fis = new FileInputStream(getPortFile()); + dis = new DataInputStream(fis); + try { + serverPort = dis.readInt(); + } catch (IOException e) { + e.printStackTrace(); + bSuccess = false; + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + bSuccess = false; + } finally { + try { + if (null != fis) { + fis.close(); + fis = null; + } + if (null != dis) { + dis.close(); + dis = null; + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + return bSuccess; + } + + private boolean setServerSocket() { + try { + ideClientSocket = new Socket(Proxy.NO_PROXY); /* handle environment in Proxy network */ + InetSocketAddress socketAddress = new InetSocketAddress(InetAddress.getLocalHost(), serverPort); + ideClientSocket.connect(socketAddress); + } catch (UnknownHostException e) { + DALog.printLog(e); + ideClientSocket = null; + return false; + } catch (IOException e) { + DALog.printLog(e); + ideClientSocket = null; + return false; + } + return true; + } + + // Send Message DA Status + public boolean sendDAStatusMessage() { + setRecvDAReadyStatus(false); + StringBuffer command = new StringBuffer(); + command.append(IDE_DA_COMMUNICATION_TYPE_1) + .append(IDE_DA_COMMUNICATION_SEPARATOR) + .append("").append(IDE_DA_COMMUNICATION_SEPARATOR)//$NON-NLS-1$ + .append("");//$NON-NLS-1$ + try { + sendData(command.toString()); + } catch (IOException e) { + DALog.printLog("DAServerManager - sendDAStatusMessage - IOException"); + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + Labels.MESSAGE_FAIL_TO_LAUNCH_PROJECT); + } + synchronized (this) { + try { + this.wait(10000); + } catch (InterruptedException e) { + DALog.printLog("DAServerManager - sendDAStatusMessage - getRecvDAReadyStatus().wait(10000)"); + DALog.printLog(e); + } + } + return getRecvDAReadyStatus(); + } + + // Send Message Trace Application +// public void runTraceApplication(final String strDevice, final String appID, +// final String appName) { +// StringBuffer command = new StringBuffer(); +// command.append(IDE_DA_COMMUNICATION_TYPE_2) +// .append(IDE_DA_COMMUNICATION_SEPARATOR).append(strDevice) +// .append(IDE_DA_COMMUNICATION_SEPARATOR).append(appID) +// .append(IDE_DA_COMMUNICATION_SEPARATOR).append(appName); +// try { +// sendData(command.toString()); +// } catch (IOException e) { +// DALog.printLog("DAServerManager - runTraceApplication - IOException"); +// DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, +// Labels.MESSAGE_FAIL_TO_LAUNCH_PROJECT); +// } +// } + + public void runTraceApplication(String strDevice, ProjectType projectType, + String binaryOfTarget, String executablePath, List<String> localPackagePathList) { + StringBuffer command = new StringBuffer(); + command.append(IDE_DA_COMMUNICATION_TYPE_2) + .append(IDE_DA_COMMUNICATION_SEPARATOR).append(strDevice) + .append(IDE_DA_COMMUNICATION_SEPARATOR).append(projectType.ordinal()) + .append(IDE_DA_COMMUNICATION_SEPARATOR).append(binaryOfTarget) + .append(IDE_DA_COMMUNICATION_SEPARATOR).append(executablePath); + if (localPackagePathList != null) { + for (int i = 0; i < localPackagePathList.size(); i++) { + command.append(IDE_DA_COMMUNICATION_SEPARATOR).append(localPackagePathList.get(i)); + } + } + try { + sendData(command.toString()); + } catch (IOException e) { + DALog.printLog("DAServerManager - runTraceApplication - IOException"); + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + Labels.MESSAGE_FAIL_TO_LAUNCH_PROJECT); + } + } + + // Management Receive Message + private void commandReceiveMessage(final String msg) { + DALog.printLog("commandReceiveMessage : " + msg);//$NON-NLS-1$ + String[] msgArray = msg.split(IDE_DA_COMMUNICATION_SEPARATOR); + int size = msgArray.length; + if (size == 3) { + if (msgArray[0].equals(IDE_DA_COMMUNICATION_TYPE_1)) { + setDAStatus(msgArray); + } else if (msgArray[0].equals(IDE_DA_COMMUNICATION_TYPE_3)) { + viewSouceLine(msgArray); + } else { + DALog.printLog("receive message is not valid type");//$NON-NLS-1$ + } + } else { + DALog.printLog("receive message is not valid ");//$NON-NLS-1$ + } + } + + private synchronized void setDAStatus(final String[] msgArray) { // DA Status + if (msgArray[1].equals(IDE_DA_COMMUNICATION_TYPE_1_RECORD)) { + setRecvDAReadyStatus(false); + } else if (msgArray[1].equals(IDE_DA_COMMUNICATION_TYPE_1_STOP)) { + setRecvDAReadyStatus(true); + } else { + DALog.printLog("receive message is not valid");//$NON-NLS-1$ + } + this.notify(); + } + + private void viewSouceLine(final String[] msgArray) { + String srcpath = msgArray[1]; + String strSourceLine = msgArray[2].trim(); + int nline = Integer.parseInt(strSourceLine); + PlatformUI.getWorkbench().getDisplay().asyncExec(new OpenEditManager(srcpath, nline)); + } + + private boolean sendData(final String msg) throws IOException { + DALog.printLog("SendData " + msg);//$NON-NLS-1$ + boolean bSuccess = true; + try { + if (null != ideClientSocket) { + writer = new BufferedWriter(new OutputStreamWriter( + ideClientSocket.getOutputStream())); + writer.write(msg); + writer.flush(); + } + } catch (IOException e) { + bSuccess = false; + } finally { + bSuccess = false; + } + return bSuccess; + } + + private void resetSocket() { + ideClientSocket = null; + writer = null; + if (null != ideClientSocket) { + try { + ideClientSocket.close(); + ideClientSocket = null; + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public boolean getRecvDAReadyStatus() { + return recvDAReadyStatus; + } + + public void setRecvDAReadyStatus(boolean status) { + recvDAReadyStatus = status; + } +}
\ No newline at end of file diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/FocusManager.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/FocusManager.java new file mode 100644 index 0000000..c060272 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/FocusManager.java @@ -0,0 +1,110 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Jaewon Lim <jaewon81.lim@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.communication; + +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; + +import org.tizen.common.core.application.InstallPathConfig; +import org.tizen.common.util.OSChecker; +import org.tizen.dynamicanalysis.ide.eplugin.DALog; + +public class FocusManager extends Thread { + private String[] cmds; + + private int selfPid; + + public FocusManager() { + selfPid = -1; + } + + public FocusManager(final int iPid) { + selfPid = iPid; + } + + public void run() { + String pid = "";//$NON-NLS-1$ + String Processid = "";//$NON-NLS-1$ + + if (selfPid > 0) { + pid = String.valueOf(selfPid); + } else { + // get IDE pid. + ManagementFactory.getRuntimeMXBean(); + RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); + Processid = rt.getName(); + pid = Processid.substring(0, Processid.indexOf("@")); //$NON-NLS-1$ + } + + cmds = new String[] { getDynAnalyzerPath(), pid }; + executeCommand(cmds); + } + + private String getDynAnalyzerPath() { + String path = ""; + if (OSChecker.isWindows()) { + path = InstallPathConfig.getSDKPath() + "/tools/dynamic-analyzer/tool/windowactivator.bat";//$NON-NLS-1$ + } else if (OSChecker.isMAC()) { + path = InstallPathConfig.getSDKPath() + "/tools/dynamic-analyzer/tool/macoswindowactivator.sh";//$NON-NLS-1$ + } else { + path = InstallPathConfig.getSDKPath() + "/tools/dynamic-analyzer/tool/windowactivator.sh";//$NON-NLS-1$ + } + DALog.printLog("activator : " + path);//$NON-NLS-1$ + return path; + } + + private int executeCommand(final String[] cmds) { + + Runtime runtime = null; + Process process = null; + int retValue = 0; + + try { + if (cmds.length == 0) { + retValue = -1; + } else { + runtime = Runtime.getRuntime(); + process = runtime.exec(cmds); + + if (process != null) { + process.waitFor(); + retValue = process.exitValue(); + } + } + } catch (IOException e) { + DALog.printLog("executeCommand - IOException"); + } catch (InterruptedException e) { + DALog.printLog("executeCommand - InterruptedException"); + } finally { + if (process != null) { + process.destroy(); + } + } + return retValue; + } +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/OpenEditManager.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/OpenEditManager.java new file mode 100644 index 0000000..040ea5d --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/OpenEditManager.java @@ -0,0 +1,155 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Jaewon Lim <jaewon81.lim@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +package org.tizen.dynamicanalysis.ide.eplugin.communication; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.texteditor.IDocumentProvider; +import org.eclipse.ui.texteditor.ITextEditor; + +import org.tizen.dynamicanalysis.ide.eplugin.DALog; + +public class OpenEditManager implements Runnable +{ + private ITextEditor _editor; + private IDocument _document; + private String filepath; + private int fileline; + + public OpenEditManager(String path, int line) + { + this.filepath = path; + this.fileline = line; + } + + private void initEditor( final String path ) throws IOException + { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IFile ifile = root.getFile(new Path(path)); + IEditorPart part = null; + + if (!ifile.exists()) + { + File targetfile = new File(path); + if(targetfile.exists() && targetfile.isFile()) + { + IFileStore filestore = EFS.getLocalFileSystem().getStore(targetfile.toURI()); + part = openEditor(filestore); + } + else + { + throw new IOException("Source file (" + path + ") is not found.");//$NON-NLS-1$ //$NON-NLS-2$ + } + } + else + { + part = openEditor(ifile); + } + + if(part != null && (part instanceof ITextEditor)) + { + _editor = (ITextEditor)part; + IDocumentProvider provider = _editor.getDocumentProvider(); + _document = provider.getDocument(_editor.getEditorInput()); + + } + } + + private IEditorPart openEditor(final IFile ifile) { + // editor open + IWorkbenchPage page = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + try { + IDE.openEditor(page, ifile); + } catch (PartInitException e) { + DALog.printLog("OpenEditManager - openEditor - PartInitException"); + } + + return page.getActiveEditor(); + } + + private IEditorPart openEditor(final IFileStore ifilestr) { + IWorkbenchPage page = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + try { + IDE.openEditorOnFileStore(page, ifilestr); + } catch (PartInitException e) { + DALog.printLog("OpenEditManager - openEditor - PartInitException"); + } + + return page.getActiveEditor(); + } + + private ITextEditor getEditor() + { + return _editor; + } + + public void run(){ + try + { + int offset; + initEditor(this.filepath); + if(this.fileline > 0) + { + offset = _document.getLineOffset(this.fileline - 1); + } + else + { + offset = 0; + } + getEditor().setHighlightRange(offset, 0, true); //move cursor + + FocusManager fm = new FocusManager(); + fm.start(); + } + catch (IOException e) + { + DALog.printLog("OpenEditManager - run - IOException"); + } + catch (BadLocationException e) + { + DALog.printLog("OpenEditManager - run - BadLocationException"); + } + } + +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/ServerStartup.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/ServerStartup.java new file mode 100644 index 0000000..73e2787 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/communication/ServerStartup.java @@ -0,0 +1,49 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Jaewon Lim <jaewon81.lim@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.communication; + + + +import org.eclipse.ui.IStartup; + +public class ServerStartup implements IStartup { + + private static DAServerManager server; + + @Override + public void earlyStartup() { + server = DAServerManager.getInstance(); + Thread thread = server; + thread.start(); + } + + public static void stopServerThread() { + if (server != null) { // case : IDE CLI mode (headless build) + server.interrupt(); + } + } +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/DynamicOptionValueHandler.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/DynamicOptionValueHandler.java new file mode 100644 index 0000000..6356321 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/DynamicOptionValueHandler.java @@ -0,0 +1,77 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Sanghyun Lee <sanghyunnim.lee@samsung.com> + * Hyunjong Park <phjwithyou.park@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.launch; + +import org.eclipse.cdt.managedbuilder.core.IBuildObject; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; +import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; +import org.eclipse.cdt.managedbuilder.core.IOption; +import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo; + +@SuppressWarnings("restriction") +public class DynamicOptionValueHandler implements IManagedOptionValueHandler { + + @Override + public boolean handleValue(IBuildObject configuration, + IHoldsOptions holder, IOption option, String extraArgument, + int event) { + + IConfiguration config = null; + + // handle just APPLY + if (event != IManagedOptionValueHandler.EVENT_OPEN + && event != IManagedOptionValueHandler.EVENT_APPLY + && event != IManagedOptionValueHandler.EVENT_SETDEFAULT) { + return false; + } + + if (configuration instanceof FolderInfo) { + return false; + } else { + config = (IConfiguration) configuration; + } + return false; + } + + @Override + public boolean isDefaultValue(IBuildObject configuration, + IHoldsOptions holder, IOption option, String extraArgument) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isEnumValueAppropriate(IBuildObject configuration, + IHoldsOptions holder, IOption option, String extraArgument, + String enumValue) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/ProjectType.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/ProjectType.java new file mode 100644 index 0000000..08b1304 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/ProjectType.java @@ -0,0 +1,34 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.launch; + +public enum ProjectType { + NONE, + OSP, // 1 + EFL, // 2 + WEBAPP, // 3 + LIBRARY // 4 +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDAConfigurationTabGroup.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDAConfigurationTabGroup.java new file mode 100644 index 0000000..43020e0 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDAConfigurationTabGroup.java @@ -0,0 +1,33 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Sanghyun Lee <sanghyunnim.lee@samsung.com> + * Hyunjong Park <phjwithyou.park@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.launch; + +import org.tizen.nativecommon.launch.ui.TizenLaunchConfigurationTabGroup; + +public class TizenNativeApplicationDAConfigurationTabGroup extends TizenLaunchConfigurationTabGroup { +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDADelegate.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDADelegate.java new file mode 100644 index 0000000..4c92e57 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDADelegate.java @@ -0,0 +1,553 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Sanghyun Lee <sanghyunnim.lee@samsung.com> + * Hyunjong Park <phjwithyou.park@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.launch; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.tizen.common.IApplicationConfiguration; +import org.tizen.common.TizenPlatformConstants; +import org.tizen.common.core.application.InstallPathConfig; +import org.tizen.common.rds.RdsDeployer; +import org.tizen.common.rds.ui.preference.RdsPreferencePage; +import org.tizen.common.util.HostUtil; +import org.tizen.common.util.OSChecker; +import org.tizen.dynamicanalysis.ide.eplugin.Activator; +import org.tizen.dynamicanalysis.ide.eplugin.DALog; +import org.tizen.dynamicanalysis.ide.eplugin.communication.DAServerManager; +import org.tizen.dynamicanalysis.ide.eplugin.nl.Labels; +import org.tizen.nativecommon.IXMLStore; +import org.tizen.nativecommon.ProjectUtil; +import org.tizen.nativecommon.build.CommonBuildConstants; +import org.tizen.nativecommon.build.CommonBuildMessages; +import org.tizen.nativecommon.build.CommonProjectDependentPackager; +import org.tizen.nativecommon.build.ProjectTypeManager; +import org.tizen.nativecommon.build.exception.SBIException; +import org.tizen.nativecommon.launch.AbstractTizenCLaunchDelegate; +import org.tizen.nativecommon.launch.IProjectLaunchCommand; +import org.tizen.nativecommon.launch.LaunchUtils; +import org.tizen.nativecommon.launch.NativeRdsDeployer; +import org.tizen.nativecommon.launch.TizenLaunchCommand; +import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants; +import org.tizen.nativecommon.launch.TizenLaunchConsole; +import org.tizen.nativecommon.launch.TizenLaunchInfo; +import org.tizen.nativecommon.launch.TizenLaunchMessages; +import org.tizen.sdblib.IDevice; +import org.tizen.sdblib.service.SyncResult; + +public class TizenNativeApplicationDADelegate extends + AbstractTizenCLaunchDelegate { + private final static String TOOLS = "tools";// $NON_NLS-1$ + private final static String DYNAMIC_ANALYZER = "dynamic-analyzer";// $NON_NLS-1$ + private final static String PKG_TYPE = CommonProjectDependentPackager.DEFAULT; + private boolean bSuccessBuild = true; + IProject project; + + private static class ExtFilter implements FilenameFilter { + private String ext; + + public ExtFilter(String ext) { + this.ext = ext; + } + + public boolean accept(File dir, String name) { + return name.endsWith(ext); + } + } + + @Override + public void launch(ILaunchConfiguration config, String mode, + ILaunch launch, IProgressMonitor monitor) throws CoreException { + DALog.printLog("Launch delegate"); + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRoot root = workspace.getRoot(); + project = root.getProject(config.getAttribute( + ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "")); //$NON-NLS-1$ + + String device = LaunchUtils.getCurrentDeployDevice().toString(); + ProjectType projectType = ProjectType.NONE; + String binaryOfTarget = ""; + String executablePath = ""; + List<String> localPackagePathList = null; + + projectType = ProjectType.OSP; + verifyCProjectConfigurationSettings(config); + try { + verityUnitTestProject(project); + verifyIMEProject(project); + LaunchUtils.verifyExecutableProject(project); + IDevice currentDevice = LaunchUtils.getCurrentDeployDevice(); + if (currentDevice == null) { + throw new CoreException(new Status(Status.ERROR, + Activator.PLUGIN_ID, Status.INFO, + TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE, null)); + } + + if (isDAReady()) { + if (packaging_upload_install(project, currentDevice)) { + IApplicationConfiguration adapter = (IApplicationConfiguration) project + .getAdapter(IApplicationConfiguration.class); + binaryOfTarget = adapter.getAppId(); + runDynamicAnalyzer(device, projectType, binaryOfTarget, executablePath, localPackagePathList); + } + } + } catch (CoreException e) { + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, e.getMessage()); + } finally { + rollBackBuildConfigSetting(project); + if (!launch.isTerminated()) { + launch.terminate(); + } + ILaunchManager launchManager = DebugPlugin.getDefault() + .getLaunchManager(); + launchManager.removeLaunch(launch); + } + } + + private boolean isDAReady() { + if (DAServerManager.getInstance().getClientSocket() != null) { + return DAServerManager.getInstance().sendDAStatusMessage(); + } + return true; + } + + private boolean packaging_upload_install(final IProject project, + final IDevice currentDevice) { + bSuccessBuild = true; + + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + ProgressMonitorDialog dialog = new ProgressMonitorDialog(window + .getShell()); + + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) { + monitor.beginTask(Labels.MESSAGE_PREPARING_PROFILE, + 1); + + IProjectLaunchCommand manifest = ProjectUtil + .getProjectManifest(project); + CommonProjectDependentPackager packager = ProjectTypeManager + .getProjectPackagerInstance(project); + + RdsDeployer rdsDeployer = null; + try { + if (RdsPreferencePage.isRdsMode(project)) { + TizenLaunchCommand tizenCommand = new TizenLaunchCommand( + currentDevice); + rdsDeployer = new NativeRdsDeployer( + project, + currentDevice, + tizenCommand, + TizenLaunchConsole + .getTizenConsole(), + CommonProjectDependentPackager.DEFAULT + .toLowerCase(), monitor); + rdsDeployer.setInterestList(TizenLaunchInfo + .makeInterestList(project)); + rdsDeployer.setIgnoreList(TizenLaunchInfo + .makeIgnoreList(project)); + if (!rdsDeployer.deploy()) { + if (packager == null) { + bSuccessBuild = false; + return; + } + buildPackage(monitor, project, + manifest, packager); + normalDeploy(monitor, project, + currentDevice, manifest, + packager); + } + rdsDeployer.pushResInfoFile(); + } else { + if (packager == null) { + bSuccessBuild = false; + return; + } + buildPackage(monitor, project, manifest, + packager); + normalDeploy(monitor, project, + currentDevice, manifest, packager); + } + LaunchUtils.touchExecutableFile(project); + } catch (CoreException e) { + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + e.getMessage()); + bSuccessBuild = false; + monitor.done(); + } finally { + if (rdsDeployer != null) { + try { + rdsDeployer.close(); + } catch (IOException e) { + DALog.dlgErrorMessage( + "Failed to close RDSDeployer", + e.getMessage()); + } + } + } + + if (monitor.isCanceled()) { + bSuccessBuild = false; + monitor.done(); + } + } + }); + } catch (InvocationTargetException e) { + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + Labels.MESSAGE_FAIL_TO_BUILD_PROJECT); + bSuccessBuild = false; + } catch (InterruptedException e) { + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + Labels.MESSAGE_FAIL_TO_BUILD_PROJECT); + bSuccessBuild = false; + } + } + }); + + return bSuccessBuild; + } + + private void buildPackage(IProgressMonitor monitor, IProject project, + IProjectLaunchCommand manifest, + CommonProjectDependentPackager packager) throws CoreException { + try { + monitor.beginTask(Labels.MESSAGE_PREPARING_PROFILE, 3); + monitor.subTask(Labels.MESSAGE_BUILDING_PACKAGE); + + manifest.doMultiAppPreProcess(packager, monitor); + + packager.buildPackage(PKG_TYPE, + TizenPlatformConstants.SIGNING_DEFAULT, true); + } catch (SBIException e) { + newCoreException(Labels.MESSAGE_FAIL_TO_BUILD_PROJECT, null); + } + } + + private void normalDeploy(IProgressMonitor monitor, IProject project, + IDevice currentDevice, IProjectLaunchCommand manifest, + CommonProjectDependentPackager packager) throws CoreException { + if (!packager.checkPackageFile(PKG_TYPE)) { + DALog.dlgErrorMessage(CommonBuildMessages.BUILD_RESULT, + CommonBuildMessages.FAIL_TO_BUILD_PACKAGE); + bSuccessBuild = false; + monitor.done(); + return; + } + + File packageFile = null; + String packageDirectory = File.separatorChar + + ManagedBuildManager.getBuildInfo(project) + .getConfigurationName() + File.separatorChar; + IPath packagePath = new Path(project.getLocation().toString() + + packageDirectory); + packageFile = findPackageFile(packagePath.toFile(), + "." + PKG_TYPE.toLowerCase(), project);//$NON-NLS-1$ + + if (packageFile == null) { + newCoreException(CommonBuildMessages.FAIL_TO_BUILD_PACKAGE, null); + } + + try { + uploadApp(monitor, project, currentDevice, packageFile); + installApp(monitor, manifest, currentDevice, packageFile); + } catch (Exception e) { + newCoreException(e.getMessage(), null); + } finally { + monitor.done(); + } + } + + private void uploadApp(IProgressMonitor monitor, IProject project, + IDevice currentDevice, File packageFile) throws CoreException { + try { + monitor.worked(2); + monitor.subTask(TizenLaunchMessages.TRANSFER_PACKAGE); + + String destDirectoryPath = TizenPlatformConstants + .getAppTmpDirectory(currentDevice); + + String srcFilePath = packageFile.getAbsoluteFile() + .getCanonicalPath(); + + SyncResult syncSuccess = currentDevice.getSyncService().push( + srcFilePath, currentDevice.getFileEntry(destDirectoryPath)); // Fixxed + + if (!syncSuccess.isOk()) { + newCoreException(TizenLaunchMessages.CANNOT_TRANSFER_FILE, null); + } + } catch (IOException e) { + newCoreException(TizenLaunchMessages.CANNOT_TRANSFER_FILE, null); + } + } + + @SuppressWarnings("deprecation") + private void installApp(IProgressMonitor monitor, + IProjectLaunchCommand manifest, IDevice currentDevice, + File packageFile) throws CoreException, Exception { + monitor.worked(1); + monitor.subTask(TizenLaunchMessages.INSTALL_PACKAGE); + + String packageName = manifest.getPackageName(); + String listCmd = manifest.getListCommand(); + String listCmdRet = manifest.getListCommandResult(); + TizenLaunchCommand launcher = new TizenLaunchCommand(currentDevice); + launcher.run(listCmd); + + String endLine = launcher.getEndLine(); + if (endLine != null && endLine.contains(listCmdRet)) { + String removeCmd = manifest.getRemoveCommand(packageName); + + launcher.run(removeCmd); + } + + String installCmd = manifest.getInstallCommand(packageFile, + PKG_TYPE.toLowerCase(), currentDevice); + launcher.run(installCmd); + } + + private File findPackageFile(final File searchPath, final String ext, + IProject project) { + File[] packageFiles = searchPath.listFiles(new ExtFilter(ext)); + + if (packageFiles == null || packageFiles.length == 0) { + return null; + } + + IProjectLaunchCommand manifest = ProjectUtil + .getProjectManifest(project); + String packageName = manifest.getPackageName(); + if (packageName == null) { + return null; + } + + for (File file : packageFiles) { + String fileName = file.getName(); + if (fileName.contains(packageName)) { + return file; + } + } + + return null; + } + + private void newCoreException(final String message, Throwable exception) + throws CoreException { + Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, + exception); + throw new CoreException(status); + } + + private boolean executeWindowsCommand(final String command) { + if (command == null) { + return false; + } + Process proc = null; + Runtime runtime = Runtime.getRuntime(); + + String[] fullCommand = new String[] { + "cmd", "/c", command, "isAutoStart" };//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + boolean bSuccuss = true; + + try { + proc = runtime.exec(fullCommand); + Thread.sleep(1000); + } catch (IOException e) { + bSuccuss = false; + DALog.printLog("TizenNativeApplicationProfileDelegate - executeWindowsCommand - IOException"); + } catch (InterruptedException e) { + bSuccuss = false; + DALog.printLog("TizenNativeApplicationProfileDelegate - executeWindowsCommand - InterruptedException"); + } finally { + if (proc != null) { + proc.destroy(); + } + } + + return bSuccuss; + } + + private void verityUnitTestProject(IProject project) throws CoreException { + String[] natures = project.getDescription().getNatureIds(); + for (String nature : natures) { + if (nature.equals(CommonBuildConstants.UNIT_TEST_NATURE_ID)) { + newCoreException(Labels.MESSAGE_NOT_SUPPORT_UNIT_TEST_PROJECT, + null); + } + } + } + + private void verifyIMEProject(IProject project) throws CoreException { + @SuppressWarnings("deprecation") + IXMLStore store = ProjectUtil.getXmlStore(project); + if (store.isImeCategory()) { + newCoreException(Labels.MESSAGE_NOT_SUPPORT_IME_PROJECT, null); + } + } + + private void runDynamicAnalyzer(String device, ProjectType projectType, String binaryOfTarget, + String executablePath, List<String> localPackagePathList) { + if (DAServerManager.getInstance().getClientSocket() == null) { + StringBuffer command = new StringBuffer(); + + if (OSChecker.isWindows()) { + command.append(InstallPathConfig.getSDKPath() + + File.separatorChar + TOOLS + File.separator + + DYNAMIC_ANALYZER + File.separatorChar + + DYNAMIC_ANALYZER + ".exe");// $NON_NLS-1$ + } else if (OSChecker.isMAC()) { + command.append(InstallPathConfig.getSDKPath() + + File.separatorChar + TOOLS + File.separator + + DYNAMIC_ANALYZER + File.separatorChar + + DYNAMIC_ANALYZER + ".app"// $NON_NLS-1$ + + File.separatorChar + "Contents"// $NON_NLS-1$ + + File.separatorChar + "MacOS"// $NON_NLS-1$ + + File.separatorChar + DYNAMIC_ANALYZER); + } else { + command.append(InstallPathConfig.getSDKPath() + + File.separatorChar + TOOLS + File.separator + + DYNAMIC_ANALYZER + File.separatorChar + + DYNAMIC_ANALYZER); + } + + File file = new File(command.toString()); + if (file.isFile() == false) { + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + Labels.MESSAGE_DYNAMIC_ANALYZER_IS_NOT_INSTALLED); + } else { + if (OSChecker.isWindows()) { + if (executeWindowsCommand(command.toString()) == false) { + return; + } + } else { + command.append(" isAutoStart&");//$NON-NLS-1$ + HostUtil.execute(command.toString()); + } + } + + DAServerManager.getInstance().reserveTraceApplication(device, projectType, binaryOfTarget, executablePath, localPackagePathList); + } else { + DAServerManager.getInstance().runTraceApplication(device, projectType, binaryOfTarget, executablePath, localPackagePathList); + } + } + + private void rollBackBuildConfigSetting(IProject project) { + String prevBuildConfigName = TizenNativeApplicationDAShortcut + .getPrevBuildConfigName(); + if (prevBuildConfigName != null) { + ManagedBuildManager.getBuildInfo(project).setDefaultConfiguration( + prevBuildConfigName); + } + } + + @Override + protected String getPluginID() { + return Activator.PLUGIN_ID; + } + + protected String getBuildConfigName(ILaunchConfiguration config) + throws CoreException { + String buildConfigName = config + .getAttribute( + TizenLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_NAME, + ""); + + if (buildConfigName.isEmpty()) { + IConfiguration configuration = ManagedBuildManager.getBuildInfo( + project).getDefaultConfiguration(); + return configuration.getName(); + } else { + return buildConfigName; + } + } + + protected IConfiguration getBuildConfiguration(String buildConfigName, + IProject project) throws CoreException { + IConfiguration configuration = null; + IConfiguration[] configurations = ManagedBuildManager + .getBuildInfo(project).getManagedProject().getConfigurations(); + for (IConfiguration c : configurations) { + if (c.getName().equals(buildConfigName)) { + configuration = c; + break; + } + } + if (configuration == null) { + newCoreException( + TizenLaunchMessages.BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE, + null); + } + + return configuration; + } + + protected String getArguments(ILaunchConfiguration config) + throws CoreException { + String appPath = config.getAttribute( + ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); + String arguments = org.eclipse.cdt.launch.LaunchUtils + .getProgramArguments(config); + String executableWithArguments = ""; + if (arguments != null && !arguments.equals("")) { + executableWithArguments = appPath + " " + arguments; + } else { + executableWithArguments = appPath; + } + return executableWithArguments; + } +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDAMainTab.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDAMainTab.java new file mode 100644 index 0000000..e446f38 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDAMainTab.java @@ -0,0 +1,165 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Sanghyun Lee <sanghyunnim.lee@samsung.com> + * Hyunjong Park <phjwithyou.park@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.launch; + +import java.util.ArrayList; + +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.cdt.ui.CElementLabelProvider; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.ui.dialogs.ElementListSelectionDialog; +import org.tizen.nativecommon.build.CommonBuildConstants; +import org.tizen.nativecommon.launch.ui.TizenMainTab; + +public class TizenNativeApplicationDAMainTab extends TizenMainTab { + @Override + @SuppressWarnings("restriction") + protected void updateProgramFromConfig(ILaunchConfiguration config) { + if (fProgText != null) { + String programName = EMPTY_STRING; + + try { + if (!isUnitTestProject(config)) { + programName = config.getAttribute( + ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, + EMPTY_STRING); + } + } catch (CoreException e) { + e.printStackTrace(); + } + + fProgText.setText(programName); + } + } + + @Override + @SuppressWarnings("restriction") + protected void updateProjectFromConfig(ILaunchConfiguration config) { + String projectName = EMPTY_STRING; + String configName = EMPTY_STRING; + try { + if (!isUnitTestProject(config)) { + projectName = config.getAttribute( + ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, + EMPTY_STRING); + configName = config + .getAttribute( + ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, + EMPTY_STRING); + } + } catch (CoreException ce) { + LaunchUIPlugin.log(ce); + } + + if (!fProjText.getText().equals(projectName)) + fProjText.setText(projectName); + updateBuildConfigCombo(configName); + } + + @Override + @SuppressWarnings("restriction") + protected ICProject chooseCProject() { + try { + ICProject[] projects = getCProjects(); + ArrayList<ICProject> filteredProjects = new ArrayList<ICProject>(); + + for (ICProject project : projects) { + String[] natures = project.getProject().getDescription() + .getNatureIds(); + boolean isUnittestProject = false; + + for (String nature : natures) { + if (nature.equals(CommonBuildConstants.UNIT_TEST_NATURE_ID)) { + isUnittestProject = true; + break; + } + } + if (!isUnittestProject) { + filteredProjects.add(project); + } + } + + ILabelProvider labelProvider = new CElementLabelProvider(); + ElementListSelectionDialog dialog = new ElementListSelectionDialog( + getShell(), labelProvider); + dialog.setTitle(LaunchMessages.CMainTab_Project_Selection); + dialog.setMessage(LaunchMessages.CMainTab_Choose_project_to_constrain_search_for_program); + dialog.setElements(filteredProjects.toArray()); + + ICProject cProject = getCProject(); + if (cProject != null) { + dialog.setInitialSelections(new Object[] { cProject }); + } + if (dialog.open() == Window.OK) { + return (ICProject) dialog.getFirstResult(); + } + } catch (CModelException e) { + LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$ + } catch (CoreException e) { + e.printStackTrace(); + } + return null; + } + + @SuppressWarnings("restriction") + public static boolean isUnitTestProject(ILaunchConfiguration config) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRoot root = workspace.getRoot(); + + try { + String pName = config.getAttribute( + ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, + EMPTY_STRING); + + if (!pName.equals(EMPTY_STRING)) { + String[] natures = root.getProject(pName).getDescription() + .getNatureIds(); + + for (String nature : natures) { + if (nature.equals(CommonBuildConstants.UNIT_TEST_NATURE_ID)) { + return true; + } + } + } + } catch (CoreException e) { + return false; + } + + return false; + } +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDAShortcut.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDAShortcut.java new file mode 100755 index 0000000..e754321 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationDAShortcut.java @@ -0,0 +1,223 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Sanghyun Lee <sanghyunnim.lee@samsung.com> + * Hyunjong Park <phjwithyou.park@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.launch; + +import java.io.File; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.tizen.common.gom.launch.GomLaunchData; +import org.tizen.common.util.SWTUtil; +import org.tizen.dynamicanalysis.ide.eplugin.DALog; +import org.tizen.dynamicanalysis.ide.eplugin.nl.Labels; +import org.tizen.nativecommon.IXMLStore; +import org.tizen.nativecommon.ProjectUtil; +import org.tizen.nativecommon.build.CommonBuildConstants; +import org.tizen.nativecommon.launch.LaunchUtils; +import org.tizen.nativecommon.launch.TizenLaunchConfiguration; +import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants; +import org.tizen.nativecommon.launch.ui.shortcut.TizenLaunchShortcut; +import org.tizen.sdblib.IDevice; + +public class TizenNativeApplicationDAShortcut extends TizenLaunchShortcut { + private static String prevBuildConfigName = null; + + static String getPrevBuildConfigName() { + String returnValue = prevBuildConfigName; + prevBuildConfigName = null; + + return returnValue; + } + + @Override + public void launch(ISelection selection, String mode) { + IStructuredSelection structuredSelection = (IStructuredSelection) selection; + Object firstElement = structuredSelection.getFirstElement(); + + IProject project = null; + if (firstElement instanceof IBinary) { + IBinary binary = (IBinary) firstElement; + project = binary.getCProject().getProject(); + } else if (firstElement instanceof IResource) { + IResource resource = (IResource) firstElement; + project = resource.getProject(); + } + if (project != null) { + try { + if (isUnitTestProject(project)) { + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + Labels.MESSAGE_NOT_SUPPORT_UNIT_TEST_PROJECT); + } else if (isIMEProject(project)) { + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + Labels.MESSAGE_NOT_SUPPORT_IME_PROJECT); + } else { + searchAndLaunch(((IStructuredSelection) selection).toArray(), + mode); + } + } catch (CoreException e) { + rollBackBuildConfigSetting(project); + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, e.getMessage()); + } + } + } + + @Override + public void launch(IEditorPart editor, String mode) { + IFileEditorInput input = (IFileEditorInput) editor.getEditorInput(); + IProject project = input.getFile().getProject(); + + if (project != null) { + try { + if (isUnitTestProject(project)) { + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + Labels.MESSAGE_NOT_SUPPORT_UNIT_TEST_PROJECT); + } else if (isIMEProject(project)) { + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, + Labels.MESSAGE_NOT_SUPPORT_IME_PROJECT); + } else { + searchAndLaunch(new Object[] { editor.getEditorInput() }, mode); + } + } catch (CoreException e) { + rollBackBuildConfigSetting(project); + DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, e.getMessage()); + } + } + } + + private ILaunchConfiguration createLaunchConfiguration(GomLaunchData data) { + ILaunchConfiguration config = null; + IProject project = data.getProject(); + IDevice device = LaunchUtils.getCurrentDeployDevice(); + + try { + String projectName = project.getName(); + String configName = data.getLaunchConfigurationName(); + + ILaunchConfigurationType configType = getCLaunchConfigType(); + + ILaunchConfigurationWorkingCopy wc = configType.newInstance( + null, + getLaunchManager().generateLaunchConfigurationName( + configName)); + TizenLaunchConfiguration tc = new TizenLaunchConfiguration(wc, + device); + tc.setDefaults(); + + String programName = ProjectUtil.getDefaultConfiguration(project) + .getName() + + File.separatorChar + + ProjectUtil.getBinaryName(project); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, + programName); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, + projectName); + wc.setMappedResources(new IResource[] { project }); + wc.setAttribute( + ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, "");//$NON-NLS-1$ + LaunchUtils.setDeviceToLaunchConfiguration(wc, device); + + setStopAtMain(wc, project); + + ICProjectDescription projDes = CCorePlugin.getDefault() + .getProjectDescription(project); + if (projDes != null) { + String buildConfigID = projDes.getActiveConfiguration().getId(); + wc.setAttribute( + ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, + buildConfigID); + String buildConfigName = projDes.getActiveConfiguration() + .getName(); + wc.setAttribute( + TizenLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_NAME, + buildConfigName); + config = wc.doSave(); + } + } catch (CoreException e) { + e.printStackTrace(); + } + return config; + } + + @Override + public ILaunchConfigurationType getCLaunchConfigType() { + return getLaunchManager().getLaunchConfigurationType( + "%daProfileConfigTypeID");//$NON-NLS-1$ + } + + private boolean isIMEProject(IProject project) { + @SuppressWarnings("deprecation") + IXMLStore store = ProjectUtil.getXmlStore(project); + return store.isImeCategory(); + } + + private boolean isUnitTestProject(IProject project) throws CoreException { + String[] natures; + natures = project.getDescription().getNatureIds(); + for (String nature : natures) { + if (nature.equals(CommonBuildConstants.UNIT_TEST_NATURE_ID)) { + return true; + } + } + + return false; + } + + + private void rollBackBuildConfigSetting(IProject project) { + if (prevBuildConfigName != null) { + ManagedBuildManager.getBuildInfo(project).setDefaultConfiguration( + prevBuildConfigName); + prevBuildConfigName = null; + } + } + + @Override + public void smartLaunch(final GomLaunchData data) { + final ILaunchConfiguration configuration = createLaunchConfiguration(data); + SWTUtil.syncExec(new Runnable() { + @Override + public void run() { + DebugUITools.launch(configuration, data.getMode()); + } + }); + } +}
\ No newline at end of file diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/nl/Labels.java b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/nl/Labels.java new file mode 100644 index 0000000..443b619 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/nl/Labels.java @@ -0,0 +1,55 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Jungwook Ryu <jungwook.ryu@samsung.com> + * Sanghyun Lee <sanghyunnim.lee@samsung.com> + * Hyunjong Park <phjwithyou.park@samsung.com> + * Juyoung Kim <j0.kim@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalysis.ide.eplugin.nl; + +import org.eclipse.osgi.util.NLS; + +public class Labels extends NLS { + private static final String BUNDLE_NAME = "org.tizen.dynamicanalysis.ide.eplugin.nl.Labels"; //$NON-NLS-1$] + public static String MESSAGE_ERROR; + public static String MESSAGE_FAIL_TO_COPY_DA_PROBE; + public static String MESSAGE_FAIL_TO_DELETE_DA_PROBE; + public static String MESSAGE_FAIL_TO_LAUNCH_PROJECT; + public static String MESSAGE_FAIL_TO_BUILD_PROJECT; + + public static String MESSAGE_PREPARING_PROFILE; + public static String MESSAGE_BUILDING_PACKAGE; + public static String MESSAGE_DYNAMIC_ANALYZER_IS_NOT_INSTALLED; + public static String MESSAGE_NOT_SUPPORT_UNIT_TEST_PROJECT; + public static String MESSAGE_NOT_SUPPORT_IME_PROJECT; + + public static String MESSAGE_ANOTHER_IDE_CONNECTED; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Labels.class); + } + + private Labels() { + } +} diff --git a/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/nl/Labels.properties b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/nl/Labels.properties new file mode 100644 index 0000000..feec3f8 --- /dev/null +++ b/org.tizen.dynamicanalysis.ide.native.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/nl/Labels.properties @@ -0,0 +1,13 @@ +MESSAGE_ERROR=Error +MESSAGE_FAIL_TO_COPY_DA_PROBE=Fail to copy DA probe. +MESSAGE_FAIL_TO_DELETE_DA_PROBE=Fail to delete DA probe. +MESSAGE_FAIL_TO_LAUNCH_PROJECT=Fail to launch project. +MESSAGE_FAIL_TO_BUILD_PROJECT=Fail to build project. + +MESSAGE_PREPARING_PROFILE=Preparing profile... +MESSAGE_BUILDING_PACKAGE=Building package... +MESSAGE_DYNAMIC_ANALYZER_IS_NOT_INSTALLED=Dynamic Analyzer is not installed. + +MESSAGE_NOT_SUPPORT_UNIT_TEST_PROJECT=DA does not support tizen unit test project. +MESSAGE_NOT_SUPPORT_IME_PROJECT=Certain application categories, such as "ime", cannot be launched by "Profile As". +MESSAGE_ANOTHER_IDE_CONNECTED= Dynamic Analyzer has been connected to another IDE\n You need to close the prior Dynamic Analyzer first.
\ No newline at end of file diff --git a/package/build.linux b/package/build.linux index fd288c5..057c7b8 100755 --- a/package/build.linux +++ b/package/build.linux @@ -1,5 +1,10 @@ #!/bin/bash -xe + +build_path=${SRCDIR}/build_result +#package_name=$1 +pde_name=$2 + __copy_necessary_binaries() { echo "add necessary files." @@ -24,62 +29,385 @@ __copy_necessary_binaries() __set_parameter() { - build_script_path=${ROOTDIR}/pde-build + build_id=${package_name} + build_type=N + build_result_directory=${build_type}.${build_id} + build_result_path="$build_path/$build_result_directory" + ide_root_path_name=ide + + case ${TARGET_OS} in + ubuntu-32) + archive_platform_name=linux + windowing=gtk + architecture=x86 + if [ ! "x${pde_name}" = "x" ] + then + ide_root_path_name=eclipse-pde/eclipse + fi + ;; + windows-32) + archive_platform_name=win32 + windowing=win32 + architecture=x86 + if [ ! "x${pde_name}" = "x" ] + then + ide_root_path_name=eclipse-pde/eclipse + fi + ;; + ubuntu-64) + archive_platform_name=linux + windowing=gtk + architecture=x86_64 + if [ ! "x${pde_name}" = "x" ] + then + ide_root_path_name=eclipse-pde/eclipse + fi + ;; + windows-64) + archive_platform_name=win32 + windowing=win32 + architecture=x86_64 + if [ ! "x${pde_name}" = "x" ] + then + ide_root_path_name=eclipse-pde/eclipse + fi + ;; + macos-64) + archive_platform_name=macosx + windowing=cocoa + architecture=x86_64 + if [ ! "x${pde_name}" = "x" ] + then + ide_root_path_name=eclipse-pde/eclipse + fi + ;; + *) + echo "${TARGET_OS} is not support yet." + ;; + esac +} + +__set_build_script_path() +{ + build_script_path=${ROOTDIR}/pde-build +} + +__set_build_parameter() +{ + result_archive_file=${build_id}-${archive_platform_name}.${windowing}.${architecture}.zip + __set_build_script_path + reference_ide_path=${ROOTDIR}/${ide_root_path_name} +} + +__clean_build_environment() +{ + if [ -d $build_path ] + then + echo "Build result directory : [$build_path]" + else + echo "Make build result directory [$build_path]" + mkdir -p $build_path + fi + + echo "Remove legacy build files..." + if [ -d ${build_result_path}/${archive_platform_name}.${windowing}.${architecture} ] + then + rm -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture} + fi + if [ -e ${build_result_path}/${result_archive_file} ] + then + rm -rf ${build_result_path}/${result_archive_file} + fi + if [ -d ${build_path}/tmp ] + then + rm -rf ${build_path}/tmp + fi + + if [ -d ${build_path}/buildRepo ] + then + rm -rf ${build_path}/buildRepo + fi + + rm -rf ${build_path}/*.xml + rm -rf ${build_path}/*.properties + rm -rf ${build_path}/*.clean + + + if [ -d $build_path/plugins ] + then + echo "plugins directory recreate..." + rm -rf $build_path/plugins + mkdir $build_path/plugins + else + echo "Make plugins directory..." + mkdir $build_path/plugins + fi + if [ -d $build_path/features/ ] + then + echo "features directory recreate..." + rm -rf $build_path/features + mkdir $build_path/features + else + echo "Make features directory..." + mkdir $build_path/features + fi + +} + +__copy_build_sources() +{ + echo "Copy features from $SRCDIR to $build_path/features" + temp_dir="`mktemp -d /tmp/ide.XXXXX`" + cp -r $SRCDIR/* $temp_dir + cp -r $temp_dir/* $build_path/features + rm -rf $temp_dir + + echo "Copy plugins from $SRCDIR to $build_path/plugins" + temp_dir="`mktemp -d /tmp/ide.XXXXX`" + cp -r $SRCDIR/* $temp_dir + cp -r $temp_dir/* $build_path/plugins + rm -rf $temp_dir + + if [ "x${package_name}" = "xdynamic-analysis-ide-eplugin" ] + then + rm -rf $build_path/plugins/org.tizen.dynamicanalysis.ide.native.eplugin + elif [ "x${package_name}" = "xdynamic-analysis-ide-native-eplugin" ] + then + rm -rf $build_path/plugins/org.tizen.dynamicanalysis.ide.eplugin + fi +} + +__copy_dependency_plugins() +{ + dependency_plugin_path=${ROOTDIR}/${ide_root_path_name} + + equinox_launcher=`echo org.eclipse.equinox.launcher_*.jar` + + ## check base-native-ide-product p2 install + update_plugin_path=${ROOTDIR}/ide/updatablenative + if [ -d ${update_plugin_path} ] + then + ## install native feature by p2 for install script failure on the cross build + java -jar ${reference_ide_path}/plugins/$equinox_launcher \ + -application org.eclipse.equinox.p2.director \ + -repository "file:/${update_plugin_path}" \ + -installIU org.tizen.base.native.feature.feature.group \ + -noSplash \ + -p2.os ${archive_platform_name} \ + -p2.ws ${windowing} \ + -p2.arch ${architecture} + rm -rf ${update_plugin_path} + fi + + ## check base-web-ide-product p2 install + update_plugin_path=${ROOTDIR}/ide/updatableweb + if [ -d ${update_plugin_path} ] + then + ## install web feature by p2 for install script failure on the cross build + java -jar ${reference_ide_path}/plugins/$equinox_launcher \ + -application org.eclipse.equinox.p2.director \ + -repository "file:/${update_plugin_path}" \ + -installIU org.tizen.base.web.feature.feature.group \ + -noSplash \ + -p2.os ${archive_platform_name} \ + -p2.ws ${windowing} \ + -p2.arch ${architecture} + rm -rf ${update_plugin_path} + fi + +} + +__make_ant_build_properties_file() +{ + builder_path="${SRCDIR}/builder" + parent_path_of_based_eclipse=${reference_ide_path}/.. + + echo "Make build.properties file..." + if [ ! -e $builder_path/build.properties.clean ] ; then + echo "ERROR : \"build.properties.clean\" file does not exist..." + exit 1 + fi + cp $builder_path/build.properties.clean $build_path + cp ${build_script_path}/customTargets.xml $build_path + + if [ -d $reference_ide_path ] + then + sed -e "s;\(^buildDirectory=\).*;\1${build_path};g" \ + -e "s;\(^base=\).*;\1${parent_path_of_based_eclipse};g" \ + -e "s;\(^baseLocation=\).*;\1${reference_ide_path};g" \ + -e "s;\(^configs=\).*;\1${archive_platform_name},${windowing},${architecture};g" \ + -e "s;\(^buildType=\).*;\1${build_type};g" \ + -e "s;\(^buildId=\).*;\1${build_id};g" \ + -e "s;\(^archivePrefix=\).*;\1${build_id};g" \ + < $build_path/build.properties.clean > $build_path/build.properties + + else + echo "ERROR : target eclipse is not exist." + exit 1 + fi +} + +__execute_pde_build() +{ + echo "Execute Product Ant Builder..." + equinox_launcher=`echo org.eclipse.equinox.launcher_*.jar` + pde_build=`echo org.eclipse.pde.build_*` + + java -server -XX:+UseParNewGC -Xmx256m -jar ${reference_ide_path}/plugins/$equinox_launcher -application org.eclipse.ant.core.antRunner -buildfile ${reference_ide_path}/plugins/$pde_build/scripts/productBuild/productBuild.xml -Dbuilder=$build_path -Dosgi.locking=none 2>&1 + + if [ $? != 0 ]; + then + echo "Build failed..." + exit 1 + fi +} + +__unzip_plugin_pack() +{ + echo "unzip to $build_result_path" + unzip -a $build_result_path/${result_archive_file} -d $build_result_path/${archive_platform_name}.${windowing}.${architecture} +} + +__modify_about_mappings_file() +{ + branding_plugin=`grep "topLevelElementId=" ${build_path}/build.properties | cut -f2 -d"="` + branding_path=`grep "plugin=" ${build_path}/features/${branding_plugin}/feature.xml -m1 | cut -f2 -d"\""` + about_mapping_path="${build_path}/plugins/${branding_path}/about.mappings" + + if [ -d ${build_path}/plugins/${branding_path} -a -e ${about_mapping_path} ] + then + build_time=`date +%Y%m%d-%H%M` + about_build_time_parameter="1" + sed -e "s;\(^${about_build_time_parameter}=\).*;\1${build_time};g" \ + < ${about_mapping_path} > ${about_mapping_path}.mod + mv ${about_mapping_path}.mod ${about_mapping_path} + fi +} + +build_plugins() +{ + case ${TARGET_OS} in + ubuntu-32|ubuntu-64|windows-32|windows-64|macos-64) + echo "build plugin for ${TARGET_OS}" + ;; + *) + echo "${TARGET_OS} is not support yet." + exit 1 + ;; + esac + + __set_parameter + __set_build_parameter + __clean_build_environment + __copy_build_sources + __copy_dependency_plugins + __make_ant_build_properties_file + __modify_about_mappings_file + __execute_pde_build + __unzip_plugin_pack + + echo "Build SUCCESS. You will find SDK IDE in \"${build_result_path}\"." } # clean clean() { - echo "=========================================CLEAN============================================" + echo "=========================================CLEAN============================================" + __set_build_script_path + ${build_script_path}/clean.sh ${package_name} +} + +## get package list from the pkginfo.manifest of git source +## Result: set "pkgname_and_platform_list" variable +getListFromPackageManifest() { + echo "get list from manifest" + PKG_MANIFEST_PATH="${SRCDIR}/package/pkginfo.manifest" + echo "${PKG_MANIFEST_PATH}" + pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${PKG_MANIFEST_PATH} | tr ' ' '@'` + echo "${pkgname_and_platform_list}" +} + +## parse name and platform from package infomation +## Argument $1: one of "pkgname_and_platform_list" +## Result: set "package_name" and "platform" variables +parsePackage() { + pkginfo=`echo ${1} | tr '@' ' '` + package_name=`echo ${pkginfo} | cut -f1 -d " " | cut -f2 -d ":"` + platform=`echo ${pkginfo} | cut -f2 -d " " | cut -f2 -d ":"` +} + +__change_filename() +{ + dir_name=`dirname ${1}` + file_name=`basename ${1}` + index=`expr index "${file_name}" _` + index=`expr $index - 1` + new_file_name=`expr substr ${file_name} 1 ${index}`".jar" + new_file_name=${dir_name}/${new_file_name} + mv ${1} ${new_file_name} +} + +packaging_plugins() +{ __set_parameter - ${build_script_path}/clean.sh ${package_name} + install_ide_path=${INSTALL_DIR}/${ide_root_path_name} + + if [ ! -d ${install_ide_path} ] + then + mkdir -p ${install_ide_path} + fi + + cp -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture}/${package_name}/* ${install_ide_path}/ + + find ${install_ide_path} -name "*.jar" | + while read filename; + do + __change_filename ${filename} + done + + touch ${install_ide_path}/init } # build build() { - echo "=========================================BUILD============================================" - pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'` - for pkgname_and_platform in ${pkgname_and_platform_list} - do - pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '` - package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"` - platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"` - - if [ "x${TARGET_OS}" = "x${platform}" ] - then - __set_parameter - ${build_script_path}/build.sh ${package_name} - else - echo "" - fi - done + echo "=========================================BUILD============================================" + getListFromPackageManifest + for pkgname_and_platform in ${pkgname_and_platform_list} + do + parsePackage ${pkgname_and_platform} + + if [ "x${TARGET_OS}" = "x${platform}" ] + then + build_plugins + else + echo "" + fi + done } # install install() { - pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'` - for pkgname_and_platform in ${pkgname_and_platform_list} - do - echo "=========================================INSTALL============================================" - pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '` - package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"` - platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"` - - if [ "x${TARGET_OS}" = "x${platform}" ] - then - __set_parameter - INSTALL_DIR=${SRCDIR}/package/${package_name}.package.${TARGET_OS}/data - mkdir -p ${INSTALL_DIR} - __copy_necessary_binaries - ${build_script_path}/install.sh ${package_name} - else - echo "" - fi - done + getListFromPackageManifest + for pkgname_and_platform in ${pkgname_and_platform_list} + do + echo "=========================================INSTALL============================================" + parsePackage ${pkgname_and_platform} + + if [ "x${TARGET_OS}" = "x${platform}" ] + then + INSTALL_DIR=${SRCDIR}/package/${package_name}.package.${TARGET_OS}/data + mkdir -p ${INSTALL_DIR} + __copy_necessary_binaries + packaging_plugins + else + echo "" + fi + done } [ "$1" = "clean" ] && clean [ "$1" = "build" ] && build [ "$1" = "install" ] && install +exit 0 diff --git a/package/changelog b/package/changelog index 1786262..e8217cc 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,9 @@ +* 2.2.18 +version up to fix build packaging error +== jungwook.ryu <jungwook.ryu@samsung.com> 2014-10-30 +* 2.2.17 +MISC : separate the ide-eplugin package for nativeplatform dependency (dynamic-analysis-ide-eplugin, dynamic-analysis-ide-native-eplugin) +== jungwook.ryu <jungwook.ryu@samsung.com> 2014-10-29 * 2.2.16 Bug fix - launching error using "run as" after "profile with dynamic analyzer". == jungwook.ryu <jungwook.ryu@samsung.com> 2014-10-27 diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index 9bf5fd7..7cda264 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,4 +1,4 @@ -Version:2.2.16 +Version:2.2.18 Source:dynamic-analysis-ide-eplugin Maintainer:Jungwook Ryu <jungwook.ryu@samsung.com>, Juyoung Kim <j0.kim@samsung.com> @@ -6,8 +6,9 @@ Package:dynamic-analysis-ide-eplugin Label:Dynamic analyzer ide plugin OS:ubuntu-32 Build-host-os:ubuntu-32 -Install-dependency:base-native-ide-product [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32], nativeplatform-eplugin [ubuntu-32] +Install-dependency:base-native-ide-product [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32], nativeplatform-eplugin [ubuntu-32], dynamic-analysis-ide-native-eplugin [ubuntu-32] Build-dependency: pde-build [ubuntu-32], base-native-ide-product [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32], nativeplatform-eplugin [ubuntu-32] +Conflicts:dynamic-analysis-ide-native-eplugin [ubuntu-32] Description:Dynamic analyzer ide plugin C-Prerequisites: @@ -15,32 +16,77 @@ Package:dynamic-analysis-ide-eplugin Label:Dynamic analyzer ide plugin OS:windows-32 Build-host-os:ubuntu-32 +Install-dependency:base-native-ide-product [windows-32], common-eplugin [windows-32], nativecommon-eplugin [windows-32], nativeplatform-eplugin [windows-32], dynamic-analysis-ide-native-eplugin [windows-32] Build-dependency:pde-build [windows-32], base-native-ide-product [windows-32], common-eplugin [windows-32], nativecommon-eplugin [windows-32], nativeplatform-eplugin [windows-32] -Install-dependency:base-native-ide-product [windows-32], common-eplugin [windows-32], nativecommon-eplugin [windows-32], nativeplatform-eplugin [windows-32] +Conflicts:dynamic-analysis-ide-native-eplugin [windows-32] Description:Dynamic analyzer ide plugin Package:dynamic-analysis-ide-eplugin Label:Dynamic analyzer ide plugin OS:ubuntu-64 Build-host-os:ubuntu-64 +Install-dependency:base-native-ide-product [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64], nativeplatform-eplugin [ubuntu-64], dynamic-analysis-ide-native-eplugin [ubuntu-64] Build-dependency:pde-build [ubuntu-64], base-native-ide-product [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64], nativeplatform-eplugin [ubuntu-64] -Install-dependency:base-native-ide-product [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64], nativeplatform-eplugin [ubuntu-64] +Conflicts:dynamic-analysis-ide-native-eplugin [ubuntu-64] Description:Dynamic analyzer ide plugin Package:dynamic-analysis-ide-eplugin Label:Dynamic analyzer ide plugin OS:windows-64 Build-host-os:ubuntu-64 +Install-dependency:base-native-ide-product [windows-64], common-eplugin [windows-64], nativecommon-eplugin [windows-64], nativeplatform-eplugin [windows-64], dynamic-analysis-ide-native-eplugin [windows-64] Build-dependency:pde-build [windows-64], base-native-ide-product [windows-64], common-eplugin [windows-64], nativecommon-eplugin [windows-64], nativeplatform-eplugin [windows-64] -Install-dependency:base-native-ide-product [windows-64], common-eplugin [windows-64], nativecommon-eplugin [windows-64], nativeplatform-eplugin [windows-64] +Conflicts:dynamic-analysis-ide-native-eplugin [windows-64] Description:Dynamic analyzer ide plugin Package:dynamic-analysis-ide-eplugin Label:Dynamic analyzer ide plugin OS:macos-64 Build-host-os:ubuntu-64 +Install-dependency:base-native-ide-product [macos-64], common-eplugin [macos-64], nativecommon-eplugin [macos-64], nativeplatform-eplugin [macos-64], dynamic-analysis-ide-native-eplugin [macos-64] Build-dependency:pde-build [macos-64], base-native-ide-product [macos-64], common-eplugin [macos-64], nativecommon-eplugin [macos-64], nativeplatform-eplugin [macos-64] -Install-dependency:base-native-ide-product [macos-64], common-eplugin [macos-64], nativecommon-eplugin [macos-64], nativeplatform-eplugin [macos-64] +Conflicts:dynamic-analysis-ide-native-eplugin [macos-64] +Description:Dynamic analyzer ide plugin + +Package:dynamic-analysis-ide-native-eplugin +Label:Dynamic analyzer ide plugin +OS:ubuntu-32 +Build-host-os:ubuntu-32 +Install-dependency:base-native-ide-product [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32] +Build-dependency: pde-build [ubuntu-32], base-native-ide-product [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32] +Description:Dynamic analyzer ide plugin +C-Prerequisites: + +Package:dynamic-analysis-ide-native-eplugin +Label:Dynamic analyzer ide plugin +OS:windows-32 +Build-host-os:ubuntu-32 +Build-dependency:pde-build [windows-32], base-native-ide-product [windows-32], common-eplugin [windows-32], nativecommon-eplugin [windows-32] +Install-dependency:base-native-ide-product [windows-32], common-eplugin [windows-32], nativecommon-eplugin [windows-32] +Description:Dynamic analyzer ide plugin + +Package:dynamic-analysis-ide-native-eplugin +Label:Dynamic analyzer ide plugin +OS:ubuntu-64 +Build-host-os:ubuntu-64 +Build-dependency:pde-build [ubuntu-64], base-native-ide-product [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64] +Install-dependency:base-native-ide-product [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64] +Description:Dynamic analyzer ide plugin + +Package:dynamic-analysis-ide-native-eplugin +Label:Dynamic analyzer ide plugin +OS:windows-64 +Build-host-os:ubuntu-64 +Build-dependency:pde-build [windows-64], base-native-ide-product [windows-64], common-eplugin [windows-64], nativecommon-eplugin [windows-64] +Install-dependency:base-native-ide-product [windows-64], common-eplugin [windows-64], nativecommon-eplugin [windows-64] +Description:Dynamic analyzer ide plugin + +Package:dynamic-analysis-ide-native-eplugin +Label:Dynamic analyzer ide plugin +OS:macos-64 +Build-host-os:ubuntu-64 +Build-dependency:pde-build [macos-64], base-native-ide-product [macos-64], common-eplugin [macos-64], nativecommon-eplugin [macos-64] +Install-dependency:base-native-ide-product [macos-64], common-eplugin [macos-64], nativecommon-eplugin [macos-64] Description:Dynamic analyzer ide plugin |