build static method

List<PipeStage> build(
  1. BPConfig config
)

The stages of build_pipe:build

Implementation

static List<PipeStage> build(BPConfig config) {
  _HookEnvironment environment = _HookEnvironment(config, "build");

  List<PipeStep> platformSteps = [];
  for (TargetPlatform platform in config.buildPlatforms) {
    PlatformConfig platformConfig = config.platformConfig(platform)!;
    // Safety check in case an empty build command is passed
    // and the lack of build command is not caught by the config parser
    if (platformConfig.buildCommand.isEmpty) continue;

    PipeStep step = _platformStep(
      label: platformNames[platform]!,
      mainLabel: "Build",
      main: (String label) => PipeBuilder.buildCommandStep(config, platformConfig, label),
      extraSteps: PipeBuilder.extraBuildSteps(config, platform),
      hooks: platformConfig.buildHooks,
      platform: platform,
      environment: environment,
    );
    environment.platformSteps[step] = platform;
    platformSteps.add(step);
  }

  return [
    PipeStage(
      "Pre-build",
      steps: [
        if (config.needXCodeDerivedCleaning) XCodeUtils.deleteDerivedDataStep(config),
        if (config.cleanFlutter) CommandStep("flutter clean", executable: "flutter", arguments: ["clean"]),
        if (config.cleanFlutter) CommandStep("flutter pub get", executable: "flutter", arguments: ["pub", "get"]),
        if (config.buildHooks.pre != null) _hookStep("Pre-platform run", config.buildHooks.pre!, environment.forPrePlatformRun),
      ],
    ),
    PipeStage("Build", steps: platformSteps, onFailure: FailurePolicy.continueRun),
    PipeStage("Post-build", steps: _postPlatformRunSteps(config.buildHooks, environment)),
  ];
}