import org.eclipse.core.runtime.CoreException;
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.Status;
-import org.tizen.common.util.ProcessMonitorThread;
+import org.eclipse.ptp.remotetools.core.IRemoteExecutionTools;
+import org.eclipse.ptp.remotetools.core.IRemoteScript;
+import org.tizen.common.util.OSChecker;
import org.tizen.nativecommon.ProjectUtil;
import org.tizen.nativecommon.build.ProjectTypeManager;
+import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.Activator;
+import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
+import org.tizen.nativeplatform.remote.connection.SourceUploader;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
public class PlatformBuildCommandLauncher extends CommandLauncher {
@Override
public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory,
IProgressMonitor monitor) throws CoreException {
- Process proc = null;
-
if (commandPath.toString().contains("/usr/bin/gbs")) {
IProject proj = getProject();
PlatformProjectDependentBuilder builder = (PlatformProjectDependentBuilder) ProjectTypeManager
.getProjectBuilderInstance(proj);
IConfiguration config = ManagedBuildManager.getBuildInfo(proj)
.getDefaultConfiguration();
- IPath workingPath = new Path(proj.getLocation().toOSString());
- String[] new_envs = builder.getEnvironment(config);
-
- String command = "";
- String[] arguments = null;
- if ("clean".equals(args[0])) {
- command = builder.getCleanCommand(config);
- arguments = builder.getCleanArguments(config);
- } else {
- command = builder.getBuildCommand(config);
- arguments = builder.getBuildArguments(config);
- }
-
- if (command == null || command.isEmpty()) {
- Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
- "Failed to build the project", null);
- throw new CoreException(status);
- }
- proc = super.execute(new Path(command), arguments, new_envs, workingPath,
- new NullProgressMonitor());
if ("clean".equals(args[0])) {
+ setCleanProcess(builder, config, monitor);
proj.touch(monitor);
ProjectUtil.refreshResources(proj);
+ } else {
+ setBuildProcess(builder, config, monitor);
}
+ } else {
+ fProcess = super.execute(commandPath, args, env, changeToDirectory, monitor);
+ }
+ return fProcess;
+ }
+
+ private void setBuildProcess(PlatformProjectDependentBuilder builder, IConfiguration config,
+ IProgressMonitor monitor) throws CoreException {
+ if (OSChecker.isWindows()) {
+ setRemoteBuildProcess(builder, config, monitor);
+ } else {
+ setLocalBuildProcess(builder, config, monitor);
+ }
+ }
+ private void setCleanProcess(PlatformProjectDependentBuilder builder, IConfiguration config,
+ IProgressMonitor monitor) throws CoreException {
+ if (OSChecker.isWindows()) {
+ setRemoteCleanProcess(builder, config, monitor);
} else {
- proc = super.execute(commandPath, args, env, changeToDirectory, monitor);
+ setLocalCleanProcess(builder, config, monitor);
+ }
+ }
+
+ private void setLocalBuildProcess(PlatformProjectDependentBuilder builder,
+ IConfiguration config, IProgressMonitor monitor) throws CoreException {
+ IProject proj = getProject();
+ IPath workingPath = new Path(proj.getLocation().toOSString());
+ String[] new_envs = builder.getEnvironment(config);
+ String command = builder.getBuildCommand(config);
+ String[] arguments = builder.getBuildArguments(config);
+ if (command == null || command.isEmpty()) {
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ "Failed to build the project", null);
+ throw new CoreException(status);
}
+ fProcess = super.execute(new Path(command), arguments, new_envs, workingPath, monitor);
+ }
- ProcessMonitorThread pmt = new ProcessMonitorThread(proc, monitor);
- pmt.start();
+ private void setLocalCleanProcess(PlatformProjectDependentBuilder builder,
+ IConfiguration config, IProgressMonitor monitor) throws CoreException {
+ IProject proj = getProject();
+ IPath workingPath = new Path(proj.getLocation().toOSString());
+ String[] new_envs = builder.getEnvironment(config);
+ String command = builder.getCleanCommand(config);
+ String[] arguments = builder.getCleanArguments(config);
+ if (command == null || command.isEmpty()) {
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ "Failed to clean the project", null);
+ throw new CoreException(status);
+ }
+ fProcess = super.execute(new Path(command), arguments, new_envs, workingPath, monitor);
+ }
+
+ private void setRemoteBuildProcess(PlatformProjectDependentBuilder builder,
+ IConfiguration config, IProgressMonitor monitor) throws CoreException {
+ if (!RemoteConnectionManager.connected()) {
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ "Connect to remote build server", null);
+ throw new CoreException(status);
+ }
+ IProject proj = getProject();
+ String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+ String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
+ if (RootstrapManager.getRootstrap(rootId).isDefault()) {
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, "Select user rootstrap",
+ null);
+ throw new CoreException(status);
+ }
+ String command = builder.getBuildCommand(config);
+ String[] arguments = builder.getBuildArguments(config);
+ for (String a : arguments) {
+ command += " " + a;
+ }
+ String remoteCmd = command.trim();
+ SourceUploader uploader = new SourceUploader(proj);
+ String targetpath = uploader.upload();
+ if (targetpath == null) {
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ "Failed to upload source", null);
+ throw new CoreException(status);
+ }
+ try {
+ IRemoteExecutionTools exectool = RemoteConnectionManager.getRemoteTools().getExecTool();
+ IRemoteScript script = exectool.createScript();
+ String commands[] = { "cd " + targetpath, remoteCmd };
+ script.setScript(commands);
+ script.setFetchProcessErrorStream(true);
+ script.setFetchProcessInputStream(true);
+ script.setFetchProcessOutputStream(true);
+ fProcess = exectool.executeProcess(script);
+ } catch (Exception e) {
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ "Failed to create remote build process", e);
+ throw new CoreException(status);
+ }
+ }
- return proc;
+ private void setRemoteCleanProcess(PlatformProjectDependentBuilder builder,
+ IConfiguration config, IProgressMonitor monitor) throws CoreException {
+ IProject proj = getProject();
+ IPath workingPath = new Path(proj.getLocation().toOSString());
+ String command = builder.getCleanCommand(config);
+ String[] arguments = builder.getCleanArguments(config);
+ fProcess = super.execute(new Path(command), arguments, null, workingPath, monitor);
}
}
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
+import org.tizen.common.util.OSChecker;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.build.IBuildCommandProvider;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
public static final String BUILD_COMMAND = "/usr/bin/gbs";
public static final String CLEAN_COMMAND = "/bin/rm";
public static final String BUILD_SUBCOMMAND = "build";
+ public static final String WINDOWS_CMD_COMMAND = "cmd";
public static final String ARCH_OP = "--arch";
public static final String REPO_OP = "--repository";
public static final String DEFINE_OP = "--define";
args.add(REPO_OP);
args.add(snapshot);
}
- args.add(String.format("%s=%s", BUILDROOT_OP, rt.getPath().toOSString()));
+ args.add(String.format("%s=%s", BUILDROOT_OP, rt.getPath().toString()));
args.add(String.format("%s=zypper,gdb,gdb-server", EXTRAPKG_OP));
for (String op : PlatformConfigurationManager.getGBSOptions(config)) {
args.add(op);
@Override
public String getCleanCommand() {
- return CLEAN_COMMAND;
+ if (OSChecker.isWindows()) {
+ return WINDOWS_CMD_COMMAND;
+ } else {
+ return CLEAN_COMMAND;
+ }
}
@Override
IProject project = (IProject) config.getOwner();
IPath configPath = project.getLocation().append(config.getName());
List<String> args = new ArrayList<String>();
- args.add("-rf");
+ if (OSChecker.isWindows()) {
+ args.add("/C");
+ args.add("rmdir");
+ args.add("/S");
+ args.add("/Q");
+ } else {
+ args.add("-rf");
+ }
args.add(configPath.toOSString());
return args.toArray(new String[0]);
}
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+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.common.util.FileUtil;
+import org.tizen.common.util.OSChecker;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.build.IBuildResultProcessor;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
import org.tizen.nativeplatform.filefilter.RpmFileFilter;
import org.tizen.nativeplatform.filefilter.XmlFileFilter;
+import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.util.RootstrapUtil;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
public class GBSBuildResultProcessor implements IBuildResultProcessor {
@Override
public boolean process(String[] buildArguments) {
+ if (OSChecker.isWindows()) {
+ return remoteProcess(buildArguments);
+ } else {
+ return localProcess(buildArguments);
+ }
+ }
+
+ private boolean localProcess(String[] buildArguments) {
if (buildArguments != null && buildArguments.length > 0) {
if (buildArguments[0].equals("clean")) {
return true;
return true;
}
+ private boolean remoteProcess(String[] buildArguments) {
+ if (buildArguments != null && buildArguments.length > 0) {
+ if (buildArguments[0].equals("clean")) {
+ return true;
+ }
+ }
+ String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+ String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
+ PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId);
+ if (rootstrap == null) {
+ return false;
+ }
+ List<String> rpms = getRemoteRpmFiles(rootstrap);
+ if (rpms.isEmpty()) {
+ return false;
+ }
+ rpmfiles.clear();
+ xmlfiles.clear();
+ IProject project = (IProject) config.getOwner();
+ IPath projectPath = project.getLocation();
+ IPath configPath = project.getLocation().append(config.getName());
+ IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool();
+ for (String rpm : rpms) {
+ try {
+ String filename = FileUtil.getFileNameFromPath(rpm);
+ String targetPath = configPath.append(filename).toOSString();
+ copytool.downloadFileToFile(rpm, targetPath);
+ rpmfiles.add(targetPath);
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ }
+ }
+ System.out.print(true);
+ List<String> xmls = getRemoteXmlFiles(rootstrap);
+ for (String xml : xmls) {
+ try {
+ String fileName = FileUtil.getFileNameFromPath(xml);
+ String targetPath = projectPath.append(fileName).toOSString();
+ copytool.downloadFileToFile(xml, targetPath);
+ xmlfiles.add(targetPath);
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ }
+ }
+ return true;
+ }
+
+ private List<String> getRemoteRpmFiles(PlatformRootstrap rootstrap) {
+ List<String> rpms = new ArrayList<String>();
+ String rootstrapPath = RootstrapUtil.getRemoteRootstrapScratchPath(rootstrap.getId());
+ String arch = rootstrap.getArch();
+ String rpmPath = new Path(rootstrapPath).append("home").append("abuild").append("rpmbuild")
+ .append("RPMS").append(arch).toString();
+ try {
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ boolean exists = filetool.hasDirectory(rpmPath, new NullProgressMonitor());
+ if (exists) {
+ IRemoteItem[] items = filetool.listItems(rpmPath, new NullProgressMonitor());
+ for (IRemoteItem item : items) {
+ if (!item.isDirectory()) {
+ String path = item.getPath();
+ String name = FileUtil.getFileNameFromPath(path);
+ String ext = FileUtil.getFileExtension(name);
+ if (ext != null && ext.equals("rpm")) {
+ rpms.add(path);
+ }
+ }
+ }
+ }
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ }
+ return rpms;
+ }
+
private List<String> getRpmFiles(PlatformRootstrap rootstrap) {
List<String> rpms = new ArrayList<String>();
String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
return rpms;
}
+ private List<String> getRemoteXmlFiles(PlatformRootstrap rootstrap) {
+ List<String> xmls = new ArrayList<String>();
+
+ String rootstrapPath = RootstrapUtil.getRemoteRootstrapScratchPath(rootstrap.getId());
+ String buildPath = new Path(rootstrapPath).append("home").append("abuild")
+ .append("rpmbuild").append("BUILD").toString();
+ try {
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ boolean exists = filetool.hasDirectory(buildPath, new NullProgressMonitor());
+ if (exists) {
+ IRemoteItem[] items = filetool.listItems(buildPath, new NullProgressMonitor());
+ for (IRemoteItem item : items) {
+ if (item.isDirectory()) {
+ IRemoteItem[] files = filetool.listItems(item.getPath(),
+ new NullProgressMonitor());
+ for (IRemoteItem file : files) {
+ String path = file.getPath();
+ String name = FileUtil.getFileNameFromPath(path);
+ String ext = FileUtil.getFileExtension(name);
+ if (ext != null && ext.equals("xml")) {
+ xmls.add(path);
+ }
+ }
+ }
+ }
+ }
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ }
+ return xmls;
+ }
+
private List<String> getXmlFiles(PlatformRootstrap rootstrap) {
List<String> xmls = new ArrayList<String>();
String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
--- /dev/null
+package org.tizen.nativeplatform.remote.connection;\r
+\r
+import java.io.File;\r
+\r
+import org.eclipse.core.filesystem.EFS;\r
+import org.eclipse.core.filesystem.IFileInfo;\r
+import org.eclipse.core.filesystem.IFileStore;\r
+import org.eclipse.core.filesystem.IFileSystem;\r
+import org.eclipse.core.resources.IProject;\r
+import org.eclipse.core.runtime.Assert;\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IPath;\r
+import org.eclipse.core.runtime.Path;\r
+import org.eclipse.ptp.remotetools.core.IRemoteCopyTools;\r
+import org.eclipse.ptp.remotetools.core.IRemoteFileTools;\r
+import org.eclipse.ptp.remotetools.core.IRemoteItem;\r
+import org.eclipse.ptp.remotetools.environment.launcher.core.LinuxPath;\r
+import org.eclipse.ptp.remotetools.exception.CancelException;\r
+import org.eclipse.ptp.remotetools.exception.RemoteConnectionException;\r
+import org.eclipse.ptp.remotetools.exception.RemoteOperationException;\r
+import org.eclipse.ptp.utils.file.core.FileRecursiveEnumeration;\r
+import org.tizen.nativeplatform.util.RootstrapUtil;\r
+\r
+public class SourceUploader {\r
+ \r
+ private IProject project;\r
+ \r
+ private static final String UPLOAD_TARGET_PATH = RootstrapUtil.getRemoteSourcePath();\r
+ \r
+ public SourceUploader(IProject project) {\r
+ this.project = project;\r
+ }\r
+ \r
+ public String upload() {\r
+ File sourcepath = project.getLocation().toFile();\r
+ IPath targetpath = new Path(UPLOAD_TARGET_PATH).append(project.getName());\r
+ try {\r
+ uploadDirectory(sourcepath, targetpath);\r
+ } catch (Exception e) {\r
+ return null;\r
+ }\r
+ return targetpath.toString(); \r
+ }\r
+\r
+ private void doFileUpload(File localFile, IPath remotePath) throws CoreException, CancelException, RemoteConnectionException { \r
+ if (! localFile.exists()) { \r
+ return;\r
+ }\r
+\r
+ Assert.isTrue(localFile.isAbsolute(), "localFile.isAbsolute()"); //$NON-NLS-1$\r
+ Assert.isTrue(localFile.isFile(), "localFile.isFile()"); //$NON-NLS-1$\r
+ Assert.isTrue(remotePath.isAbsolute(), "remotePath.isAbsolute()"); //$NON-NLS-1$\r
+ \r
+ String remotePathAsString = LinuxPath.toString(remotePath);\r
+\r
+ IRemoteCopyTools copyTools = RemoteConnectionManager.getRemoteTools().getCopyTool();\r
+ IRemoteFileTools fileTools = RemoteConnectionManager.getRemoteTools().getFileTool();\r
+\r
+ /*\r
+ if (rule.getOverwritePolicy() == OverwritePolicies.SKIP) {\r
+ if (remoteFile.exists()) {\r
+ //outputWriter.println(NLS.bind(Messages.UploadRuleAction_10, remotePath));\r
+ return;\r
+ }\r
+ } else if (rule.getOverwritePolicy() == OverwritePolicies.NEWER) {\r
+ long difference = localFile.lastModified() - remoteFile.getModificationTime();\r
+ if (difference < 1000) {\r
+ //outputWriter.println(NLS.bind(Messages.UploadRuleAction_11, remotePath));\r
+ return; \r
+ }\r
+ }\r
+ */\r
+ \r
+ /*\r
+ * Upload the file.\r
+ */\r
+ try {\r
+ copyTools.uploadFileToFile(localFile, remotePathAsString);\r
+ } catch (RemoteOperationException e) {\r
+ //errorWriter.println(NLS.bind(Messages.UploadRuleAction_12, e.getMessage()));\r
+ return;\r
+ }\r
+ \r
+ /*\r
+ * Add file to list of files to download back, if this feature was enabled.\r
+ */\r
+ /*\r
+ if (rule.isDownloadBack()) {\r
+ if (downloadBackRule == null) {\r
+ downloadBackRule = new DownloadBackRule();\r
+ }\r
+ downloadBackRule.add(localFile, remotePath);\r
+ }\r
+ */\r
+\r
+ /*\r
+ * Fetch properties of file that was just uploaded.\r
+ */\r
+ IRemoteItem remoteFile = null;\r
+ try {\r
+ remoteFile = fileTools.getFile(remotePathAsString, null);\r
+ } catch (RemoteOperationException e) {\r
+ //errorWriter.println(NLS.bind(Messages.UploadRuleAction_13, e.getMessage()));\r
+ return;\r
+ }\r
+ \r
+ /*\r
+ * Set file permissions. We need help of EFS, since the File class from\r
+ * Java does not providel all information.\r
+ */\r
+ IFileSystem localFileSystem = EFS.getLocalFileSystem();\r
+ IFileStore fileStore = localFileSystem.getStore(new Path(localFile.getPath()));\r
+ IFileInfo fileInfo = fileStore.fetchInfo();\r
+\r
+ boolean read = localFile.canRead();\r
+ boolean write = localFile.canWrite();\r
+ boolean execute = fileInfo.getAttribute(EFS.ATTRIBUTE_EXECUTABLE);\r
+ \r
+ /*\r
+ if (rule.isAsReadOnly()) {\r
+ write = false;\r
+ }\r
+ if (rule.isAsExecutable()) {\r
+ execute = true;\r
+ }\r
+ */\r
+ \r
+ remoteFile.setExecutable(execute);\r
+ remoteFile.setWriteable(write);\r
+ remoteFile.setReadable(read);\r
+ \r
+ /*\r
+ * Set date/time, if required\r
+ */ \r
+ //if (rule.isPreserveTimeStamp()) {\r
+ long timestamp = localFile.lastModified();\r
+ remoteFile.setModificationTime(timestamp);\r
+ //}\r
+ \r
+\r
+ /*\r
+ * Commit changes\r
+ */\r
+ try {\r
+ remoteFile.commitAttributes(null);\r
+ } catch (RemoteOperationException e) {\r
+ //errorWriter.println(NLS.bind(Messages.UploadRuleAction_14, e.getMessage()));\r
+ return;\r
+ }\r
+ }\r
+ \r
+ private void doDirectoryUpload(File localDir, IPath remotePath) throws RemoteConnectionException, CancelException {\r
+ if (! localDir.exists()) {\r
+ //errorWriter.println(NLS.bind(Messages.UploadRuleAction_15, localDir.toString()));\r
+ return;\r
+ }\r
+\r
+ Assert.isTrue(localDir.isDirectory(), "localFile.isDirectory()"); //$NON-NLS-1$\r
+ Assert.isTrue(localDir.isAbsolute(), "localFile.isAbsolute()"); //$NON-NLS-1$\r
+ Assert.isTrue(remotePath.isAbsolute(), "remotePath.isAbsolute()"); //$NON-NLS-1$\r
+\r
+ IRemoteFileTools fileTools = RemoteConnectionManager.getRemoteTools().getFileTool();\r
+ \r
+ /*\r
+ * Create remote directory if not already exists.\r
+ */\r
+ try {\r
+ fileTools.assureDirectory(LinuxPath.toString(remotePath), null);\r
+ } catch (RemoteOperationException e) {\r
+ //errorWriter.println(NLS.bind(Messages.UploadRuleAction_16, e.getMessage()));\r
+ return;\r
+ }\r
+ \r
+ /*\r
+ * Fetch properties of directory that was just uploaded.\r
+ */\r
+ IRemoteItem remoteDirectory = null;\r
+ try {\r
+ remoteDirectory = fileTools.getDirectory(LinuxPath.toString(remotePath), null);\r
+ } catch (RemoteOperationException e) {\r
+ //errorWriter.println(NLS.bind(Messages.UploadRuleAction_17, e.getMessage()));\r
+ return;\r
+ }\r
+ \r
+ /*\r
+ * Set file permissions.\r
+ */\r
+ boolean read = localDir.canRead();\r
+ boolean write = localDir.canWrite();\r
+ boolean execute = true;\r
+ \r
+ /*\r
+ if (rule.isAsReadOnly()) {\r
+ write = false;\r
+ }\r
+ */\r
+ \r
+ remoteDirectory.setExecutable(execute);\r
+ remoteDirectory.setWriteable(write);\r
+ remoteDirectory.setReadable(read);\r
+ \r
+ /*\r
+ * Set date/time, if required\r
+ */\r
+ //if (rule.isPreserveTimeStamp()) {\r
+ long timestamp = localDir.lastModified();\r
+ remoteDirectory.setModificationTime(timestamp);\r
+ //}\r
+\r
+ /*\r
+ * Commit changes\r
+ */\r
+ try {\r
+ remoteDirectory.commitAttributes(null);\r
+ } catch (RemoteOperationException e) {\r
+ //errorWriter.println(NLS.bind(Messages.UploadRuleAction_18, e.getMessage()));\r
+ return;\r
+ } \r
+ }\r
+\r
+ public void uploadDirectory(File localDir, IPath remotePath) throws CoreException, CancelException, RemoteConnectionException {\r
+ Assert.isTrue(localDir.isAbsolute(), "localDir.isAbsolute()"); //$NON-NLS-1$\r
+ Assert.isTrue(remotePath.isAbsolute(), "remotePath.isAbsolute()"); //$NON-NLS-1$\r
+\r
+ //outputWriter.println(NLS.bind(Messages.UploadRuleAction_19, localDir.toString()));\r
+ //outputWriter.println(NLS.bind(Messages.UploadRuleAction_20, LinuxPath.toString(remotePath)));\r
+\r
+ FileRecursiveEnumeration enumeration = null;\r
+ enumeration = new FileRecursiveEnumeration(localDir);\r
+ \r
+ IPath rootPath = new Path(localDir.getAbsolutePath());\r
+ int rootPathLength = rootPath.segmentCount();\r
+ while (enumeration.hasMoreElements()) {\r
+ while (enumeration.hasMoreExceptions()) {\r
+ //errorWriter.println(NLS.bind(Messages.UploadRuleAction_21, enumeration.nextException())); \r
+ }\r
+ File file = (File) enumeration.nextElement();\r
+ IPath filePath = new Path(file.getAbsolutePath());\r
+ IPath relativePath = filePath.removeFirstSegments(rootPathLength);\r
+ IPath remoteFilePath = remotePath.append(relativePath);\r
+ if (file.isDirectory()) {\r
+ //outputWriter.println(NLS.bind(Messages.UploadRuleAction_22, LinuxPath.toString(remoteFilePath)));\r
+ doDirectoryUpload(file, remoteFilePath);\r
+ } else {\r
+ //outputWriter.println(NLS.bind(Messages.UploadRuleAction_23, LinuxPath.toString(relativePath)));\r
+ doFileUpload(file, remoteFilePath);\r
+ }\r
+ }\r
+ while (enumeration.hasMoreExceptions()) {\r
+ //errorWriter.println(NLS.bind(Messages.UploadRuleAction_24, enumeration.nextException())); \r
+ }\r
+ }\r
+}\r
import org.eclipse.ptp.remotetools.exception.CancelException;
import org.eclipse.ptp.remotetools.exception.RemoteConnectionException;
import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
+import org.tizen.common.util.OSChecker;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.command.launcher.CommandUtil;
import org.tizen.nativeplatform.command.launcher.HostCommandLauncher;
public static boolean generate(String rootstrapPath, List<String> reposURLs, String arch,
IPath confFile, IProgressMonitor monitor) throws InterruptedException {
+ if (OSChecker.isWindows()) {
+ return remoteGenerate(rootstrapPath, reposURLs, arch, confFile, monitor);
+ } else {
+ return localGenerate(rootstrapPath, reposURLs, arch, confFile, monitor);
+ }
+ }
+
+ public static boolean generate(String rootstrapPath, String arch, List<Repository> reposURLs,
+ IPath confFile, IProgressMonitor monitor) throws InterruptedException {
+ List<String> repos = new ArrayList<String>();
+ for (Repository repo : reposURLs) {
+ repos.add(repo.getUri());
+ }
+ if (OSChecker.isWindows()) {
+ return remoteGenerate(rootstrapPath, repos, arch, confFile, monitor);
+ } else {
+ return localGenerate(rootstrapPath, repos, arch, confFile, monitor);
+ }
+ }
+
+ private static boolean localGenerate(String rootstrapPath, List<String> reposURLs, String arch,
+ IPath confFile, IProgressMonitor monitor) throws InterruptedException {
File rootstrapDir = new File(rootstrapPath);
String id = rootstrapDir.getName();
String tempDirPath = null;
return true;
}
- public static boolean generate(String rootstrapPath, String arch, List<Repository> reposURLs,
- IPath confFile, IProgressMonitor monitor) throws InterruptedException {
- List<String> repos = new ArrayList<String>();
- for (Repository repo : reposURLs) {
- repos.add(repo.getUri());
- }
- return generate(rootstrapPath, repos, arch, confFile, monitor);
- }
-
- public static boolean remoteGenerate(String rootstrapPath, List<String> reposURLs, String arch,
- IPath confFile, IProgressMonitor monitor) throws InterruptedException {
+ private static boolean remoteGenerate(String rootstrapPath, List<String> reposURLs,
+ String arch, IPath confFile, IProgressMonitor monitor) throws InterruptedException {
IPath rootstrapDir = new Path(rootstrapPath);
String id = rootstrapDir.lastSegment();
String tempDirPath = null;
return true;
}
- public static boolean remoteGenerate(String rootstrapPath, String arch,
- List<Repository> reposURLs, IPath confFile, IProgressMonitor monitor)
- throws InterruptedException {
- List<String> repos = new ArrayList<String>();
- for (Repository repo : reposURLs) {
- repos.add(repo.getUri());
+ public static void remove(String id, String arch) throws InterruptedException {
+ if (OSChecker.isWindows()) {
+ remoteRemove(id, arch);
+ } else {
+ localRemove(id, arch);
}
- return remoteGenerate(rootstrapPath, repos, arch, confFile, monitor);
}
- public static void remove(String id, String arch) throws InterruptedException {
+ public static void remove(String id, String arch, String path) throws InterruptedException {
+ if (OSChecker.isWindows()) {
+ remoteRemove(id, arch, path);
+ } else {
+ localRemove(id, arch);
+ }
+ }
+
+ private static void localRemove(String id, String arch) throws InterruptedException {
String path = RootstrapUtil.getUserRootstrapPath(id);
+ localRemove(id, arch, path);
+ }
+
+ private static void localRemove(String id, String arch, String path)
+ throws InterruptedException {
// check sub-directory
String checkDir = String.format("%s/local/BUILD-ROOTS/scratch.%s.0/proc", path, arch);
if (new File(checkDir).exists()) {
HostCommandLauncher.executeSudo(String.format("sudo -S rm -rf %s", path), null);
}
- public static boolean remoteRemove(String id, String arch) throws InterruptedException {
- String path = RootstrapUtil.getRemoteUserRootstrapPath(id);
+ private static boolean remoteRemove(String id, String arch) throws InterruptedException {
+ String path = RootstrapUtil.getRemoteRootstrapPath(id);
return remoteRemove(id, arch, path);
}
- public static boolean remoteRemove(String id, String arch, String path)
+ private static boolean remoteRemove(String id, String arch, String path)
throws InterruptedException {
String checkDir = String.format("%s/local/BUILD-ROOTS/scratch.%s.0/proc", path, arch);
try {
public static final int LIST_ARM = 1 << 4;
protected static List<PlatformRootstrap> rootstraps = new ArrayList<PlatformRootstrap>();
- protected static List<PlatformRootstrap> userRootstraps = new ArrayList<PlatformRootstrap>();
protected static PlatformRootstrap selectedRootstrap;
protected static Set<IRootstrapChangedListener> changedListener = new HashSet<IRootstrapChangedListener>();
public static void updateRootstrap(PlatformRootstrap rootstrap) {
if (rootstrap != null) {
try {
- XMLPluginGenerator
- .generate(rootstrap.getId(), rootstrap.getName(), rootstrap.getArch(),
- rootstrap.getVersion(), rootstrap.getPath().toOSString(),
- rootstrap.getJustRepoURLs(), rootstrap.getConfFile(),
- rootstrap.isDefault());
+ XMLPluginGenerator.generate(rootstrap.getId(), rootstrap.getName(),
+ rootstrap.getArch(), rootstrap.getVersion(),
+ rootstrap.getPath().toString(), rootstrap.getJustRepoURLs(),
+ rootstrap.getConfFile(), rootstrap.isDefault());
SBIModel.updateRootstrap(rootstrap);
notifyChangedRootstrap();
} catch (SBIException e) {
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.build.exception.SBIException;
import org.tizen.nativecommon.build.model.SBIModel;
-import org.tizen.nativeplatform.build.PlatformConfigurationManager;
import org.tizen.nativeplatform.command.launcher.HostCommandLauncher;
import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
import org.tizen.nativeplatform.repo.commander.RepoManager;
public class RemoteRootstrapManager extends LocalRootstrapManager {
+ protected static List<PlatformRootstrap> userRootstraps = new ArrayList<PlatformRootstrap>();
+
protected static final Logger logger = LoggerFactory.getLogger(RemoteRootstrapManager.class);
private synchronized static void initialize(IProgressMonitor monitor) {
try {
SmartBuildInterface sbi = SmartBuildInterface.getInstance();
String localpluginPath = SmartBuildInterface.getInstance().getPluginPath();
- String remotepluginPath = RootstrapUtil.getRemoteUserRootstrapPluginPath();
+ String remotepluginPath = RootstrapUtil.getRemoteRootstrapPluginPath();
List<String> remotelists = new ArrayList<String>();
IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool();
}
}
+ public static void reinitialize(IProgressMonitor monitor) {
+ init = false;
+ rootstraps.clear();
+ userRootstraps.clear();
+ initialize(monitor);
+ }
+
public static PlatformRootstrap addRootstrap(PlatformRootstrap rootstrap) {
rootstraps.add(rootstrap);
if (!rootstrap.isDefault()) {
PlatformRootstrap rootstrap = getRootstrap(id);
if (rootstrap != null) {
try {
- BaseFileSystemGenerator.remoteRemove(rootstrap.getId(), rootstrap.getArch(),
- rootstrap.getPath().toString());
+ BaseFileSystemGenerator.remove(rootstrap.getId(), rootstrap.getArch(), rootstrap
+ .getPath().toString());
} catch (InterruptedException e) {
logger.error(String.format("Failed to rootstrap: [%s]", id), e);
e.printStackTrace();
if (userRootstraps.contains(rootstrap)) {
userRootstraps.remove(rootstrap);
}
- XMLPluginGenerator.remoteRemove(rootstrap.getId());
+ XMLPluginGenerator.remove(rootstrap.getId());
SBIModel.removeRootstrap(rootstrap);
notifyChangedRootstrap();
return true;
}
}
- public static List<PlatformRootstrap> getUserRootstraps() {
+ public static List<PlatformRootstrap> getRootstraps() {
checkInit();
return userRootstraps;
}
notifyChangedRootstrap();
}
- public static List<PlatformRootstrap> getX86Rootstrap() {
- checkInit();
- List<PlatformRootstrap> list = new ArrayList<PlatformRootstrap>();
- for (PlatformRootstrap r : rootstraps) {
- String arch = r.getArch();
- if (PlatformConfigurationManager.containValue(
- PlatformConfigurationManager.ARCHGROUP_X86, arch)) {
- list.add(r);
- }
- }
- return list;
- }
-
- public static List<PlatformRootstrap> getArmRootstrap() {
- checkInit();
- List<PlatformRootstrap> list = new ArrayList<PlatformRootstrap>();
- for (PlatformRootstrap r : rootstraps) {
- String arch = r.getArch();
- if (PlatformConfigurationManager.containValue(
- PlatformConfigurationManager.ARCHGROUP_ARM, arch)) {
- list.add(r);
- }
- }
- return list;
- }
-
- public static List<PlatformRootstrap> getInitializedRootstrap() {
- checkInit();
- List<PlatformRootstrap> list = new ArrayList<PlatformRootstrap>();
- for (PlatformRootstrap r : rootstraps) {
- if (r.isInitialized()) {
- list.add(r);
- }
- }
- return list;
- }
-
- public static List<PlatformRootstrap> getNonInitializedRootstrap() {
- checkInit();
- List<PlatformRootstrap> list = new ArrayList<PlatformRootstrap>();
- for (PlatformRootstrap r : rootstraps) {
- if (!r.isInitialized()) {
- list.add(r);
- }
- }
- return list;
- }
-
- public static String getRootstrapId(String name) {
- checkInit();
- for (PlatformRootstrap r : rootstraps) {
- if (r.getName().equals(name)) {
- return r.getId();
- }
- }
- return "";
- }
-
- public static PlatformRootstrap getRootstrap(String id) {
- checkInit();
- for (PlatformRootstrap r : rootstraps) {
- if (r.getId().equals(id)) {
- return r;
- }
- }
- return null;
- }
-
- public static boolean existsRootstrap(String id) {
- checkInit();
- for (PlatformRootstrap r : rootstraps) {
- if (r.getId().equals(id)) {
- return true;
- }
- }
- return false;
- }
-
- public static void reinitialize(IProgressMonitor monitor) {
- init = false;
- rootstraps.clear();
- initialize(monitor);
- }
-
- public static void updateRootstrap(PlatformRootstrap rootstrap) {
- if (rootstrap != null) {
- try {
- XMLPluginGenerator
- .remoteGenerate(rootstrap.getId(), rootstrap.getName(),
- rootstrap.getArch(), rootstrap.getVersion(), rootstrap.getPath()
- .toOSString(), rootstrap.getJustRepoURLs(), rootstrap
- .getConfFile(), rootstrap.isDefault());
- SBIModel.updateRootstrap(rootstrap);
- notifyChangedRootstrap();
- } catch (SBIException e) {
- logger.error(String.format("Failed to update rootstrap: [%s]", rootstrap.getId()),
- e);
- e.printStackTrace();
- }
- }
- }
-
private static void checkInit() {
if (!init) {
initialize(new NullProgressMonitor());
boolean initialized = false;
String id = name;
if (immediateGen) {
- if (BaseFileSystemGenerator.remoteGenerate(
- RootstrapUtil.getRemoteUserRootstrapPath(id), arch, reposURLs, confFile,
- monitor)) {
+ if (BaseFileSystemGenerator.generate(RootstrapUtil.getRemoteRootstrapPath(id), arch,
+ reposURLs, confFile, monitor)) {
initialized = true;
} else {
return null;
}
// generate SBI plugins
- if (XMLPluginGenerator.remoteGenerate(id, name, arch, version, null, reposURLs, confFile)) {
- return new PlatformRootstrap(id, name, arch,
- RootstrapUtil.getRemoteUserRootstrapPath(id), reposURLs, confFile, initialized,
- false);
+ if (XMLPluginGenerator.generate(id, name, arch, version, null, reposURLs, confFile)) {
+ return new PlatformRootstrap(id, name, arch, RootstrapUtil.getRemoteRootstrapPath(id),
+ reposURLs, confFile, initialized, false);
} else {
if (immediateGen) {
- BaseFileSystemGenerator.remoteRemove(id, arch);
+ BaseFileSystemGenerator.remove(id, arch);
}
return null;
}
public class RootstrapManager {
public static PlatformRootstrap addRootstrap(PlatformRootstrap rootstrap) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.addRootstrap(rootstrap);
- } else {
- return LocalRootstrapManager.addRootstrap(rootstrap);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.addRootstrap(rootstrap);
+ } else {
+ return LocalRootstrapManager.addRootstrap(rootstrap);
+ }
}
public static boolean removeRootstrap(String id) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.removeRootstrap(id);
- } else {
- return LocalRootstrapManager.removeRootstrap(id);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.removeRootstrap(id);
+ } else {
+ return LocalRootstrapManager.removeRootstrap(id);
+ }
}
public static boolean exportRootstrap(PlatformRootstrap rootstrap, String exportFilePath,
IProgressMonitor monitor) throws InterruptedException {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.exportRootstrap(rootstrap, exportFilePath, monitor);
- } else {
- return LocalRootstrapManager.exportRootstrap(rootstrap, exportFilePath, monitor);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.exportRootstrap(rootstrap, exportFilePath, monitor);
+ } else {
+ return LocalRootstrapManager.exportRootstrap(rootstrap, exportFilePath, monitor);
+ }
}
public static PlatformRootstrap importRootstrap(String importFilePath, IProgressMonitor monitor)
throws InterruptedException {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.importRootstrap(importFilePath, monitor);
- } else {
- return LocalRootstrapManager.importRootstrap(importFilePath, monitor);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.importRootstrap(importFilePath, monitor);
+ } else {
+ return LocalRootstrapManager.importRootstrap(importFilePath, monitor);
+ }
}
-
+
public static void clearRootstrap() {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.clearRootstrap();
- } else {
- LocalRootstrapManager.clearRootstrap();
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.clearRootstrap();
+ } else {
+ LocalRootstrapManager.clearRootstrap();
+ }
}
public static List<PlatformRootstrap> getRootstraps(int listType) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getRootstraps(listType);
- } else {
- return LocalRootstrapManager.getRootstraps(listType);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getRootstraps(listType);
+ } else {
+ return LocalRootstrapManager.getRootstraps(listType);
+ }
}
public static List<PlatformRootstrap> getRootstraps() {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getRootstraps();
- } else {
- return LocalRootstrapManager.getRootstraps();
- }
- }
-
- public static List<PlatformRootstrap> getUserRootstraps() {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getUserRootstraps();
- } else {
- return LocalRootstrapManager.getRootstraps();
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getRootstraps();
+ } else {
+ return LocalRootstrapManager.getRootstraps();
+ }
}
public static List<PlatformRootstrap> getX86Rootstrap() {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getX86Rootstrap();
- } else {
- return LocalRootstrapManager.getX86Rootstrap();
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getX86Rootstrap();
+ } else {
+ return LocalRootstrapManager.getX86Rootstrap();
+ }
}
public static List<PlatformRootstrap> getArmRootstrap() {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getArmRootstrap();
- } else {
- return LocalRootstrapManager.getArmRootstrap();
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getArmRootstrap();
+ } else {
+ return LocalRootstrapManager.getArmRootstrap();
+ }
}
public static List<PlatformRootstrap> getInitializedRootstrap() {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getInitializedRootstrap();
- } else {
- return LocalRootstrapManager.getInitializedRootstrap();
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getInitializedRootstrap();
+ } else {
+ return LocalRootstrapManager.getInitializedRootstrap();
+ }
}
public static List<PlatformRootstrap> getNonInitializedRootstrap() {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getNonInitializedRootstrap();
- } else {
- return LocalRootstrapManager.getNonInitializedRootstrap();
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getNonInitializedRootstrap();
+ } else {
+ return LocalRootstrapManager.getNonInitializedRootstrap();
+ }
}
public static String getRootstrapId(String name) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getRootstrapId(name);
- } else {
- return LocalRootstrapManager.getRootstrapId(name);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getRootstrapId(name);
+ } else {
+ return LocalRootstrapManager.getRootstrapId(name);
+ }
}
public static PlatformRootstrap getRootstrap(String id) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getRootstrap(id);
- } else {
- return LocalRootstrapManager.getRootstrap(id);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getRootstrap(id);
+ } else {
+ return LocalRootstrapManager.getRootstrap(id);
+ }
}
public static PlatformRootstrap getDefaultRootstrap(String arch) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getDefaultRootstrap(arch);
- } else {
- return LocalRootstrapManager.getDefaultRootstrap(arch);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getDefaultRootstrap(arch);
+ } else {
+ return LocalRootstrapManager.getDefaultRootstrap(arch);
+ }
}
public static PlatformRootstrap findDefaultRootstrap(String arch) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.findDefaultRootstrap(arch);
- } else {
- return LocalRootstrapManager.findDefaultRootstrap(arch);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.findDefaultRootstrap(arch);
+ } else {
+ return LocalRootstrapManager.findDefaultRootstrap(arch);
+ }
}
public static boolean existsRootstrap(String id) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.existsRootstrap(id);
- } else {
- return LocalRootstrapManager.existsRootstrap(id);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.existsRootstrap(id);
+ } else {
+ return LocalRootstrapManager.existsRootstrap(id);
+ }
}
public static void reinitialize(IProgressMonitor monitor) {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.reinitialize(monitor);
- } else {
- LocalRootstrapManager.reinitialize(monitor);
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.reinitialize(monitor);
+ } else {
+ LocalRootstrapManager.reinitialize(monitor);
+ }
}
public static void updateRootstrap(PlatformRootstrap rootstrap) {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.updateRootstrap(rootstrap);
- } else {
- LocalRootstrapManager.updateRootstrap(rootstrap);
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.updateRootstrap(rootstrap);
+ } else {
+ LocalRootstrapManager.updateRootstrap(rootstrap);
+ }
}
public static void setSelectedRootstrap(PlatformRootstrap selected) {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.setSelectedRootstrap(selected);
- } else {
- LocalRootstrapManager.setSelectedRootstrap(selected);
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.setSelectedRootstrap(selected);
+ } else {
+ LocalRootstrapManager.setSelectedRootstrap(selected);
+ }
}
public static void setSelectedRootstrap(String id) {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.setSelectedRootstrap(id);
- } else {
- LocalRootstrapManager.setSelectedRootstrap(id);
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.setSelectedRootstrap(id);
+ } else {
+ LocalRootstrapManager.setSelectedRootstrap(id);
+ }
}
public static void resetSelectedRootstrap() {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.resetSelectedRootstrap();
- } else {
- LocalRootstrapManager.resetSelectedRootstrap();
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.resetSelectedRootstrap();
+ } else {
+ LocalRootstrapManager.resetSelectedRootstrap();
+ }
}
public static boolean isInitialized(String rootId) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.isInitialized(rootId);
- } else {
- return LocalRootstrapManager.isInitialized(rootId);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.isInitialized(rootId);
+ } else {
+ return LocalRootstrapManager.isInitialized(rootId);
+ }
}
public static boolean checkInitialized(String rootId) {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.checkInitialized(rootId);
- } else {
- return LocalRootstrapManager.checkInitialized(rootId);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.checkInitialized(rootId);
+ } else {
+ return LocalRootstrapManager.checkInitialized(rootId);
+ }
}
public static PlatformRootstrap getSelectedRootstrap() {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.getSelectedRootstrap();
- } else {
- return LocalRootstrapManager.getSelectedRootstrap();
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.getSelectedRootstrap();
+ } else {
+ return LocalRootstrapManager.getSelectedRootstrap();
+ }
}
public static synchronized void addListener(IRootstrapChangedListener listener) {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.addListener(listener);
- } else {
- LocalRootstrapManager.addListener(listener);
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.addListener(listener);
+ } else {
+ LocalRootstrapManager.addListener(listener);
+ }
}
public static synchronized void removeListener(IRootstrapChangedListener listener) {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.removeListener(listener);
- } else {
- LocalRootstrapManager.removeListener(listener);
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.removeListener(listener);
+ } else {
+ LocalRootstrapManager.removeListener(listener);
+ }
}
public static synchronized void notifyChangedRootstrap() {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.notifyChangedRootstrap();
- } else {
- LocalRootstrapManager.notifyChangedRootstrap();
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.notifyChangedRootstrap();
+ } else {
+ LocalRootstrapManager.notifyChangedRootstrap();
+ }
}
public static synchronized void notifyChangedSelectionListener(String rootName) {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.notifyChangedSelectionListener(rootName);
- } else {
- LocalRootstrapManager.notifyChangedSelectionListener(rootName);
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.notifyChangedSelectionListener(rootName);
+ } else {
+ LocalRootstrapManager.notifyChangedSelectionListener(rootName);
+ }
}
public static void removeLatestTempDirForRootstrap() {
- if (OSChecker.isWindows()) {
- RemoteRootstrapManager.removeLatestTempDirForRootstrap();
- } else {
- LocalRootstrapManager.removeLatestTempDirForRootstrap();
- }
+ if (OSChecker.isWindows()) {
+ RemoteRootstrapManager.removeLatestTempDirForRootstrap();
+ } else {
+ LocalRootstrapManager.removeLatestTempDirForRootstrap();
+ }
}
public static PlatformRootstrap generate(String name, String arch, String version,
List<Repository> reposURLs, boolean immediateGen, IPath confFile,
IProgressMonitor monitor) throws InterruptedException {
- if (OSChecker.isWindows()) {
- return RemoteRootstrapManager.generate(name, arch, version, reposURLs, immediateGen, confFile, monitor);
- } else {
- return LocalRootstrapManager.generate(name, arch, version, reposURLs, immediateGen, confFile, monitor);
- }
+ if (OSChecker.isWindows()) {
+ return RemoteRootstrapManager.generate(name, arch, version, reposURLs, immediateGen,
+ confFile, monitor);
+ } else {
+ return LocalRootstrapManager.generate(name, arch, version, reposURLs, immediateGen,
+ confFile, monitor);
+ }
}
}
import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.tizen.common.util.OSChecker;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.build.model.SBIModel;
import org.tizen.nativecommon.build.model.Target;
protected static final Logger logger = LoggerFactory.getLogger(XMLPluginGenerator.class);
public static boolean generate(String id, String name, String arch, String version,
- String path, List<String> reposURLs) {
- return generate(id, name, arch, version, path, null, reposURLs);
- }
-
- public static boolean generate(String id, String name, String arch, String version,
String path, List<Repository> reposURLs, IPath confFile) {
-
List<String> repos = new ArrayList<String>();
for (Repository repo : reposURLs) {
repos.add(repo.getUri());
}
- return generate(id, name, arch, version, path, confFile, repos);
+ if (OSChecker.isWindows()) {
+ return remoteGenerate(id, name, arch, version, path, repos, confFile, false);
+ } else {
+ return localGenerate(id, name, arch, version, path, repos, confFile, false);
+ }
}
public static boolean generate(String id, String name, String arch, String version,
- String path, IPath confFile, List<String> reposURLs) {
- return generate(id, name, arch, version, path, reposURLs, confFile, false);
+ String path, List<String> reposURLs, IPath confFile, boolean isDefault) {
+ if (OSChecker.isWindows()) {
+ return remoteGenerate(id, name, arch, version, path, reposURLs, confFile, false);
+ } else {
+ return localGenerate(id, name, arch, version, path, reposURLs, confFile, false);
+ }
}
- public static boolean generate(String id, String name, String arch, String version,
+ private static boolean localGenerate(String id, String name, String arch, String version,
String path, List<String> reposURLs, IPath confFile, boolean isDefault) {
IPath pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath());
attrArch.setValue(arch);
Attr attrPath = doc.createAttribute(ATTR_PATH);
if (path == null) {
- attrPath.setValue(RootstrapUtil.getUserRootstrapXmlPath(name));
+ attrPath.setValue(RootstrapUtil.getUserRootstrapPathOfXml(name));
} else {
attrPath.setValue(RootstrapUtil.getRootstrapPathOfXml(path));
}
firstnode.setAttributeNode(attrType);
firstnode.setAttributeNode(attrVer);
- //String reposURLString = "";
+ // String reposURLString = "";
StringBuffer sbReposURL = new StringBuffer();
for (String URL : reposURLs) {
if (sbReposURL.length() != 0) {
return true;
}
- public static boolean remoteGenerate(String id, String name, String arch, String version,
+ private static boolean remoteGenerate(String id, String name, String arch, String version,
String path, List<String> reposURLs, IPath confFile, boolean isDefault) {
IPath pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath());
- IPath filePath = pluginPath.append(id + ".xml");
+ IPath filePath = pluginPath.append(id + ".xml");
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
attrArch.setValue(arch);
Attr attrPath = doc.createAttribute(ATTR_PATH);
if (path == null) {
- attrPath.setValue(RootstrapUtil.getRemoteUserRootstrapXmlPath(name));
+ attrPath.setValue(RootstrapUtil.getRemoteRootstrapPathOfXml(name));
} else {
attrPath.setValue(RootstrapUtil.getRootstrapPathOfXml(path));
}
node1.setAttributeNode(attrType);
node1.setAttributeNode(attrVer);
- //String reposURLString = "";
+ // String reposURLString = "";
StringBuffer sbReposURL = new StringBuffer();
for (String URL : reposURLs) {
if (sbReposURL.length() != 0) {
e.printStackTrace();
return false;
}
- IPath remotepluginPath = new Path(RootstrapUtil.getRemoteUserRootstrapPluginPath());
+ IPath remotepluginPath = new Path(RootstrapUtil.getRemoteRootstrapPluginPath());
IPath remotefilePath = remotepluginPath.append(id + ".xml");
-
+
try {
IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool();
copytool.uploadFileToFile(filePath.toOSString(), remotefilePath.toString());
} catch (CancelException e) {
e.printStackTrace();
}
-
+
return true;
}
-
- public static boolean remoteGenerate(String id, String name, String arch, String version,
- String path, List<Repository> reposURLs, IPath confFile) {
- List<String> repos = new ArrayList<String>();
- for (Repository repo : reposURLs) {
- repos.add(repo.getUri());
+
+ public static void remove(String id) {
+ if (OSChecker.isWindows()) {
+ remoteRemove(id);
+ } else {
+ localRemove(id);
}
- return remoteGenerate(id, name, arch, version, path, repos, confFile, false);
}
-
- public static void remove(String id) {
+
+ private static void localRemove(String id) {
// remove related targets
List<Target> targetList = SBIModel.getTargetList();
List<Target> removeList = new ArrayList<Target>();
new File(RootstrapUtil.getPluginXML(id)).delete();
}
- public static void remoteRemove(String id) {
+ private static void remoteRemove(String id) {
remove(id);
String path = RootstrapUtil.getRemotePluginXML(id);
try {
package org.tizen.nativeplatform.util;
-import java.io.File;
-import java.io.IOException;
-
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+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.common.core.application.InstallPathConfig;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
private static final String USER_ROOSTRAP_BASE_DIR_NAME = "user-rootstraps";
private static final String REMOTE_TIZEN_SDK_DIR_NAME = "tizen-sdk-remote-data";
+ private static final String REMOTE_SOURCE_DIR_NAME = "source";
private static final String REMOTE_ROOSTRAP_PLUGINS_DIR_NAME = "user-rootstrap-plugins";
public static String getBaseArchitecture(String arch) {
return "i386";
}
}
-
- public static String getRemoteUserRootstrapPluginPath() {
+
+ public static String getRemoteRootstrapBasePath() {
String userhome = RemoteConnectionManager.getRemoteTools().getUserhome();
- return new Path(userhome).append(REMOTE_TIZEN_SDK_DIR_NAME).append(REMOTE_ROOSTRAP_PLUGINS_DIR_NAME).toString();
+ return new Path(userhome).append(REMOTE_TIZEN_SDK_DIR_NAME).toString();
+ }
+
+ public static String getRemoteSourcePath() {
+ return new Path(getRemoteRootstrapBasePath()).append(REMOTE_SOURCE_DIR_NAME).toString();
+ }
+
+ public static String getRemoteRootstrapPluginPath() {
+ return new Path(getRemoteRootstrapBasePath()).append(REMOTE_ROOSTRAP_PLUGINS_DIR_NAME)
+ .toString();
}
-
+
public static String getUserRootstrapPath(String id) {
return new Path(getBaseUserRootstrapPath()).append(id).toOSString();
}
-
- public static String getRemoteUserRootstrapPath(String id) {
- String userhome = RemoteConnectionManager.getRemoteTools().getUserhome();
- return new Path(userhome).append(REMOTE_TIZEN_SDK_DIR_NAME).append(USER_ROOSTRAP_BASE_DIR_NAME).append(id).toString();
+
+ public static String getRemoteRootstrapPath(String id) {
+ return new Path(getRemoteRootstrapBasePath()).append(USER_ROOSTRAP_BASE_DIR_NAME)
+ .append(id).toString();
}
-
+
public static String getBaseUserRootstrapPath() {
return new Path(InstallPathConfig.getUserDataPath()).append(USER_ROOSTRAP_BASE_DIR_NAME)
.toOSString();
}
-
- public static String getRemoteUserRootstrapXmlPath(String id) {
- String rootstrapPath = getRemoteUserRootstrapPath(id);
+
+ public static String getRemoteRootstrapPathOfXml(String id) {
+ String rootstrapPath = getRemoteRootstrapPath(id);
return getRootstrapPathOfXml(rootstrapPath);
}
-
- public static String getUserRootstrapXmlPath(String id) {
+
+ public static String getRemoteRootstrapScratchPath(String id) {
+ IPath rootstrapPath = new Path(getRemoteRootstrapPath(id));
+ String rootstrapBasepath = rootstrapPath.append("local").append("BUILD-ROOTS").toString();
+ String result = "";
+
+ try {
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ boolean exists = filetool.hasDirectory(rootstrapBasepath.toString(),
+ new NullProgressMonitor());
+ if (exists) {
+ IRemoteItem[] items = filetool.listItems(rootstrapBasepath,
+ new NullProgressMonitor());
+ for (IRemoteItem item : items) {
+ if (item.isDirectory()) {
+ String scratchPath = item.getPath();
+ String dirname = new Path(scratchPath).lastSegment().toString();
+ if (dirname.startsWith("scratch.")) {
+ result = scratchPath;
+ }
+ }
+ }
+ }
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ public static String getUserRootstrapPathOfXml(String id) {
String rootstrapPath = getUserRootstrapPath(id);
return getRootstrapPathOfXml(rootstrapPath);
}
-
+
public static String getRootstrapPathOfXml(String path) {
if (InstallerUtil.isSupportedMultipleSDK()) {
return path.replaceAll(String.format("%s/", InstallPathConfig.getSDKPath()),
"#{HOME}/tizen-sdk-data/");
}
}
-
+
public static String getPluginXML(String id) {
IPath pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath());
return pluginPath.append(id + ".xml").toOSString();
}
public static String getRemotePluginXML(String id) {
- return new Path(getRemoteUserRootstrapPluginPath()).append(id + ".xml").toString();
+ return new Path(getRemoteRootstrapPluginPath()).append(id + ".xml").toString();
}
-
+
public static String getRogenPath() {
- return new Path(InstallPathConfig.getSDKPath()).append("tools").append("rogen").append("bin").append("rogen.rb").toString();
+ return new Path(InstallPathConfig.getSDKPath()).append("tools").append("rogen")
+ .append("bin").append("rogen.rb").toString();
}
-
+
public static String getRemoteRogenPath() {
String userhome = RemoteConnectionManager.getRemoteTools().getUserhome();
- return new Path(userhome).append(REMOTE_TIZEN_SDK_DIR_NAME).append("tools").append("rogen").append("bin").append("rogen.rb").toString();
+ return new Path(userhome).append(REMOTE_TIZEN_SDK_DIR_NAME).append("tools").append("rogen")
+ .append("bin").append("rogen.rb").toString();
}
}
tableViewer.setLabelProvider(new TableViewerProvider());
tableViewer.setContentProvider(new ArrayContentProvider());
- tableViewer.setInput(RootstrapManager.getUserRootstraps());
+ tableViewer.setInput(RootstrapManager.getRootstraps());
tableViewer.getTable().addSelectionListener(new SelectionListener() {