package org.tizen.nativeplatform;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
PlatformProjectDependentPackager.getInstance(), true);
PreferencesManager.setDefaultValues();
CommandUtil.clearPlatformTempDir();
+ PlatformResourceChangeListener listener = new PlatformResourceChangeListener();
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(
+ listener, IResourceChangeEvent.PRE_DELETE);
}
/*
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.ptp.remotetools.core.IRemoteExecutionTools;
import org.eclipse.ptp.remotetools.core.IRemoteFileTools;
+import org.eclipse.ptp.remotetools.core.IRemoteScript;
import org.eclipse.ptp.remotetools.exception.CancelException;
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.widgets.Display;
import org.tizen.common.util.OSChecker;
throw new CoreException(status);
}
}
+ gitInit(project);
+ }
+
+
+ private static void gitInit(IProject project) {
+ String targetPath = RootstrapUtil.getUserSyncWorkspacePath(project.getName());
+ String workspacePath = new Path(targetPath).removeLastSegments(1).toString();
+ IPath projectPath = new Path(workspacePath).append(project.getName());
+ String gitPath = projectPath.append(".git").toString();
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ try {
+ boolean exists = filetool.hasDirectory(projectPath.toString(), new NullProgressMonitor());
+ if (exists) {
+ exists = filetool.hasDirectory(gitPath, new NullProgressMonitor());
+ if (!exists) {
+ IRemoteExecutionTools execTool = RemoteConnectionManager.getRemoteTools().getExecTool();
+ String cmds[] = {"cd " + projectPath, "git init"};
+ IRemoteScript script = execTool.createScript();
+ script.setScript(cmds);
+ execTool.executeScript(script);
+ }
+ }
+ } catch (RemoteExecutionException e) {
+ e.printStackTrace();
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ }
}
protected boolean invokeExternalBuild(int kind, IProject project, IConfiguration configuration,
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.tizen.common.util.OSChecker;
args.add(op);
}
args.add(DEFINE_OP);
- args.add("BUILD_TYPE ${BUILD_TYPE}");
+ ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(config);
+ IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
+ IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
+ for (IEnvironmentVariable var : vars) {
+ if (var.getName().equals("BUILD_TYPE")) {
+ args.add(String.format("\"BUILD_TYPE %s\"", var.getValue()));
+ break;
+ }
+ }
return args.toArray(new String[0]);
}
List<String> args = new ArrayList<String>();
if (OSChecker.isWindows()) {
args.add("/C");
- args.add("rmdir");
- args.add("/S");
- args.add("/Q");
+ if (configPath.toFile().exists()) {
+ args.add("rmdir");
+ args.add("/S");
+ args.add("/Q");
+ args.add(configPath.toOSString());
+ }
} else {
args.add("-rf");
+ args.add(configPath.toOSString());
}
- args.add(configPath.toOSString());
return args.toArray(new String[0]);
}
List<String> xmls = getRemoteXmlFiles(rootstrap);
for (String xml : xmls) {
try {
- String fileName = FileUtil.getFileNameFromPath(xml);
- String targetPath = configPath.append(fileName).toOSString();
+ String filename = FileUtil.getFileNameFromPath(xml);
+ String targetPath = configPath.append(filename).toOSString();
+ String remoteTargetPath = remoteConfigPath.append(filename).toString();
+ filetool.copyFile(xml, remoteTargetPath, new NullProgressMonitor());
copytool.downloadFileToFile(xml, targetPath);
xmlfiles.add(targetPath);
} catch (RemoteConnectionException e) {
contents = new StringBuilder();
input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ err = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
String line = null;
while ((line = input.readLine()) != null) {
contents.append(line);
throw new InterruptedException("Command execution is canceled!");
}
}
+ if (includeStdErr) {
+ while ((line = err.readLine()) != null) {
+ contents.append(line);
+ contents.append(LINE_SEPARATOR);
+ if (monitor != null && monitor.isCanceled()) {
+ contents.append(String.format("Canceled command: %s", command));
+ throw new InterruptedException("Command execution is canceled!");
+ }
+ }
+ }
// wait for process finish
proc.waitFor();
import java.util.ArrayList;
import java.util.List;
+import org.tizen.common.util.OSChecker;
import org.tizen.nativeplatform.command.launcher.HostCommandLauncher;
+import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
public class GBSOptionManager {
private static List<GBSOption> options = new ArrayList<GBSOption>();
// check GBS command
try {
+ if (OSChecker.isWindows()) {
+ if (!RemoteConnectionManager.connected()) {
+ return false;
+ }
+ }
if (!HostCommandLauncher.execute("which gbs")) {
return false;
}
+
+ // In windows, version output is from error stream. It should be fixed.
+ // In ubuntu, version output is from standard output stream.
String result = HostCommandLauncher.executeOutput("gbs --version", null, true, null);
// result format : gbs [version]
startArgs = true;
}
}
- initialized = true;
+ setInitialize(true);
+ }
+
+ public static void setInitialize(boolean value) {
+ initialized = value;
}
}
}
private void createDialogDescription(Composite composite) {
- Composite comp_descrip = new Composite(composite, SWT.NONE);
+ Composite comp_descrip = new Composite(composite, SWT.NONE | SWT.BORDER);
Color whiteColor = new Color(composite.getDisplay(), 255, 255, 255);
comp_descrip.setLayout(new GridLayout(1, false));
}
private void createTabs(Composite parent) {
- tabFolder = new TabFolder(parent, SWT.BORDER);
+ tabFolder = new TabFolder(parent, SWT.NONE);
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
tabFolder.setLayout(new GridLayout(1, false));
if (enableRootstrapTab) {
\r
public class WorkspaceSyncronizer {\r
\r
- public static String[] EXCLUDES = {".git/", "Debug/", "Release/", ".cproject", ".project", ".tproject"};\r
+ public static String[] EXCLUDES = {".git/", "Debug/", "Release/", ".cproject", ".project", ".tproject",\r
+ ".gitignore"};\r
\r
public static boolean syncronize(IProject project, IProgressMonitor monitor) {\r
final String host = RemoteConnectionManager.getRemoteTools().getHost();\r
RsyncProcessor processor = new RsyncProcessor(host, user, sshKeyPath);\r
UserLogger.end(PlatformUserInteraction.CATE_SYNCRONIZE, PlatformUserInteraction.SYNC_WORKSPACE);\r
boolean result = processor.uploadSync(sourcePath, workspacePath, EXCLUDES, monitor);\r
- if (result) {\r
- gitInit(workspacePath, project);\r
- }\r
return result;\r
} catch (RemoteOperationException e) {\r
e.printStackTrace();\r
}\r
return false;\r
}\r
- \r
- private static void gitInit(String workspacePath, IProject project) { \r
- IPath projectPath = new Path(workspacePath).append(project.getName());\r
- String gitPath = projectPath.append(".git").toString();\r
- IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();\r
- try {\r
- boolean exists = filetool.hasDirectory(gitPath, new NullProgressMonitor());\r
- if (!exists) {\r
- IRemoteExecutionTools execTool = RemoteConnectionManager.getRemoteTools().getExecTool();\r
- String cmds[] = {"cd " + projectPath, "git init"};\r
- IRemoteScript script = execTool.createScript();\r
- script.setScript(cmds);\r
- execTool.executeScript(script);\r
- }\r
- } catch (RemoteExecutionException e) {\r
- e.printStackTrace();\r
- } catch (RemoteOperationException e) {\r
- e.printStackTrace();\r
- } catch (RemoteConnectionException e) {\r
- e.printStackTrace();\r
- } catch (CancelException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
}\r
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.ptp.remotetools.core.IRemoteFileTools;
+import org.eclipse.ptp.remotetools.exception.CancelException;
+import org.eclipse.ptp.remotetools.exception.RemoteConnectionException;
+import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
import org.tizen.nativeplatform.IPlatformProject;
import org.tizen.nativeplatform.IPlatformXMLStore;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
import org.tizen.nativeplatform.manifest.PlatformManifestXMLStore;
+import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
import org.tizen.nativeplatform.types.PkgTypes;
public class PlatformProjectUtil {
break;
}
}
-
return result;
}
+
+ public static void removeRemoteProject(String projectName) {
+ if (!RemoteConnectionManager.connected()) {
+ return;
+ }
+ String remoteProjectPath = RootstrapUtil.getUserSyncWorkspacePath(projectName);
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ try {
+ filetool.removeDirectory(remoteProjectPath, new NullProgressMonitor());
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ }
+ }
}
.toString();
}
- public static String getUserSyncWorkspacePath(String project) {
+ public static String getUserSyncWorkspacePath() {
InetAddress ia = null;
try {
ia = InetAddress.getLocalHost();
SmartBuildInterface sbi = SmartBuildInterface.getInstance();
String linuxWorkspace = sbi.getMinGWPathFromWindowsPath(workspace, false);
String dir = ip + "_" + user;
- return new Path(getRemoteRootstrapBasePath()).append(REMOTE_WORKSPACE_DIR).append(dir).append(linuxWorkspace).append(project).toString();
+ return new Path(getRemoteRootstrapBasePath()).append(REMOTE_WORKSPACE_DIR).append(dir).append(linuxWorkspace).toString();
+ }
+
+ public static String getUserSyncWorkspacePath(String project) {
+ return new Path(getUserSyncWorkspacePath()).append(project).toString();
}
public static String getUserSyncRootstrapPath(String id) {
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.IWorkspace;
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.SubProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.ptp.remotetools.core.IRemoteCopyTools;
import org.eclipse.ptp.remotetools.core.IRemoteFileTools;
+import org.eclipse.ptp.remotetools.core.IRemoteItem;
import org.eclipse.ptp.remotetools.exception.CancelException;
import org.eclipse.ptp.remotetools.exception.RemoteConnectionException;
import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
import org.tizen.nativeplatform.Activator;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
import org.tizen.nativeplatform.command.launcher.CommandUtil;
+import org.tizen.nativeplatform.gbs.GBSOptionManager;
import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer;
import org.tizen.nativeplatform.pkgmgr.ui.RPMPackageDialog;
+import org.tizen.nativeplatform.remote.connection.PlatformResourceProxyVisitor;
import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
import org.tizen.nativeplatform.remote.connection.RootstrapSyncronizer;
import org.tizen.nativeplatform.remote.connection.RsyncProcessor;
InterruptedException {
monitor.beginTask("Synchronizing...", 4);
try {
- monitor.subTask("Synchronizing rootstraps...");
RootstrapManager.reinitialize(new SubProgressMonitor(monitor, 1));
monitor.subTask("Clear platform temp directory");
CommandUtil.clearPlatformTempDir();
monitor.worked(1);
initBuildserver(new SubProgressMonitor(monitor, 1));
+ initWorkspace(new SubProgressMonitor(monitor, 1));
SWTUtil.syncExec(new Runnable() {
public void run() {
updateToolbarEnable();
}
}
+ private void initWorkspace(IProgressMonitor monitor) {
+ monitor.beginTask("", 4);
+ monitor.subTask("Initialize workspace...");
+ List<String> projList = new ArrayList<String>();
+ try {
+ IWorkspace works = ResourcesPlugin.getWorkspace();
+ IProject[] projs = works.getRoot().getProjects();
+ for (IProject proj : projs) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(proj);
+ if (info == null) {
+ continue;
+ }
+ IConfiguration config = info.getDefaultConfiguration();
+ if (config == null) {
+ continue;
+ }
+ IManagedProject managedProject = config.getManagedProject();
+ if (managedProject == null) {
+ continue;
+ }
+ String projectArtifactType = managedProject.getProjectType() != null ? managedProject
+ .getProjectType().getBuildArtefactType().getId()
+ : null;
+ if (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)) {
+ continue;
+ }
+ projList.add(proj.getName());
+ }
+ monitor.worked(1);
+
+ // remove remote projects if it do not exists on local workspace.
+ String userSyncworkspace = RootstrapUtil.getUserSyncWorkspacePath();
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+
+ filetool.assureDirectory(userSyncworkspace, new SubProgressMonitor(monitor, 1));
+ IRemoteItem[] items = filetool.listItems(userSyncworkspace, new SubProgressMonitor(monitor, 1));
+ List<String> removeProjs = new ArrayList<String>();
+ for (IRemoteItem item : items) {
+ String projectName = new Path(item.getPath()).lastSegment();
+ if (!projList.contains(projectName)) {
+ removeProjs.add(item.getPath());
+ }
+ }
+ removeRemoteProjects(removeProjs, new SubProgressMonitor(monitor, 1));
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ } finally {
+ monitor.done();
+ }
+ }
+
+ private void removeRemoteProjects(List<String> projPath, IProgressMonitor monitor) {
+ monitor.beginTask("", projPath.size());
+ monitor.subTask("Remove projects...");
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ try {
+ for (String path : projPath) {
+ filetool.removeDirectory(path, new SubProgressMonitor(monitor, 1));
+ }
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ } finally {
+ monitor.done();
+ }
+ }
+
private void initBuildserver(IProgressMonitor monitor) {
monitor.beginTask("Setting build server...", 3);
IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
"Failed to close remote connection", e.getMessage()));
return;
}
+ GBSOptionManager.setInitialize(false);
}
private void showAddDialog() {