code: def write_target_ninja(ninja, target, src_dir):
      compile_depends = None
      if target.has_compile_depends:
          compile_depends = os.path.join(
              "obj", target.dir_path, target.name + ".stamp"
          )
          ninja.build(
              compile_depends, "stamp", target.src_obj_pairs[0][0]
          )
          ninja.newline()
  
      ninja.variable("defines", target.defines)
      ninja.variable("includes", "-I" + src_dir)
      ninja.variable(
          "cflags", ["-Wall", "-fno-rtti", "-fno-exceptions"]
      )
      ninja.newline()
  
      for src, obj in target.src_obj_pairs:
          ninja.build(obj, "cxx", src, implicit=compile_depends)
      ninja.newline()
  
      deps = [dep.output for dep in target.deps]
      libs = [dep.output for dep in target.deps if dep.kind == LIB]
      if target.kind == EXE:
          ninja.variable("libs", libs)
          if sys.platform == "darwin":
              ninja.variable("ldflags", "-Wl,-pie")
      link = {LIB: "alink", EXE: "link"}[target.kind]
      ninja.build(
          target.output,
          link,
          [obj for _, obj in target.src_obj_pairs],
          implicit=deps,
      )
  
imports: import argparse
  import contextlib
  import os
  import random
  import sys
  import ninja_syntax
label_desc: Use image node_id 3 for calling a global function with example usage: write_target_ninja(ninja, target, src_dir) without return types