*
* 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>
*
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.tizen.nativecommon.launch.ui.TizenLaunchDeviceSelectionDialog;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
import org.tizen.nativeplatform.launch.ILaunchConfigurationProcessor;
-import org.tizen.nativeplatform.launch.LaunchCommandCancelThread;
import org.tizen.nativeplatform.launch.LaunchConfigurationProcessor;
import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
-import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
-import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-import org.tizen.nativeplatform.types.CmdTargetTypes;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
import org.tizen.nativeplatform.util.PlatformProjectUtil;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
import org.tizen.sdblib.Arch;
protected IConfiguration selectedConfig;
protected PkgCommandTarget target = null;
protected TizenLaunchCommand tizenCommand = null;
-
+
private static class ExtFilter implements FilenameFilter {
private String ext;
return name.endsWith(ext);
}
}
-
+
@Override
public void launch(ILaunchConfiguration config, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
-
+
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;
+
if (PlatformProjectUtil.isTizenPlatformProject(project)) {
- isLaunchFailed = false;
- shell = LaunchUIPlugin.getShell();
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- try {
- int totalWorks = 4;
- monitor.beginTask("", totalWorks);
- monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
-
- activateProgressView();
- verifyDeviceReachability(config, new SubProgressMonitor(monitor, 1));
- setRootstrap(config);
- verifyBuildConfiguration(config, mode, new SubProgressMonitor(monitor, 1));
- setPkgCommandTarget();
- tizenCommand = new TizenLaunchCommand(currentDevice, null);
-
- ILaunchConfigurationProcessor processor = getConfigurationProcessor(shell, config,
- project, mode, target, new SubProgressMonitor(monitor, 1));
- if (!processor.process()) {
- newCoreException(PlatformLaunchMessages.CANNOT_LAUNCH, null);
- }
-
- launchApplicationForRun(config, launch, new SubProgressMonitor(monitor, 1));
- } finally {
- if (!launch.isTerminated()) {
- launch.terminate();
- }
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- launchManager.removeLaunch(launch);
-
- // Do not save failed configuration.
- if (isLaunchFailed) {
- config.delete();
- isLaunchFailed = false;
- }
- monitor.done();
- UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH);
- }
-
- if (bSuccessBuild && !isLaunchFailed && isDAReady()) {
- runDynamicAnalyzer(project, currentDevice);
+ isLaunchFailed = false;
+ shell = LaunchUIPlugin.getShell();
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ try {
+ int totalWorks = 4;
+ monitor.beginTask("", totalWorks);
+ monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
+
+ activateProgressView();
+ verifyDeviceReachability(config, new SubProgressMonitor(
+ monitor, 1));
+ setRootstrap(config);
+ verifyBuildConfiguration(config, mode, new SubProgressMonitor(
+ monitor, 1));
+ setPkgCommandTarget();
+ tizenCommand = new TizenLaunchCommand(currentDevice, null);
+
+ ILaunchConfigurationProcessor processor = getConfigurationProcessor(
+ shell, config, project, mode, target,
+ new SubProgressMonitor(monitor, 1));
+ if (!processor.process()) {
+ newCoreException(PlatformLaunchMessages.CANNOT_LAUNCH, null);
+ }
+
+ if (PlatformProjectUtil.isEFLApplication(project)) {
+ localPackagePathList = getRpmFiles(rootstrap);
+ projectType = ProjectType.EFL;
+ String envCmd = getEnvironments(config);
+ String execArg = getArguments(config);
+ executablePath = envCmd + execArg;
+
+ binaryOfTarget = PlatformLaunchUtil.getAppId(project)[0];
+ // TODO : need to be changed
+ //binaryOfTarget = envCmd + execArg;
+ } else {
+ projectType = ProjectType.LIBRARY;
+ String envCmd = getEnvironments(config);
+ String execArg = getArguments(config);
+ executablePath = envCmd + execArg;
+ }
+ } catch (Exception e) {
+ DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, e.getMessage());
+ } finally {
+ if (!launch.isTerminated()) {
+ launch.terminate();
+ }
+ ILaunchManager launchManager = DebugPlugin.getDefault()
+ .getLaunchManager();
+ launchManager.removeLaunch(launch);
+
+ // Do not save failed configuration.
+ if (isLaunchFailed) {
+ config.delete();
+ isLaunchFailed = false;
+ }
+ monitor.done();
+ UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH);
}
- } else { // Case : Native application
+
+ if (bSuccessBuild && !isLaunchFailed && isDAReady()) {
+ runDynamicAnalyzer(device, projectType, binaryOfTarget, executablePath, localPackagePathList);
+ }
+ } else { // Case : Native application
+ projectType = ProjectType.OSP;
verifyCProjectConfigurationSettings(config);
try {
verityUnitTestProject(project);
if (isDAReady()) {
if (packaging_upload_install(project, currentDevice)) {
- runDynamicAnalyzer(project, currentDevice);
+ IApplicationConfiguration adapter = (IApplicationConfiguration) project
+ .getAdapter(IApplicationConfiguration.class);
+ binaryOfTarget = adapter.getAppId();
+ runDynamicAnalyzer(device, projectType, binaryOfTarget, executablePath, localPackagePathList);
}
}
} catch (CoreException e) {
.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)) {
project,
currentDevice,
tizenCommand,
- TizenLaunchConsole.getTizenConsole(),
+ TizenLaunchConsole
+ .getTizenConsole(),
CommonProjectDependentPackager.DEFAULT
.toLowerCase(), monitor);
rdsDeployer.setInterestList(TizenLaunchInfo
try {
rdsDeployer.close();
} catch (IOException e) {
- DALog.dlgErrorMessage("Failed to close RDSDeployer",
+ DALog.dlgErrorMessage(
+ "Failed to close RDSDeployer",
e.getMessage());
}
}
}
-
- if(monitor.isCanceled()) {
+
+ if (monitor.isCanceled()) {
bSuccessBuild = false;
monitor.done();
}
}
}
});
-
+
return bSuccessBuild;
}
}
}
- private void runDynamicAnalyzer(IProject project, IDevice currentDevice) {
- IApplicationConfiguration adapter = (IApplicationConfiguration) project
- .getAdapter(IApplicationConfiguration.class);
-
+ private void runDynamicAnalyzer(String device, ProjectType projectType, String binaryOfTarget,
+ String executablePath, List<String> localPackagePathList) {
if (DAServerManager.getInstance().getClientSocket() == null) {
StringBuffer command = new StringBuffer();
}
}
- DAServerManager.getInstance().reserveTraceApplication(currentDevice.toString(),
- adapter.getAppId(),
- adapter.getBinaryName().split(".exe")[0]);//$NON-NLS-1$
+ DAServerManager.getInstance().reserveTraceApplication(device, projectType, binaryOfTarget, executablePath, localPackagePathList);
} else {
- DAServerManager.getInstance().runTraceApplication(currentDevice.toString(),
- adapter.getAppId(),
- adapter.getBinaryName().split(".exe")[0]);//$NON-NLS-1$
+ DAServerManager.getInstance().runTraceApplication(device, projectType, binaryOfTarget, executablePath, localPackagePathList);
}
}
-
+
+ private List<String> getRpmFiles(PlatformRootstrap rootstrap) {
+ List<String> rpms = new ArrayList<String>();
+ String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
+ rootstrap.getPath());
+ String arch = rootstrap.getArch();
+ IPath rpmPath = new Path(rootstrapPath).append("home").append("abuild").append("rpmbuild")
+ .append("RPMS").append(arch);
+ File rpmDir = rpmPath.toFile();
+ if (rpmDir.exists()) {
+ String[] files = rpmDir.list(new RpmFileFilter());
+ for (String file : files) {
+ IPath pkgPath = new Path(rpmDir.getPath()).append(file);
+ rpms.add(pkgPath.toOSString());
+ }
+ }
+ return rpms;
+ }
+
private void rollBackBuildConfigSetting(IProject project) {
String prevBuildConfigName = TizenNativeApplicationDAShortcut
.getPrevBuildConfigName();
protected String getPluginID() {
return Activator.PLUGIN_ID;
}
-
- protected void activateProgressView() {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .showView("org.eclipse.ui.views.ProgressView");
- } catch (PartInitException e) {
- e.printStackTrace();
- }
- }
- });
- }
-
- protected void verifyDeviceReachability(ILaunchConfiguration config, IProgressMonitor monitor)
- throws CoreException {
- try {
- monitor.beginTask(TizenLaunchMessages.PREPARE_TO_LAUNCH, 1);
- monitor.subTask(TizenLaunchMessages.PREPARE_TO_LAUNCH);
-
- final ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- final IDevice[] devices = getDeploayableDevices(config);
- IDevice configDevice = null;
-
- // 1. Get device from configuration
- configDevice = LaunchUtils.getDeviceFromLaunchConfiguration(config, devices);
-
- // 2-1. Set device for launch configuration if there is no device
- // matched with configuration or device is off-lined
- if (configDevice == null) {
- // 4. Get list of deployable devices for configuration
- int device_count = devices.length;
-
- if (device_count == 0) {
- // TODO: notify no deployable devices, open emulator
- // manager?
- currentDevice = null;
- }
- // Found device more than 0
- else {
- if (device_count == 1) {
- currentDevice = devices[0];
- }
- // if devices.length > 1
- else {
- SWTUtil.syncExec(new Runnable() {
- @Override
- public void run() {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getShell();
- TizenLaunchDeviceSelectionDialog deviceDialog = new TizenLaunchDeviceSelectionDialog(
- shell, devices);
- currentDevice = (deviceDialog.open() == Window.OK) ? deviceDialog
- .getSelectedDevice() : null;
- }
- });
- }
- if (currentDevice != null) {
- String device_id = LaunchUtils.getDeviceId(currentDevice);
- wc.setAttribute(TizenLaunchConfigurationConstants.ATTR_CONFIG_DEVICE_ID,
- device_id);
- wc.doSave();
- }
- }
- }
- // 2-2. Launch with the device if there is device info in
- // configuration
- else {
- currentDevice = configDevice;
- }
- if (currentDevice == null) {
- LaunchUtils.newCoreException(TizenLaunchMessages.NO_TARGET, null);
- }
- if (!isOnline(currentDevice)) {
- LaunchUtils.newCoreException(TizenLaunchMessages.NO_TARGET, null);
- }
- } finally {
- monitor.done();
- }
- }
-
- private IDevice[] getDeploayableDevices(ILaunchConfiguration config) throws CoreException {
- IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
- List<IDevice> deployableDevices = new ArrayList<IDevice>();
- Arch configArch = getBuildConfigurationArchitecture(config);
-
- for (IDevice device : devices) {
- if (device.getArch() == configArch) {
- deployableDevices.add(device);
- }
- }
- return deployableDevices.toArray(new IDevice[deployableDevices.size()]);
- }
-
- protected Arch getBuildConfigurationArchitecture(ILaunchConfiguration config)
- throws CoreException {
- String buildTargetArchitecture = getBuildConfigName(config);
- return getBuildConfigurationArchitecture(project, buildTargetArchitecture);
- }
-
- 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 Arch getBuildConfigurationArchitecture(IProject project,
- String buildTargetArchitecture) throws CoreException {
- IConfiguration configuration = getBuildConfiguration(buildTargetArchitecture, project);
- String arch = PlatformConfigurationManager.getArchitecture(configuration);
- if (LaunchUtils.isX86(arch)) {
- return Arch.X86;
- } else {
- return Arch.ARM;
- }
- }
-
- 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 void setRootstrap(ILaunchConfiguration config) throws CoreException {
- String buildConfigName = getBuildConfigName(config);
- IConfiguration buildConfig = getBuildConfiguration(buildConfigName, project);
- String targetID = PlatformConfigurationManager.getBuildTargetName(buildConfig);
- String rootstrapId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetID);
- rootstrap = RootstrapManager.getRootstrap(rootstrapId);
- }
+ protected void activateProgressView() {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage()
+ .showView("org.eclipse.ui.views.ProgressView");
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
- protected void verifyBuildConfiguration(ILaunchConfiguration config, String mode,
- IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", 1);
- monitor.subTask(TizenLaunchMessages.PREPARE_TO_LAUNCH);
+ protected void verifyDeviceReachability(ILaunchConfiguration config,
+ IProgressMonitor monitor) throws CoreException {
+ try {
+ monitor.beginTask(TizenLaunchMessages.PREPARE_TO_LAUNCH, 1);
+ monitor.subTask(TizenLaunchMessages.PREPARE_TO_LAUNCH);
+
+ final ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ final IDevice[] devices = getDeploayableDevices(config);
+ IDevice configDevice = null;
+
+ // 1. Get device from configuration
+ configDevice = LaunchUtils.getDeviceFromLaunchConfiguration(config,
+ devices);
+
+ // 2-1. Set device for launch configuration if there is no device
+ // matched with configuration or device is off-lined
+ if (configDevice == null) {
+ // 4. Get list of deployable devices for configuration
+ int device_count = devices.length;
+
+ if (device_count == 0) {
+ // TODO: notify no deployable devices, open emulator
+ // manager?
+ currentDevice = null;
+ }
+ // Found device more than 0
+ else {
+ if (device_count == 1) {
+ currentDevice = devices[0];
+ }
+ // if devices.length > 1
+ else {
+ SWTUtil.syncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ TizenLaunchDeviceSelectionDialog deviceDialog = new TizenLaunchDeviceSelectionDialog(
+ shell, devices);
+ currentDevice = (deviceDialog.open() == Window.OK) ? deviceDialog
+ .getSelectedDevice() : null;
+ }
+ });
+ }
+ if (currentDevice != null) {
+ String device_id = LaunchUtils
+ .getDeviceId(currentDevice);
+ wc.setAttribute(
+ TizenLaunchConfigurationConstants.ATTR_CONFIG_DEVICE_ID,
+ device_id);
+ wc.doSave();
+ }
+ }
+ }
+ // 2-2. Launch with the device if there is device info in
+ // configuration
+ else {
+ currentDevice = configDevice;
+ }
+ if (currentDevice == null) {
+ LaunchUtils.newCoreException(TizenLaunchMessages.NO_TARGET,
+ null);
+ }
+ if (!isOnline(currentDevice)) {
+ LaunchUtils.newCoreException(TizenLaunchMessages.NO_TARGET,
+ null);
+ }
+ } finally {
+ monitor.done();
+ }
+ }
- // FIXME : Match by deviceType, not buildTargetArchitecture.
- String buildConfigName = getBuildConfigName(config);
+ private IDevice[] getDeploayableDevices(ILaunchConfiguration config)
+ throws CoreException {
+ IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
+ List<IDevice> deployableDevices = new ArrayList<IDevice>();
+ Arch configArch = getBuildConfigurationArchitecture(config);
- IConfiguration configuration = getBuildConfiguration(buildConfigName, project);
- String buildTargetArchitecture = CommonConfigurationManager.getArchitecture(configuration);
- if (currentDevice.isEmulator() && currentDevice.getArch() == Arch.X86) {
- if (!PlatformConfigurationManager.isEmulatorArch(buildTargetArchitecture)) {
- resolveProblematicConfiguration(config, "i386");
- }
- } else {
- if (!PlatformConfigurationManager.isDeviceArch(buildTargetArchitecture)) {
- resolveProblematicConfiguration(config, "armel");
- }
- }
- monitor.worked(1);
- monitor.done();
- }
-
- protected void resolveProblematicConfiguration(ILaunchConfiguration config, final String arch)
- throws CoreException {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- selectedConfig = selectBuildConfiguration(project, arch);
- }
- });
+ for (IDevice device : devices) {
+ if (device.getArch() == configArch) {
+ deployableDevices.add(device);
+ }
+ }
+ return deployableDevices.toArray(new IDevice[deployableDevices.size()]);
+ }
- if (selectedConfig == null) {
- newCoreException(
- TizenLaunchMessages.BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE,
- null);
- }
+ protected Arch getBuildConfigurationArchitecture(ILaunchConfiguration config)
+ throws CoreException {
+ String buildTargetArchitecture = getBuildConfigName(config);
+ return getBuildConfigurationArchitecture(project,
+ buildTargetArchitecture);
+ }
- ICProjectDescription projDes = CDTPropertyManager.getProjectDescription(project);
- ICConfigurationDescription cDesc = projDes.getConfigurationByName(selectedConfig.getName());
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, cDesc
- .getConfiguration().getId());
- wc.doSave();
- }
-
- protected IConfiguration selectBuildConfiguration(IProject project, String arch) {
- Shell shell = LaunchUIPlugin.getShell();
-
- ILabelProvider topprovider = new LabelProvider() {
- public String getText(Object element) {
- IConfiguration buildConfig = (IConfiguration) element;
- return buildConfig.getName();
- }
- };
+ 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;
+ }
+ }
- ILabelProvider downprovider = new LabelProvider() {
- public String getText(Object element) {
- IConfiguration buildConfig = (IConfiguration) element;
- return buildConfig.getName();
- }
- };
-
- TwoPaneElementSelector dlg = new TwoPaneElementSelector(shell, topprovider, downprovider);
- dlg.setTitle("Select a new build configuration"); //$NON-NLS-1$
- dlg.setMessage("Build configuration doesn't match with current active device.\nSelect a new build configuration to launch"); //$NON-NLS-1$
-
- IConfiguration[] configurations = ManagedBuildManager.getBuildInfo(project)
- .getManagedProject().getConfigurations();
- List<IConfiguration> adaptableConfigs = new ArrayList<IConfiguration>(0);
- for (IConfiguration c : configurations) {
- String buildTargetArchitecture = CommonConfigurationManager.getArchitecture(c);
- if (buildTargetArchitecture.equals(arch)) {
- adaptableConfigs.add(c);
- }
- }
+ protected Arch getBuildConfigurationArchitecture(IProject project,
+ String buildTargetArchitecture) throws CoreException {
+ IConfiguration configuration = getBuildConfiguration(
+ buildTargetArchitecture, project);
+ String arch = PlatformConfigurationManager
+ .getArchitecture(configuration);
+ if (LaunchUtils.isX86(arch)) {
+ return Arch.X86;
+ } else {
+ return Arch.ARM;
+ }
+ }
- dlg.setElements(adaptableConfigs.toArray());
+ 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);
+ }
- if (dlg.open() == Window.OK) {
- IConfiguration selectedConfig = (IConfiguration) dlg.getFirstResult();
- return selectedConfig;
- }
+ return configuration;
+ }
- return null;
- }
-
- protected void setPkgCommandTarget() {
- target = new PkgCommandTarget(PlatformProjectUtil.getPkgType(), currentDevice, rootstrap);
- }
-
- protected ILaunchConfigurationProcessor getConfigurationProcessor(Shell shell,
- ILaunchConfiguration launchConfig, IProject project, String mode,
- PkgCommandTarget target, IProgressMonitor monitor) {
- return new LaunchConfigurationProcessor(shell, launchConfig, project, mode, target, monitor);
- }
-
- protected void setDebugConfigAttributes(ILaunchConfiguration config) throws CoreException {
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
- wc.doSave();
- }
+ protected void setRootstrap(ILaunchConfiguration config)
+ throws CoreException {
+ String buildConfigName = getBuildConfigName(config);
+ IConfiguration buildConfig = getBuildConfiguration(buildConfigName,
+ project);
+ String targetID = PlatformConfigurationManager
+ .getBuildTargetName(buildConfig);
+ String rootstrapId = SmartBuildInterface.getInstance()
+ .getRootstrapIDFromTargetID(targetID);
+ rootstrap = RootstrapManager.getRootstrap(rootstrapId);
+ }
- protected void verifyPlatformProjectSettings(ILaunchConfiguration config) throws CoreException {
- String appPath = config
- .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
- IPath hostPath = getHostPath(appPath, config);
- if (hostPath != null) {
- if (hostPath.toFile().exists()) {
- return;
- } else {
- newCoreException(PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
- null);
- }
- } else {
- newCoreException(PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
- null);
- }
- }
-
- protected IPath getHostPath(String exePath, ILaunchConfiguration config) throws CoreException {
- IPath path = target.getRootstrap().getPath();
- if (target.getRootstrapCommander() == null) {
- return new Path(exePath);
- }
- String canonicalPath = target.getRootstrapCommander().canonicalizePath(exePath);
- String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
- if (rootstrapPath != null && !rootstrapPath.isEmpty()) {
- if (canonicalPath != null && !canonicalPath.isEmpty()) {
- rootstrapPath = rootstrapPath.concat(canonicalPath);
- } else {
- rootstrapPath = rootstrapPath.concat(exePath);
- }
- }
- return new Path(rootstrapPath);
- }
-
- protected IBinaryObject getBinaryObject(ILaunchConfiguration config) throws CoreException {
- String appPath = config
- .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
- IPath hostPath = getHostPath(appPath, config);
- ICProject cproject = CDebugUtils.verifyCProject(config);
- IBinaryObject binaryObject = verifyBinary(cproject, hostPath);
- return binaryObject;
- }
+ protected void verifyBuildConfiguration(ILaunchConfiguration config,
+ String mode, IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("", 1);
+ monitor.subTask(TizenLaunchMessages.PREPARE_TO_LAUNCH);
+
+ // FIXME : Match by deviceType, not buildTargetArchitecture.
+ String buildConfigName = getBuildConfigName(config);
+
+ IConfiguration configuration = getBuildConfiguration(buildConfigName,
+ project);
+ String buildTargetArchitecture = CommonConfigurationManager
+ .getArchitecture(configuration);
+ if (currentDevice.isEmulator() && currentDevice.getArch() == Arch.X86) {
+ if (!PlatformConfigurationManager
+ .isEmulatorArch(buildTargetArchitecture)) {
+ resolveProblematicConfiguration(config, "i386");
+ }
+ } else {
+ if (!PlatformConfigurationManager
+ .isDeviceArch(buildTargetArchitecture)) {
+ resolveProblematicConfiguration(config, "armel");
+ }
+ }
+ monitor.worked(1);
+ monitor.done();
+ }
- protected void launchApplicationForRun(final ILaunchConfiguration config, ILaunch launch,
- final IProgressMonitor monitor) throws CoreException {
- final IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
- final LaunchCommandCancelThread cancelThread = new LaunchCommandCancelThread(commander, monitor);
-
- bSuccessBuild = true;
+ protected void resolveProblematicConfiguration(ILaunchConfiguration config,
+ final String arch) throws CoreException {
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 dialog_monitor) {
- try {
- dialog_monitor.beginTask(Labels.MESSAGE_PREPARING_PROFILE, 1);
- dialog_monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
- monitor.beginTask("", 1);
- monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
- cancelThread.start();
- String envCmd = getEnvironments(config);
- String execArg = getArguments(config);
- ICommandStatus status = commander.executeBinary(envCmd + execArg);
- } catch (Exception e) {
- bSuccessBuild = false;
- } finally {
- dialog_monitor.done();
- monitor.worked(1);
- monitor.done();
- cancelThread.setTerminated();
- if (cancelThread.isAlive()) {
- cancelThread.interrupt();
- }
- }
- }
- });
- } 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;
- }
- }}
- );
- }
+ selectedConfig = selectBuildConfiguration(project, arch);
+ }
+ });
- protected String getEnvironments(ILaunchConfiguration config) throws Exception {
- String envs = "";
- String[] envArray = getEnvironment(config);
- for (String env : envArray) {
- envs += TizenPlatformConstants.ENVIRONMENT_SETTING_CMD + env + " && ";
- }
- return envs;
- }
+ if (selectedConfig == null) {
+ newCoreException(
+ TizenLaunchMessages.BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE,
+ null);
+ }
- 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;
- }
+ ICProjectDescription projDes = CDTPropertyManager
+ .getProjectDescription(project);
+ ICConfigurationDescription cDesc = projDes
+ .getConfigurationByName(selectedConfig.getName());
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ wc.setAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID,
+ cDesc.getConfiguration().getId());
+ wc.doSave();
+ }
+
+ protected IConfiguration selectBuildConfiguration(IProject project,
+ String arch) {
+ Shell shell = LaunchUIPlugin.getShell();
+
+ ILabelProvider topprovider = new LabelProvider() {
+ public String getText(Object element) {
+ IConfiguration buildConfig = (IConfiguration) element;
+ return buildConfig.getName();
+ }
+ };
+
+ ILabelProvider downprovider = new LabelProvider() {
+ public String getText(Object element) {
+ IConfiguration buildConfig = (IConfiguration) element;
+ return buildConfig.getName();
+ }
+ };
+
+ TwoPaneElementSelector dlg = new TwoPaneElementSelector(shell,
+ topprovider, downprovider);
+ dlg.setTitle("Select a new build configuration"); //$NON-NLS-1$
+ dlg.setMessage("Build configuration doesn't match with current active device.\nSelect a new build configuration to launch"); //$NON-NLS-1$
+
+ IConfiguration[] configurations = ManagedBuildManager
+ .getBuildInfo(project).getManagedProject().getConfigurations();
+ List<IConfiguration> adaptableConfigs = new ArrayList<IConfiguration>(0);
+ for (IConfiguration c : configurations) {
+ String buildTargetArchitecture = CommonConfigurationManager
+ .getArchitecture(c);
+ if (buildTargetArchitecture.equals(arch)) {
+ adaptableConfigs.add(c);
+ }
+ }
+
+ dlg.setElements(adaptableConfigs.toArray());
+
+ if (dlg.open() == Window.OK) {
+ IConfiguration selectedConfig = (IConfiguration) dlg
+ .getFirstResult();
+ return selectedConfig;
+ }
+
+ return null;
+ }
+
+ protected void setPkgCommandTarget() {
+ target = new PkgCommandTarget(PlatformProjectUtil.getPkgType(),
+ currentDevice, rootstrap);
+ }
+
+ protected ILaunchConfigurationProcessor getConfigurationProcessor(
+ Shell shell, ILaunchConfiguration launchConfig, IProject project,
+ String mode, PkgCommandTarget target, IProgressMonitor monitor) {
+ return new LaunchConfigurationProcessor(shell, launchConfig, project,
+ mode, target, monitor);
+ }
+
+ protected void setDebugConfigAttributes(ILaunchConfiguration config)
+ throws CoreException {
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ wc.setAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
+ wc.doSave();
+ }
+
+ protected void verifyPlatformProjectSettings(ILaunchConfiguration config)
+ throws CoreException {
+ String appPath = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+ IPath hostPath = getHostPath(appPath, config);
+ if (hostPath != null) {
+ if (hostPath.toFile().exists()) {
+ return;
+ } else {
+ newCoreException(
+ PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
+ null);
+ }
+ } else {
+ newCoreException(
+ PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
+ null);
+ }
+ }
+
+ protected IPath getHostPath(String exePath, ILaunchConfiguration config)
+ throws CoreException {
+ IPath path = target.getRootstrap().getPath();
+ if (target.getRootstrapCommander() == null) {
+ return new Path(exePath);
+ }
+ String canonicalPath = target.getRootstrapCommander().canonicalizePath(
+ exePath);
+ String rootstrapPath = SmartBuildInterface.getInstance()
+ .getPlatformRootstrapPath(path);
+ if (rootstrapPath != null && !rootstrapPath.isEmpty()) {
+ if (canonicalPath != null && !canonicalPath.isEmpty()) {
+ rootstrapPath = rootstrapPath.concat(canonicalPath);
+ } else {
+ rootstrapPath = rootstrapPath.concat(exePath);
+ }
+ }
+ return new Path(rootstrapPath);
+ }
+
+ protected IBinaryObject getBinaryObject(ILaunchConfiguration config)
+ throws CoreException {
+ String appPath = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+ IPath hostPath = getHostPath(appPath, config);
+ ICProject cproject = CDebugUtils.verifyCProject(config);
+ cproject.getBinaryContainer().getPath();
+ IBinaryObject binaryObject = verifyBinary(cproject, hostPath);
+ return binaryObject;
+ }
+
+ protected String getEnvironments(ILaunchConfiguration config)
+ throws Exception {
+ String envs = "";
+ String[] envArray = getEnvironment(config);
+ for (String env : envArray) {
+ envs += TizenPlatformConstants.ENVIRONMENT_SETTING_CMD + env
+ + " && ";
+ }
+ return envs;
+ }
+
+ 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;
+ }
}