Skip to content

Commit

Permalink
Look for the Perfetto config in GAPID package.
Browse files Browse the repository at this point in the history
If the flag is not given, or points somewhere invalid, try to read the
Perfetto config from a "perfetto.cfg" file inside the GAPID package.
  • Loading branch information
pmuetschard committed Jul 26, 2019
1 parent 93a8e58 commit dd30a91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion gapic/src/main/com/google/gapid/perfetto/PerfettoConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static java.util.logging.Level.WARNING;

import com.google.common.collect.ImmutableList;
import com.google.gapid.server.GapiPaths;
import com.google.gapid.util.Flags;
import com.google.gapid.util.Flags.Flag;
import com.google.protobuf.TextFormat;
Expand Down Expand Up @@ -66,7 +67,8 @@ private static PerfettoConfig findConfig() {
() -> {
String path = perfettoConfig.get();
return "".equals(path) ? null : new File(path);
}
},
GapiPaths.get()::perfettoConfig
).stream()
.map(dir -> checkForConfig(dir.get()))
.filter(PerfettoConfig::shouldUse)
Expand Down
16 changes: 12 additions & 4 deletions gapic/src/main/com/google/gapid/server/GapiPaths.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ public final class GapiPaths {
Flags.value("gapid", "", "Path to the gapid binaries.");
public static final Flag<String> adbPath = Flags.value("adb", "", "Path to the adb binary.");

public static final GapiPaths MISSING = new GapiPaths(null, null, null, null, null);
public static final GapiPaths MISSING = new GapiPaths(null, null, null, null, null, null);

private static final Logger LOG = Logger.getLogger(GapiPaths.class.getName());

private static final String GAPIS_EXECUTABLE_NAME = "gapis" + OS.exeExtension;
private static final String GAPIT_EXECUTABLE_NAME = "gapit" + OS.exeExtension;
private static final String STRINGS_DIR_NAME = "strings";
private static final String PERFETTO_CONFIG_NAME = "perfetto.cfg";
private static final String USER_HOME_GAPID_ROOT = "gapid";
private static final String GAPID_PKG_SUBDIR = "pkg";
private static final String GAPID_ROOT_ENV_VAR = "GAPID";
Expand All @@ -59,22 +60,25 @@ public final class GapiPaths {
private final File gapisPath;
private final File gapitPath;
private final File stringsPath;
private final File perfettoConfigPath;
private final File runfiles;

public GapiPaths(File baseDir) {
this.baseDir = baseDir;
this.gapisPath = new File(baseDir, GAPIS_EXECUTABLE_NAME);
this.gapitPath = new File(baseDir, GAPIT_EXECUTABLE_NAME);
this.stringsPath = new File(baseDir, STRINGS_DIR_NAME);
this.perfettoConfigPath = new File(baseDir, PERFETTO_CONFIG_NAME);
this.runfiles = null;
}

protected GapiPaths(
File baseDir, File gapisPath, File gapitPath, File stringsPath, File runfiles) {
protected GapiPaths(File baseDir, File gapisPath, File gapitPath, File stringsPath,
File perfettoConfigPath, File runfiles) {
this.baseDir = baseDir;
this.gapisPath = gapisPath;
this.gapitPath = gapitPath;
this.stringsPath = stringsPath;
this.perfettoConfigPath = perfettoConfigPath;
this.runfiles = runfiles;
}

Expand Down Expand Up @@ -107,6 +111,10 @@ public File strings() {
return stringsPath;
}

public File perfettoConfig() {
return perfettoConfigPath;
}

public void addRunfilesFlag(List<String> args) {
if (runfiles != null && runfiles.exists()) {
args.add("--runfiles");
Expand Down Expand Up @@ -166,7 +174,7 @@ public boolean processLine(String line) throws IOException {
public GapiPaths getResult() {
// Fall back to ignoring the runfiles if no gapis was found.
return (gapis == null) ? new GapiPaths(dir) :
new GapiPaths(dir, gapis, gapit, strings, runfiles);
new GapiPaths(dir, gapis, gapit, strings, null, runfiles);
}
});
} catch (IOException e) {
Expand Down

0 comments on commit dd30a91

Please sign in to comment.