code: def build_archive(
      srcs=[],
      out_name="",
      build_dir="temp_build/temp_build",
      debug=False,
      num_parallel=1,
  ):
      compiler = os.environ.get("CXX", "g++")
      if sys.platform.startswith("win"):
          compiler = '"{}"'.format(compiler)
      ar = os.environ.get("AR", "ar")
      libexe = os.environ.get("LIBEXE", "lib.exe")
      libtool = os.environ.get("LIBTOOL", "libtool")
      cflags = os.environ.get("CFLAGS", "") + os.environ.get(
          "CXXFLAGS", ""
      )
      args = ARGS + (DBG_ARGS if debug else OPT_ARGS)
  
      for file in srcs:
          outfile = os.path.join(
              build_dir, os.path.splitext(file)[0] + ".o"
          )
          outdir = os.path.dirname(outfile)
          if not os.path.exists(outdir):
              print("mkdir", outdir)
              os.makedirs(outdir)
  
      def build_one(file):
          outfile = os.path.join(
              build_dir, os.path.splitext(file)[0] + ".o"
          )
          if os.path.exists(outfile):
              return
  
          if sys.platform.startswith("win"):
              file = '"{}"'.format(file.replace("\\", "/"))
              output = '/Fo"{}"'.format(outfile.replace("\\", "/"))
          else:
              output = "-o " + outfile
  
          cmd = "{cc} -c {cflags} {args} {includes} {infile} {output}".format(
              cc=compiler,
              cflags=cflags,
              args=" ".join(args),
              includes=" ".join("-I" + i for i in INCLUDES),
              infile=file,
              output=output,
          )
          print(cmd)
          subprocess.check_call(shlex.split(cmd))
          return outfile
  
      pool = Pool(num_parallel)
      obj_files = list(pool.imap_unordered(build_one, srcs))
  
      if sys.platform.startswith("darwin"):
          cmd = "{libtool} -static -o {outfile} {infiles}".format(
              libtool=libtool,
              outfile=out_name,
              infiles=" ".join(obj_files),
          )
          print(cmd)
          subprocess.check_call(shlex.split(cmd))
      elif sys.platform.startswith("win"):
          cmd = '"{libexe}" /OUT:"{outfile}" {infiles} /MACHINE:X64 /NOLOGO'.format(
              libexe=libexe,
              outfile=out_name,
              infiles=" ".join(obj_files),
          )
          cmd = cmd.replace("\\", "/")
          print(cmd)
          subprocess.check_call(shlex.split(cmd))
      else:
          cmd = "{ar} rcs {outfile} {infiles}".format(
              ar=ar, outfile=out_name, infiles=" ".join(obj_files)
          )
          print(cmd)
          subprocess.check_call(shlex.split(cmd))
  
file_path: DeepSpeech/native_client/ctcdecode/build_archive.py
imports: from __future__ import absolute_import, division, print_function
  import glob
  import os
  import shlex
  import subprocess
  import sys
  from multiprocessing.dummy import Pool
label_desc: Use image node_id 1 for calling a global function with example usage: build_archive(srcs, out_name, build_dir, debug, num_parallel) and returns: outfile