remote server and local.
- If include files are changed after building a project, IDE asks user
to synchronize include files. If debug files are changed before
debugging, IDE also asks user to synchronize debug files.
- Exclude "include/boost" directory when synchronizing include files
because the directory has so many files.
Change-Id: Ia515f7814fd8062c263a38029721cda760ce05bd
Signed-off-by: donghyuk.yang <donghyuk.yang@samsung.com>
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.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.Activator;
import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
-import org.tizen.nativeplatform.remote.connection.WorkspaceDeltaManager;
-import org.tizen.nativeplatform.remote.connection.WorkspaceResourceDelta;
-import org.tizen.nativeplatform.remote.connection.WorkspaceSyncronizer;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
import org.tizen.nativeplatform.util.RootstrapUtil;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.ptp.remotetools.exception.RemoteConnectionException;
import org.eclipse.ptp.remotetools.exception.RemoteExecutionException;
import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
+import org.tizen.common.util.DialogUtil;
import org.tizen.common.util.OSChecker;
import org.tizen.common.util.log.UserInteraction;
import org.tizen.common.util.log.UserLogger;
import org.tizen.nativeplatform.Activator;
import org.tizen.nativeplatform.build.IBuildCommandProvider.BUILDTOOL;
import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
-import org.tizen.nativeplatform.remote.connection.RootstrapSyncronizer;
+import org.tizen.nativeplatform.remote.connection.RootstrapSynchronizer;
import org.tizen.nativeplatform.remote.connection.WorkspaceDeltaManager;
import org.tizen.nativeplatform.remote.connection.WorkspaceResourceDelta;
-import org.tizen.nativeplatform.remote.connection.WorkspaceSyncronizer;
+import org.tizen.nativeplatform.remote.connection.WorkspaceSynchronizer;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
import org.tizen.nativeplatform.util.IPackageUtil;
import org.tizen.nativeplatform.util.PkgUtilFactory;
}
if (needRemoteSync) {
- /*
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- syncRootstrap(rootstrap);
- }
- });
- */
+ if (RootstrapSynchronizer.isChangedIncludes(rootstrap)) {
+ syncIncludes(rootstrap, new SubProgressMonitor(monitor, 1));
+ }
} else {
CCorePlugin.getIndexManager().reindex(CoreModel.getDefault().create(project));
}
return isClean;
}
- private void readySyncRootstrap(PlatformRootstrap rootstrap) {
- RootstrapSyncronizer.cacheModificationTime(rootstrap);
+ public void syncIncludes(final PlatformRootstrap rootstrap, IProgressMonitor monitor) {
+ if (!RemoteConnectionManager.connected()) {
+ return;
+ }
+ String msg = "There are changes for includes in remote rootstrap.\n" +
+ "Do you want to synchronize the changes?\n\n" +
+ "(Recommend \"YES\". This may take a few moments.)";
+ int result = DialogUtil.openQuestionDialog(msg);
+ if (result == SWT.YES) {
+ RootstrapSynchronizer.syncronize(rootstrap, true, false, monitor);
+ }
}
- private void syncRootstrap(PlatformRootstrap rootstrap) {
- RootstrapSyncronizer.syncronizeIfChanges(rootstrap, new NullProgressMonitor());
+ private void readySyncRootstrap(PlatformRootstrap rootstrap) {
+ RootstrapSynchronizer.cacheModificationTime(rootstrap);
}
-
+
private void syncWorkspace(IProject project, IConfiguration config, IProgressMonitor monitor)
throws CoreException {
WorkspaceResourceDelta resourceDelta = WorkspaceDeltaManager.getDelta(project);
}
}
if (needSync) {
- if(!WorkspaceSyncronizer.syncronize(project, new SubProgressMonitor(monitor, 1))) {
+ if(!WorkspaceSynchronizer.syncronize(project, new SubProgressMonitor(monitor, 1))) {
Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
"Failed to syncronized workspace", null);
throw new CoreException(status);
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.ptp.remotetools.core.IRemoteCopyTools;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PartInitException;
import org.tizen.nativeplatform.pkg.model.IPackage;
import org.tizen.nativeplatform.pkg.model.PkgStatus;
import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
+import org.tizen.nativeplatform.remote.connection.RootstrapSynchronizer;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
import org.tizen.nativeplatform.types.CmdTargetTypes;
import org.tizen.nativeplatform.util.IPackageUtil;
verifyBuildConfiguration(config, mode, new SubProgressMonitor(monitor, 1));
setPkgCommandTarget();
tizenCommand = new TizenLaunchCommand(currentDevice, null);
+ if (mode.equals(ILaunchManager.DEBUG_MODE) && OSChecker.isWindows()) {
+ checkDebugsourceSync();
+ }
ILaunchConfigurationProcessor processor = getConfigurationProcessor(shell, config,
project, mode, target, new SubProgressMonitor(monitor, 1));
UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH);
}
}
+
+ protected void checkDebugsourceSync() {
+ if (!RemoteConnectionManager.connected()) {
+ return;
+ }
+ final PlatformRootstrap rootstrap = target.getRootstrap();
+ String rootstrapPath = RootstrapUtil.getUserSyncRootstrapPath(rootstrap.getId());
+ String defaultPath = new Path(rootstrapPath).append("usr").append("src").append("debug").toString();
+ File debugSrcPath = new File(defaultPath);
+ if (!debugSrcPath.exists()) {
+ return;
+ }
+ long dstTime = debugSrcPath.lastModified();
+ long srcTime = RootstrapSynchronizer.getDebugsrcPathLastmodifiedTime(rootstrap);
+ if (srcTime != dstTime) {
+ String msg = "There are changes for debug source in remote rootstrap.\n" +
+ "Do you want to synchronize the changes?\n\n" +
+ "(Click \"Yes\" if you want to debug other platform source together.)";
+ int result = DialogUtil.openQuestionDialog(shell, "Do you want to synchronize?", msg);
+ if (result == SWT.YES) {
+ SWTUtil.syncExec(new Runnable() {
+ public void run() {
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ monitor.beginTask("Synchronize debug sources...", -1);
+ try {
+ RootstrapSynchronizer.syncronize(rootstrap, false, true, monitor);
+ } finally {
+ monitor.done();
+ }
+ }
+ });
+ } catch (Exception e) {
+ logger.error("Failed to syncronize debug sources", e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ "Failed to syncronize debug sources", e.toString()));
+ return;
+ }
+ }
+ });
+ }
+ }
+ }
protected ILaunchConfigurationProcessor getConfigurationProcessor(Shell shell,
ILaunchConfiguration launchConfig, IProject project, String mode,
}
public boolean loadSharedLibAutomatically() {
- return autoLibButton.getSelection();
+ if (autoLibButton == null) {
+ return false;
+ } else {
+ return autoLibButton.getSelection();
+ }
}
public String getSelectedApp() {
import org.tizen.nativeplatform.util.RootstrapUtil;\r
import org.tizen.nativeplatform.views.model.PlatformRootstrap;\r
\r
-public class RootstrapSyncronizer {\r
+public class RootstrapSynchronizer {\r
+ \r
+ public static String[] EXCLUDES = {"boost/"};\r
\r
private static long includeDirModificationTime = 0;\r
private static long debugsrcDirModificationTime = 0;\r
\r
public static void cacheModificationTime(PlatformRootstrap rootstrap) {\r
+ long time = getIncludePathLastmodifiedTime(rootstrap);\r
+ if (time > 0) {\r
+ includeDirModificationTime = time;\r
+ }\r
+ time = getDebugsrcPathLastmodifiedTime(rootstrap);\r
+ if (time > 0) {\r
+ debugsrcDirModificationTime = time;\r
+ }\r
+ }\r
+ \r
+ public static long getIncludePathLastmodifiedTime(PlatformRootstrap rootstrap) {\r
String remoteIncludePath = getRemoteIncludePath(rootstrap);\r
- String remoteDebugsrcPath = getRemoteDebugsrcPath(rootstrap);\r
IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();\r
try {\r
boolean exists = filetool.hasDirectory(remoteIncludePath, new NullProgressMonitor());\r
if (exists) {\r
IRemoteItem item = filetool.getDirectory(remoteIncludePath, new NullProgressMonitor());\r
- includeDirModificationTime = item.getModificationTime();\r
+ return item.getModificationTime();\r
}\r
- exists = filetool.hasDirectory(remoteDebugsrcPath, new NullProgressMonitor());\r
+ } catch (RemoteOperationException e) {\r
+ e.printStackTrace();\r
+ } catch (RemoteConnectionException e) {\r
+ e.printStackTrace();\r
+ } catch (CancelException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return -1;\r
+ }\r
+ \r
+ public static long getDebugsrcPathLastmodifiedTime(PlatformRootstrap rootstrap) {\r
+ String remoteDebugsrcPath = getRemoteDebugsrcPath(rootstrap);\r
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();\r
+ try {\r
+ boolean exists = filetool.hasDirectory(remoteDebugsrcPath, new NullProgressMonitor());\r
if (exists) {\r
IRemoteItem item = filetool.getDirectory(remoteDebugsrcPath, new NullProgressMonitor());\r
- debugsrcDirModificationTime = item.getModificationTime();\r
+ return item.getModificationTime();\r
}\r
- } catch (RemoteOperationException e) {\r
+ } catch (RemoteOperationException e) {\r
e.printStackTrace();\r
} catch (RemoteConnectionException e) {\r
e.printStackTrace();\r
} catch (CancelException e) {\r
e.printStackTrace();\r
}\r
+ return -1;\r
}\r
\r
- public static void syncronizeIfChanges(PlatformRootstrap rootstrap, IProgressMonitor monitor) {\r
+ public static boolean isChangedIncludes(PlatformRootstrap rootstrap) {\r
String remoteIncludePath = getRemoteIncludePath(rootstrap);\r
- String remoteDebugsrcPath = getRemoteDebugsrcPath(rootstrap);\r
IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();\r
- boolean syncInclude = false;\r
- boolean syncDebugsrc = false;\r
try {\r
boolean exists = filetool.hasDirectory(remoteIncludePath, new NullProgressMonitor());\r
if (exists) {\r
IRemoteItem item = filetool.getDirectory(remoteIncludePath, new NullProgressMonitor());\r
long currentModificationTime = item.getModificationTime();\r
if (includeDirModificationTime != currentModificationTime) {\r
- syncInclude = true;\r
+ return true;\r
}\r
}\r
- exists = filetool.hasDirectory(remoteDebugsrcPath, new NullProgressMonitor());\r
+ } catch (RemoteOperationException e) {\r
+ e.printStackTrace();\r
+ } catch (RemoteConnectionException e) {\r
+ e.printStackTrace();\r
+ } catch (CancelException e) {\r
+ e.printStackTrace();\r
+ } \r
+ return false;\r
+ }\r
+ \r
+ public static boolean isChangedDebugsrc(PlatformRootstrap rootstrap) {\r
+ String remoteDebugsrcPath = getRemoteDebugsrcPath(rootstrap);\r
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();\r
+ try {\r
+ boolean exists = filetool.hasDirectory(remoteDebugsrcPath, new NullProgressMonitor());\r
if (exists) {\r
IRemoteItem item = filetool.getDirectory(remoteDebugsrcPath, new NullProgressMonitor());\r
long currentModificationTime = item.getModificationTime();\r
if (debugsrcDirModificationTime != currentModificationTime) {\r
- syncDebugsrc = true;\r
+ return true;\r
}\r
}\r
} catch (RemoteOperationException e) {\r
e.printStackTrace();\r
} catch (CancelException e) {\r
e.printStackTrace();\r
- }\r
+ } \r
+ return false;\r
+ }\r
+ \r
+ public static void syncronizeIfChanges(PlatformRootstrap rootstrap, IProgressMonitor monitor) {\r
+ boolean syncInclude = isChangedIncludes(rootstrap);\r
+ boolean syncDebugsrc = isChangedDebugsrc(rootstrap);\r
syncronize(rootstrap, syncInclude, syncDebugsrc, monitor);\r
}\r
\r
final String host = RemoteConnectionManager.getRemoteTools().getHost();\r
final String user = RemoteConnectionManager.getRemoteTools().getUser();\r
final String sshKeyPath = RemoteConnectionManager.getRemoteTools().getPrivateKey();\r
- monitor.beginTask("Syncronize includes...", list.size() * 2);\r
+ monitor.beginTask("Synchronize includes... (This may take a few moments)", list.size() * 2);\r
for (PlatformRootstrap rootstrap : list) {\r
final String remoteIncludePath = getRemoteIncludePath(rootstrap);\r
final String remoteDebugsrcPath = getRemoteDebugsrcPath(rootstrap); \r
try {\r
UserLogger.start(PlatformUserInteraction.CATE_SYNCRONIZE, PlatformUserInteraction.SYNC_INCLUDES);\r
if (syncIncludes) {\r
- monitor.subTask(String.format("Syncronize includes... [%s]", rootstrap.getId()));\r
- processor.downloadSync(remoteIncludePath, usrDir.toString(), monitor);\r
+ monitor.subTask(String.format("Synchronize includes... [%s]", rootstrap.getId()));\r
+ processor.downloadSync(remoteIncludePath, usrDir.toString(), EXCLUDES, monitor);\r
}\r
monitor.worked(1);\r
if (syncDebugsrc) {\r
if (!debugDir.exists()) {\r
FileUtil.createDirectory(debugDir);\r
}\r
- monitor.subTask(String.format("Syncronize debug source... [%s]", rootstrap.getId()));\r
- \r
- processor.downloadSync(remoteDebugsrcPath, debugDir.toString(), monitor);\r
+ monitor.subTask(String.format("Synchronize debug source... [%s]", rootstrap.getId()));\r
+ processor.downloadSync(remoteDebugsrcPath, debugDir.toString(), null, monitor);\r
}\r
monitor.worked(1);\r
UserLogger.end(PlatformUserInteraction.CATE_SYNCRONIZE, PlatformUserInteraction.SYNC_INCLUDES);\r
this.sshPrivateKey = sshPrivateKey;\r
}\r
\r
- public boolean downloadSync(String remotePath, String localPath, IProgressMonitor monitor) throws InterruptedException {\r
+ public boolean downloadSync(String remotePath, String localPath, String[] excludes, IProgressMonitor monitor) throws InterruptedException {\r
SmartBuildInterface sbi = SmartBuildInterface.getInstance();\r
String[] envs = sbi.getEnvironmentVariables();\r
Map<String, String> envMap = new HashMap<String, String>();\r
envMap.put(key, value);\r
}\r
}\r
+ String excludeCmd = "";\r
+ if (excludes != null) {\r
+ for (String exclude : excludes) {\r
+ excludeCmd += String.format("--exclude=%s ", exclude);\r
+ }\r
+ }\r
+ \r
String msysBinPath = sbi.getMsysBinPath();\r
StringBuffer cmd = new StringBuffer();\r
cmd.append(new Path(msysBinPath).append("sh.exe").toOSString());\r
cmd.append(sshPrivateKey);\r
cmd.append(" -o StrictHostKeyChecking=no");\r
cmd.append("' ");\r
+ if (!excludeCmd.isEmpty()) {\r
+ cmd.append(excludeCmd);\r
+ }\r
cmd.append(user);\r
cmd.append("@");\r
cmd.append(host);\r
import org.tizen.nativeplatform.util.PlatformUserInteraction;\r
import org.tizen.nativeplatform.util.RootstrapUtil;\r
\r
-public class WorkspaceSyncronizer {\r
+public class WorkspaceSynchronizer {\r
\r
public static String[] EXCLUDES = {".git/", "Debug/", "Release/", ".cproject", ".project", ".tproject",\r
".gitignore"};\r
View.Contextmenu.Manage = Manage Packages
View.Contextmenu.Remove = Remove
View.Contextmenu.Export = Export
-View.Contextmenu.Sync = Sync Includes
+View.Contextmenu.Sync = Sync Include && Debug files
View.Contextmenu.OpenDbgsrc = Open Debug Source
View.Desc.Arch = * Architecture: %s(%s)
import java.util.Map;
import java.util.ResourceBundle;
-import org.eclipse.ui.ide.IDE;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISizeProvider;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.ViewPart;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer;
import org.tizen.nativeplatform.pkgmgr.ui.RPMPackageDialog;
import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
-import org.tizen.nativeplatform.remote.connection.RootstrapSyncronizer;
+import org.tizen.nativeplatform.remote.connection.RootstrapSynchronizer;
import org.tizen.nativeplatform.remote.connection.RsyncProcessor;
import org.tizen.nativeplatform.repo.commander.LocalRepoMounter;
import org.tizen.nativeplatform.repo.commander.RepoManager;
final PlatformRootstrap selected = (PlatformRootstrap) item[0].getData();
String rootstrapPath = RootstrapUtil.getUserSyncRootstrapPath(selected.getId());
String defaultPath = new Path(rootstrapPath).append("usr").append("src").append("debug").toString();
+ File debugSrcPath = new File(defaultPath);
+ if (!debugSrcPath.exists()) {
+ String msg = String.format("There is no any debug source in \"%s\" rootstrap.\n" +
+ "Try it again after installing debug packages using \"Manage Packages\" menu.", selected.getId());
+ DialogUtil.openMessageDialog(shell, msg);
+ return;
+ }
+ long dstTime = debugSrcPath.lastModified();
+ long srcTime = RootstrapSynchronizer.getDebugsrcPathLastmodifiedTime(selected);
+ if (srcTime != dstTime) {
+ String msg = "There are changes for debug source in remote rootstrap.\n" +
+ "Do you want to synchronize the changes?";
+ int result = DialogUtil.openQuestionDialog(shell, "Do you want to synchronize?", msg);
+ if (result == SWT.YES) {
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ monitor.beginTask("Synchronize debug sources...", -1);
+ try {
+ RootstrapSynchronizer.syncronize(selected, false, true, monitor);
+ } finally {
+ monitor.done();
+ }
+ }
+ });
+ } catch (Exception e) {
+ logger.error("Failed to syncronize debug sources", e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ "Failed to syncronize debug sources", e.toString()));
+ return;
+ }
+ }
+ }
FileDialog fd = new FileDialog(shell, SWT.OPEN | SWT.SINGLE);
fd.setText("Select debug source file");
fd.setFilterPath(defaultPath);
@Override
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
- monitor.beginTask("Syncronize includes...", -1);
+ monitor.beginTask("Synchronize includes...", -1);
try {
- RootstrapSyncronizer.syncronize(selected, monitor);
+ RootstrapSynchronizer.syncronize(selected, monitor);
} finally {
monitor.done();
}
throw new InterruptedException();
}
if (OSChecker.isWindows()) {
- RootstrapSyncronizer.syncronize(generatedRootstrap, monitor);
+ RootstrapSynchronizer.syncronize(generatedRootstrap, monitor);
}
}
});
}
final boolean needRemoteSync = OSChecker.isWindows();
if (needRemoteSync) {
- RootstrapSyncronizer.cacheModificationTime(selected);
+ RootstrapSynchronizer.cacheModificationTime(selected);
}
// launch package manager
IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
RootstrapManager.updateRootstrap(selected);
monitor.worked(1);
if (needRemoteSync) {
- RootstrapSyncronizer.syncronizeIfChanges(selected, new SubProgressMonitor(monitor, 1));
+ RootstrapSynchronizer.syncronizeIfChanges(selected, new SubProgressMonitor(monitor, 1));
}
monitor.worked(1);
} finally {