use of com.facebook.buck.android.NoAndroidSdkException in project buck by facebook.
the class Main method createAndroidPlatformTargetSupplier.
@VisibleForTesting
static Supplier<AndroidPlatformTarget> createAndroidPlatformTargetSupplier(final AndroidDirectoryResolver androidDirectoryResolver, final AndroidBuckConfig androidBuckConfig, final BuckEventBus eventBus) {
// of its getCacheName() method in its RuleKey.
return new Supplier<AndroidPlatformTarget>() {
@Nullable
private AndroidPlatformTarget androidPlatformTarget;
@Nullable
private NoAndroidSdkException exception;
@Override
public AndroidPlatformTarget get() {
if (androidPlatformTarget != null) {
return androidPlatformTarget;
} else if (exception != null) {
throw exception;
}
Optional<Path> androidSdkDirOption = androidDirectoryResolver.getSdkOrAbsent();
if (!androidSdkDirOption.isPresent()) {
exception = new NoAndroidSdkException();
throw exception;
}
String androidPlatformTargetId;
Optional<String> target = androidBuckConfig.getAndroidTarget();
if (target.isPresent()) {
androidPlatformTargetId = target.get();
} else {
androidPlatformTargetId = AndroidPlatformTarget.DEFAULT_ANDROID_PLATFORM_TARGET;
eventBus.post(ConsoleEvent.warning("No Android platform target specified. Using default: %s", androidPlatformTargetId));
}
Optional<AndroidPlatformTarget> androidPlatformTargetOptional = AndroidPlatformTarget.getTargetForId(androidPlatformTargetId, androidDirectoryResolver, androidBuckConfig.getAaptOverride());
if (androidPlatformTargetOptional.isPresent()) {
androidPlatformTarget = androidPlatformTargetOptional.get();
return androidPlatformTarget;
} else {
exception = NoAndroidSdkException.createExceptionForPlatformThatCannotBeFound(androidPlatformTargetId);
throw exception;
}
}
};
}
use of com.facebook.buck.android.NoAndroidSdkException in project buck by facebook.
the class Genrule method addEnvironmentVariables.
protected void addEnvironmentVariables(SourcePathResolver pathResolver, ExecutionContext context, ImmutableMap.Builder<String, String> environmentVariablesBuilder) {
environmentVariablesBuilder.put("SRCS", Joiner.on(' ').join(FluentIterable.from(srcs).transform(pathResolver::getAbsolutePath).transform(Object::toString)));
environmentVariablesBuilder.put("OUT", getAbsoluteOutputFilePath(pathResolver));
environmentVariablesBuilder.put("GEN_DIR", getProjectFilesystem().resolve(getProjectFilesystem().getBuckPaths().getGenDir()).toString());
environmentVariablesBuilder.put("SRCDIR", absolutePathToSrcDirectory.toString());
environmentVariablesBuilder.put("TMP", absolutePathToTmpDirectory.toString());
// TODO(bolinfest): This entire hack needs to be removed. The [tools] section of .buckconfig
// should be generalized to specify local paths to tools that can be used in genrules.
AndroidPlatformTarget android;
try {
android = context.getAndroidPlatformTarget();
} catch (NoAndroidSdkException e) {
android = null;
}
if (android != null) {
Optional<Path> sdkDirectory = android.getSdkDirectory();
if (sdkDirectory.isPresent()) {
environmentVariablesBuilder.put("ANDROID_HOME", sdkDirectory.get().toString());
}
Optional<Path> ndkDirectory = android.getNdkDirectory();
if (ndkDirectory.isPresent()) {
environmentVariablesBuilder.put("NDK_HOME", ndkDirectory.get().toString());
}
environmentVariablesBuilder.put("DX", android.getDxExecutable().toString());
environmentVariablesBuilder.put("ZIPALIGN", android.getZipalignExecutable().toString());
}
// TODO(t5302074): This shouldn't be necessary. Speculatively disabling.
environmentVariablesBuilder.put("NO_BUCKD", "1");
}
Aggregations