# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/compiled_action.gni")
import("//flutter/common/config.gni")
import("//flutter/impeller/tools/malioc.gni")
import("//flutter/testing/testing.gni")

declare_args() {
  # Maximum number of malioc processes to run in parallel.
  #
  # To avoid out-of-memory errors we explicitly reduce the number of jobs.
  impeller_concurrent_malioc_jobs = -1
}

if (impeller_concurrent_malioc_jobs == -1) {
  _script = "//flutter/build/get_concurrent_jobs.py"
  _args = [
    "--reserve-memory=1GB",
    "--memory-per-job",
    "malioc=100MB",
  ]
  _concurrent_jobs = exec_script(_script, _args, "json", [ _script ])
  impeller_concurrent_malioc_jobs = _concurrent_jobs.malioc
  assert(impeller_concurrent_malioc_jobs > 0)
}

pool("malioc_pool") {
  depth = impeller_concurrent_malioc_jobs
}
