code: def build_dep(name: str) -> str:
      dep = DEPS[name]
      dir = dep["dir"]
      file = f"build_dep_{name}.cmd"
  
      extract_dep(dep["url"], dep["filename"])
  
      licenses = dep["license"]
      if isinstance(licenses, str):
          licenses = [licenses]
      license_text = ""
      for license_file in licenses:
          with open(os.path.join(sources_dir, dir, license_file)) as f:
              license_text += f.read()
      if "license_pattern" in dep:
          match = re.search(
              dep["license_pattern"], license_text, re.DOTALL
          )
          license_text = "\n".join(match.groups())
      assert len(license_text) > 50
      with open(os.path.join(license_dir, f"{dir}.txt"), "w") as f:
          print(f"Writing license {dir}.txt")
          f.write(license_text)
  
      for patch_file, patch_list in dep.get("patch", {}).items():
          patch_file = os.path.join(
              sources_dir, dir, patch_file.format(**prefs)
          )
          with open(patch_file) as f:
              text = f.read()
          for patch_from, patch_to in patch_list.items():
              patch_from = patch_from.format(**prefs)
              patch_to = patch_to.format(**prefs)
              assert patch_from in text
              text = text.replace(patch_from, patch_to)
          with open(patch_file, "w") as f:
              print(f"Patching {patch_file}")
              f.write(text)
  
      banner = f"Building {name} ({dir})"
      lines = [
          r'call "{build_dir}\build_env.cmd"',
          "@echo " + ("=" * 70),
          f"@echo ==== {banner:<60} ====",
          "@echo " + ("=" * 70),
          cmd_cd(os.path.join(sources_dir, dir)),
          *dep.get("build", []),
          *get_footer(dep),
      ]
  
      write_script(file, lines)
      return file
  
imports: from __future__ import annotations
  import argparse
  import os
  import platform
  import re
  import shutil
  import struct
  import subprocess
label_desc: Use image node_id 17 for calling a global function with example usage: build_dep(name) and returns: file