blob: b82623198d34b26160561d241fee7ecd9a87afd0 [file] [log] [blame]
// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.shaking;
import com.android.tools.r8.origin.Origin;
import com.google.common.annotations.VisibleForTesting;
import java.nio.file.Path;
import java.nio.file.Paths;
public class ProguardConfigurationSourceStrings implements ProguardConfigurationSource {
private final Path basePath;
private final String config;
private final Origin origin;
/**
* Creates {@link ProguardConfigurationSource} with raw {@param config}, along with {@param
* basePath}, which allows all other options that use a relative path to reach out to desired
* paths appropriately.
*/
public ProguardConfigurationSourceStrings(String config, Path basePath, Origin origin) {
this.basePath = basePath;
this.config = config;
this.origin = origin;
}
@VisibleForTesting
public static ProguardConfigurationSourceStrings createConfigurationForTesting(String config) {
return new ProguardConfigurationSourceStrings(config, Paths.get(""), Origin.unknown());
}
@Override
public String get() {
return String.join(System.lineSeparator(), config);
}
@Override
public Path getBaseDirectory() {
return basePath;
}
@Override
public String getName() {
return "<no file>";
}
@Override
public Origin getOrigin() {
return origin;
}
}