comparison agent/src/jetbrains/buildServer/symbols/tools/SrcToolExe.java @ 27:76ed2d58c871

- reused home path between all srcsrv-related utilities - extracted JetSymbols utility class
author Evgeniy.Koshkin
date Wed, 07 Aug 2013 18:37:23 +0400
parents agent/src/jetbrains/buildServer/symbols/SrcToolExe.java@662a0be55de7
children 4c516ddbddf1
comparison
equal deleted inserted replaced
26:87b24e4efcc3 27:76ed2d58c871
1 /*
2 * Copyright 2000-2013 JetBrains s.r.o.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package jetbrains.buildServer.symbols.tools;
18
19 import com.intellij.execution.configurations.GeneralCommandLine;
20 import jetbrains.buildServer.ExecResult;
21 import jetbrains.buildServer.SimpleCommandLineProcessRunner;
22 import jetbrains.buildServer.util.CollectionsUtil;
23 import jetbrains.buildServer.util.Converter;
24 import org.jetbrains.annotations.NotNull;
25
26 import java.io.File;
27 import java.util.Arrays;
28 import java.util.Collection;
29
30 /**
31 * @author Evgeniy.Koshkin
32 */
33 public class SrcToolExe {
34 private static final String DUMP_SOURCES_FROM_PDB_SWITCH = "-r";
35 private static final String SRCTOOL_EXE = "srctool.exe";
36
37 private final File mySrcToolPath;
38
39 public SrcToolExe(File homeDir) {
40 mySrcToolPath = new File(homeDir, SRCTOOL_EXE);
41 }
42
43 public Collection<File> getReferencedSourceFiles(File symbolsFile) {
44 final GeneralCommandLine commandLine = new GeneralCommandLine();
45 commandLine.setExePath(mySrcToolPath.getPath());
46 commandLine.addParameter(symbolsFile.getAbsolutePath());
47 commandLine.addParameter(DUMP_SOURCES_FROM_PDB_SWITCH);
48 final ExecResult execResult = SimpleCommandLineProcessRunner.runCommand(commandLine, null);
49 return CollectionsUtil.convertAndFilterNulls(Arrays.asList(execResult.getOutLines()), new Converter<File, String>() {
50 public File createFrom(@NotNull String source) {
51 final File file = new File(source);
52 if (file.isFile()) return file;
53 return null; //last string is not a source file path
54 }
55 });
56 }
57 }