parameters: (args, spec, header_file_name)
docstring: Update the list of imports with a list of include files for each import with structs.
docstring_summary: Update the list of imports with a list of include files for each import with structs.
docstring_tokens: Update the list of imports with a list of include files for each import with structs .
function: def _update_import_includes(args, spec, header_file_name):
      # type: (CompilerArgs, syntax.IDLSpec, str) -> None
      """Update the list of imports with a list of include files for each import with structs."""
      # This function is fragile:
      # In order to try to generate headers with an "include what you use" set of headers, the IDL
      # compiler needs to generate include statements to headers for imported files with structs. The
      # problem is that the IDL compiler needs to make the following assumptions:
      # 1. The layout of build vs source directory.
      # 2. The file naming suffix rules for all IDL invocations are consistent.
      if not spec.imports:
          return
  
      if args.output_base_dir:
          base_include_h_file_name = os.path.relpath(
              os.path.normpath(header_file_name), os.path.normpath(args.output_base_dir))
      else:
          base_include_h_file_name = os.path.abspath(header_file_name)
  
      # Normalize to POSIX style for consistency across Windows and POSIX.
      base_include_h_file_name = base_include_h_file_name.replace("\\", "/")
  
      # Modify the includes list of the root_doc to include all of its direct imports
      if not spec.globals:
          spec.globals = syntax.Global(args.input_file, -1, -1)
  
      first_dir = base_include_h_file_name.split('/')[0]
  
      for resolved_file_name in spec.imports.resolved_imports:
          # Guess: the file naming rules are consistent across IDL invocations
          include_h_file_name = os.path.splitext(resolved_file_name)[0] + args.output_suffix + ".h"
  
          if args.output_base_dir:
              base_dir = os.path.normpath(args.output_base_dir)
              include_h_file_name = os.path.relpath(os.path.normpath(include_h_file_name), base_dir)
  
              if os.path.isabs(base_dir):
                  include_h_file_name = os.path.join(
                      base_dir, include_h_file_name[include_h_file_name.rfind(first_dir):])
              else:
                  include_h_file_name = include_h_file_name[include_h_file_name.find(first_dir):]
          else:
              include_h_file_name = os.path.abspath(include_h_file_name)
  
          # Normalize to POSIX style for consistency across Windows and POSIX.
          include_h_file_name = include_h_file_name.replace("\\", "/")
  
          spec.globals.cpp_includes.append(include_h_file_name)
function_tokens: def _update_import_includes ( args , spec , header_file_name ) : # type: (CompilerArgs, syntax.IDLSpec, str) -> None # This function is fragile: # In order to try to generate headers with an "include what you use" set of headers, the IDL # compiler needs to generate include statements to headers for imported files with structs. The # problem is that the IDL compiler needs to make the following assumptions: # 1. The layout of build vs source directory. # 2. The file naming suffix rules for all IDL invocations are consistent. if not spec . imports : return if args . output_base_dir : base_include_h_file_name = os . path . relpath ( os . path . normpath ( header_file_name ) , os . path . normpath ( args . output_base_dir ) ) else : base_include_h_file_name = os . path . abspath ( header_file_name ) # Normalize to POSIX style for consistency across Windows and POSIX. base_include_h_file_name = base_include_h_file_name . replace ( "\\" , "/" ) # Modify the includes list of the root_doc to include all of its direct imports if not spec . globals : spec . globals = syntax . Global ( args . input_file , - 1 , - 1 ) first_dir = base_include_h_file_name . split ( '/' ) [ 0 ] for resolved_file_name in spec . imports . resolved_imports : # Guess: the file naming rules are consistent across IDL invocations include_h_file_name = os . path . splitext ( resolved_file_name ) [ 0 ] + args . output_suffix + ".h" if args . output_base_dir : base_dir = os . path . normpath ( args . output_base_dir ) include_h_file_name = os . path . relpath ( os . path . normpath ( include_h_file_name ) , base_dir ) if os . path . isabs ( base_dir ) : include_h_file_name = os . path . join ( base_dir , include_h_file_name [ include_h_file_name . rfind ( first_dir ) : ] ) else : include_h_file_name = include_h_file_name [ include_h_file_name . find ( first_dir ) : ] else : include_h_file_name = os . path . abspath ( include_h_file_name ) # Normalize to POSIX style for consistency across Windows and POSIX. include_h_file_name = include_h_file_name . replace ( "\\" , "/" ) spec . globals . cpp_includes . append ( include_h_file_name )