code: def write_sources(target, root_dir):
      need_main = target.kind == EXE
  
      includes = []
  
      # Include siblings.
      for cc_filename, _ in target.src_obj_pairs:
          h_filename = os.path.basename(
              os.path.splitext(cc_filename)[0] + ".h"
          )
          includes.append(h_filename)
  
      # Include deps.
      for dep in target.deps:
          for cc_filename, _ in dep.src_obj_pairs:
              h_filename = os.path.basename(
                  os.path.splitext(cc_filename)[0] + ".h"
              )
              includes.append("%s/%s" % (dep.dir_path, h_filename))
  
      for cc_filename, _ in target.src_obj_pairs:
          cc_path = os.path.join(root_dir, cc_filename)
          h_path = os.path.splitext(cc_path)[0] + ".h"
          namespace = os.path.basename(target.dir_path)
          class_ = os.path.splitext(os.path.basename(cc_filename))[0]
          try:
              os.makedirs(os.path.dirname(cc_path))
          except OSError:
              pass
  
          with open(h_path, "w") as f:
              f.write(
                  "namespace %s { struct %s { %s(); }; }"
                  % (namespace, class_, class_)
              )
          with open(cc_path, "w") as f:
              for include in includes:
                  f.write('#include "%s"\n' % include)
              f.write("\n")
              f.write(
                  "namespace %s { %s::%s() {} }"
                  % (namespace, class_, class_)
              )
  
              if need_main:
                  f.write("int main(int argc, char **argv) {}\n")
                  need_main = False
  
imports: import argparse
  import contextlib
  import os
  import random
  import sys
  import ninja_syntax
label_desc: Use image node_id 4 for calling a global function with example usage: write_sources(target, root_dir) without return types