Search in sources :

Example 1 with AppleBundle

use of com.facebook.buck.apple.AppleBundle in project buck by facebook.

the class InstallCommand method install.

private int install(CommandRunnerParams params) throws IOException, InterruptedException, NoSuchBuildTargetException {
    Build build = super.getBuild();
    int exitCode = 0;
    for (BuildTarget buildTarget : getBuildTargets()) {
        BuildRule buildRule = build.getRuleResolver().requireRule(buildTarget);
        SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(build.getRuleResolver()));
        if (buildRule instanceof HasInstallableApk) {
            ExecutionContext executionContext = ExecutionContext.builder().from(build.getExecutionContext()).setAdbOptions(Optional.of(adbOptions(params.getBuckConfig()))).setTargetDeviceOptions(Optional.of(targetDeviceOptions())).setExecutors(params.getExecutors()).setCellPathResolver(params.getCell().getCellPathResolver()).build();
            exitCode = installApk(params, (HasInstallableApk) buildRule, executionContext, pathResolver);
            if (exitCode != 0) {
                return exitCode;
            }
        } else if (buildRule instanceof AppleBundle) {
            AppleBundle appleBundle = (AppleBundle) buildRule;
            InstallEvent.Started started = InstallEvent.started(appleBundle.getBuildTarget());
            params.getBuckEventBus().post(started);
            InstallResult installResult = installAppleBundle(params, appleBundle, appleBundle.getProjectFilesystem(), build.getExecutionContext().getProcessExecutor(), pathResolver);
            params.getBuckEventBus().post(InstallEvent.finished(started, installResult.getExitCode() == 0, installResult.getLaunchedPid(), Optional.empty()));
            exitCode = installResult.getExitCode();
            if (exitCode != 0) {
                return exitCode;
            }
        } else {
            params.getBuckEventBus().post(ConsoleEvent.severe(String.format("Specified rule %s must be of type android_binary() or apk_genrule() or " + "apple_bundle() but was %s().\n", buildRule.getFullyQualifiedName(), buildRule.getType())));
            return 1;
        }
    }
    return exitCode;
}
Also used : ExecutionContext(com.facebook.buck.step.ExecutionContext) Build(com.facebook.buck.command.Build) BuildTarget(com.facebook.buck.model.BuildTarget) AppleBundle(com.facebook.buck.apple.AppleBundle) BuildRule(com.facebook.buck.rules.BuildRule) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) HasInstallableApk(com.facebook.buck.android.HasInstallableApk)

Aggregations

HasInstallableApk (com.facebook.buck.android.HasInstallableApk)1 AppleBundle (com.facebook.buck.apple.AppleBundle)1 Build (com.facebook.buck.command.Build)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 BuildRule (com.facebook.buck.rules.BuildRule)1 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)1 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)1 ExecutionContext (com.facebook.buck.step.ExecutionContext)1