code: def build(ctx, src, build_dir, force, targets, **kwargs):
      """Initialize a C++ build directory.
  
      The build command creates a directory initialized with Arrow's cpp source
      cmake and configuration. It can also optionally invoke the generator to
      test the build (and used in scripts).
  
      Note that archery will carry the caller environment. It will also not touch
      an existing directory, one must use the `--force` option to remove the
      existing directory.
  
      Examples:
  
      \b
      # Initialize build with clang8 and avx2 support in directory `clang8-build`
      \b
      archery build --cc=clang-8 --cxx=clang++-8 --cxx-flags=-mavx2 clang8-build
  
      \b
      # Builds and run test
      archery build --targets=all --targets=test build
      """
      # Arrow's cpp cmake configuration
      conf = CppConfiguration(**kwargs)
      # This is a closure around cmake invocation, e.g. calling `def.build()`
      # yields a directory ready to be run with the generator
      cmake_def = CppCMakeDefinition(src.cpp, conf)
      # Create build directory
      build = cmake_def.build(build_dir, force=force)
  
      for target in targets:
          build.run(target)
  
imports: from collections import namedtuple
  from io import StringIO
  import click
  import json
  import logging
  import os
  import pathlib
  import sys
  from .benchmark.codec import JsonEncoder
  from .benchmark.compare import RunnerComparator, DEFAULT_THRESHOLD
  from .benchmark.runner import CppBenchmarkRunner, JavaBenchmarkRunner
  from .compat import _import_pandas
  from .lang.cpp import CppCMakeDefinition, CppConfiguration
  from .utils.cli import ArrowBool, validate_arrow_sources, add_optional_command
  from .utils.lint import linter, python_numpydoc, LintValidationException
  from .utils.logger import logger, ctx
  from .utils.source import ArrowSources
  from .utils.tmpdir import tmpdir
label_desc: Use image node_id 5 for calling a global function with example usage: build(ctx, src, build_dir, force, targets) without return types