# HG changeset patch # User Vladimir Kvashin # Date 1452680249 -10800 # Branch release81 # Node ID 49f6835f7b7c7e4f608040ea8616f4379e8f65ca # Parent 864ee319bb5d70f630c00006a41eb75754167e66 fixing #257285 - Need an easy way to retrieve *multiple* build results from remote host diff -r 864ee319bb5d -r 49f6835f7b7c cnd.remote/src/org/netbeans/modules/cnd/remote/support/RemoteProjectSupport.java --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/support/RemoteProjectSupport.java Wed Dec 30 10:37:01 2015 +0300 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/support/RemoteProjectSupport.java Wed Jan 13 13:17:29 2016 +0300 @@ -44,6 +44,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -60,11 +61,14 @@ import org.netbeans.modules.cnd.remote.sync.SharabilityFilter; import org.netbeans.modules.cnd.utils.CndPathUtilities; import org.netbeans.modules.cnd.utils.FSPath; +import org.netbeans.modules.dlight.libs.common.PathUtilities; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; import org.netbeans.modules.remote.spi.FileSystemProvider; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; import org.openide.util.Lookup; /** @@ -128,13 +132,49 @@ return Collections.emptyList(); } + private static void readBuildResults(FileObject baseFO, String path, Collection results) { + if (baseFO != null && baseFO.isValid()) { + FileSystem fs; + try { + fs = baseFO.getFileSystem(); + } catch (FileStateInvalidException ex) { + Exceptions.printStackTrace(ex); + return; + } + FileObject buildResultsFO = baseFO.getFileObject(path); + if (buildResultsFO != null && buildResultsFO.isValid()) { + try { + List lines = buildResultsFO.asLines(); + for (String l : lines) { + l = l.trim(); + if (!FileSystemProvider.isAbsolute(fs, l)) { + l = baseFO.getPath() + '/' + l; + } + if (!l.startsWith("#")) { //NOI18N + results.add(l); + } + } + } catch (IOException ex) { + RemoteLogger.getInstance().log(Level.FINE, "Error reading build results from " + buildResultsFO.getPath() , ex); //NOI18N + } + } + } + } + public static List getBuildResults(MakeConfiguration conf) { + List result = new ArrayList<>(); String binaryPath = (conf == null) ? null : conf.getAbsoluteOutputValue(); if (binaryPath != null) { - return Collections.singletonList(new FSPath(conf.getFileSystem(), binaryPath)); - } else { - return Collections.emptyList(); + result.add(new FSPath(conf.getFileSystem(), binaryPath)); } + FileObject baseFO = conf.getBaseFSPath().getFileObject(); + Set lines = new HashSet<>(); + readBuildResults(baseFO, "nbproject/build-results", lines); // NOI18N + readBuildResults(baseFO, "nbproject/private/build-results", lines); // NOI18N + for (String line : lines) { + result.add(new FSPath(conf.getFileSystem(), line)); + } + return result; } public static List getProjectSourceDirs(Lookup.Provider project, AtomicReference runDir) {