parameters: (self, spec, config_name, generator_flags,
        case_sensitive_filesystem)
return_statement: return self.target
docstring: The main entry point for NinjaWriter: write the build rules for a spec.
  
      Returns a Target object, which represents the output paths for this spec.
      Returns None if there are no outputs (e.g. a settings-only 'none' type
      target).
docstring_summary: The main entry point for NinjaWriter: write the build rules for a spec.
docstring_tokens: The main entry point for NinjaWriter : write the build rules for a spec .
function: def WriteSpec(self, spec, config_name, generator_flags,
        case_sensitive_filesystem):
      """The main entry point for NinjaWriter: write the build rules for a spec.
  
      Returns a Target object, which represents the output paths for this spec.
      Returns None if there are no outputs (e.g. a settings-only 'none' type
      target)."""
  
      self.config_name = config_name
      self.name = spec['target_name']
      self.toolset = spec['toolset']
      config = spec['configurations'][config_name]
      self.target = Target(spec['type'])
  
      self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec)
      self.xcode_settings = self.msvs_settings = None
      if self.flavor == 'mac':
        self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec)
      if self.flavor == 'win':
        self.msvs_settings = gyp.msvs_emulation.MsvsSettings(spec,
                                                             generator_flags)
        target_platform = self.msvs_settings.GetTargetPlatform(config_name)
        self.ninja.variable('arch', self.win_env[target_platform])
  
      # Compute predepends for all rules.
      # actions_depends is the dependencies this target depends on before running
      # any of its action/rule/copy steps.
      # compile_depends is the dependencies this target depends on before running
      # any of its compile steps.
      actions_depends = []
      compile_depends = []
      # TODO(evan): it is rather confusing which things are lists and which
      # are strings.  Fix these.
      if 'dependencies' in spec:
        for dep in spec['dependencies']:
          if dep in self.target_outputs:
            target = self.target_outputs[dep]
            actions_depends.append(target.PreActionInput(self.flavor))
            compile_depends.append(target.PreCompileInput())
        actions_depends = filter(None, actions_depends)
        compile_depends = filter(None, compile_depends)
        actions_depends = self.WriteCollapsedDependencies('actions_depends',
                                                          actions_depends)
        compile_depends = self.WriteCollapsedDependencies('compile_depends',
                                                          compile_depends)
        self.target.preaction_stamp = actions_depends
        self.target.precompile_stamp = compile_depends
  
      # Write out actions, rules, and copies.  These must happen before we
      # compile any sources, so compute a list of predependencies for sources
      # while we do it.
      extra_sources = []
      mac_bundle_depends = []
      self.target.actions_stamp = self.WriteActionsRulesCopies(
          spec, extra_sources, actions_depends, mac_bundle_depends)
  
      # If we have actions/rules/copies, we depend directly on those, but
      # otherwise we depend on dependent target's actions/rules/copies etc.
      # We never need to explicitly depend on previous target's link steps,
      # because no compile ever depends on them.
      compile_depends_stamp = (self.target.actions_stamp or compile_depends)
  
      # Write out the compilation steps, if any.
      link_deps = []
      sources = spec.get('sources', []) + extra_sources
      if sources:
        pch = None
        if self.flavor == 'win':
          pch = gyp.msvs_emulation.PrecompiledHeader(
              self.msvs_settings, config_name, self.GypPathToNinja)
        else:
          pch = gyp.xcode_emulation.MacPrefixHeader(
              self.xcode_settings, self.GypPathToNinja,
              lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang))
        link_deps = self.WriteSources(
            config_name, config, sources, compile_depends_stamp, pch,
            case_sensitive_filesystem)
        # Some actions/rules output 'sources' that are already object files.
        link_deps += [self.GypPathToNinja(f)
            for f in sources if f.endswith(self.obj_ext)]
  
      if self.flavor == 'win' and self.target.type == 'static_library':
        self.target.component_objs = link_deps
  
      # Write out a link step, if needed.
      output = None
      if link_deps or self.target.actions_stamp or actions_depends:
        output = self.WriteTarget(spec, config_name, config, link_deps,
                                  self.target.actions_stamp or actions_depends)
        if self.is_mac_bundle:
          mac_bundle_depends.append(output)
  
      # Bundle all of the above together, if needed.
      if self.is_mac_bundle:
        output = self.WriteMacBundle(spec, mac_bundle_depends)
  
      if not output:
        return None
  
      assert self.target.FinalOutput(), output
      return self.target
function_tokens: def WriteSpec ( self , spec , config_name , generator_flags , case_sensitive_filesystem ) : self . config_name = config_name self . name = spec [ 'target_name' ] self . toolset = spec [ 'toolset' ] config = spec [ 'configurations' ] [ config_name ] self . target = Target ( spec [ 'type' ] ) self . is_mac_bundle = gyp . xcode_emulation . IsMacBundle ( self . flavor , spec ) self . xcode_settings = self . msvs_settings = None if self . flavor == 'mac' : self . xcode_settings = gyp . xcode_emulation . XcodeSettings ( spec ) if self . flavor == 'win' : self . msvs_settings = gyp . msvs_emulation . MsvsSettings ( spec , generator_flags ) target_platform = self . msvs_settings . GetTargetPlatform ( config_name ) self . ninja . variable ( 'arch' , self . win_env [ target_platform ] ) # Compute predepends for all rules. # actions_depends is the dependencies this target depends on before running # any of its action/rule/copy steps. # compile_depends is the dependencies this target depends on before running # any of its compile steps. actions_depends = [ ] compile_depends = [ ] # TODO(evan): it is rather confusing which things are lists and which # are strings.  Fix these. if 'dependencies' in spec : for dep in spec [ 'dependencies' ] : if dep in self . target_outputs : target = self . target_outputs [ dep ] actions_depends . append ( target . PreActionInput ( self . flavor ) ) compile_depends . append ( target . PreCompileInput ( ) ) actions_depends = filter ( None , actions_depends ) compile_depends = filter ( None , compile_depends ) actions_depends = self . WriteCollapsedDependencies ( 'actions_depends' , actions_depends ) compile_depends = self . WriteCollapsedDependencies ( 'compile_depends' , compile_depends ) self . target . preaction_stamp = actions_depends self . target . precompile_stamp = compile_depends # Write out actions, rules, and copies.  These must happen before we # compile any sources, so compute a list of predependencies for sources # while we do it. extra_sources = [ ] mac_bundle_depends = [ ] self . target . actions_stamp = self . WriteActionsRulesCopies ( spec , extra_sources , actions_depends , mac_bundle_depends ) # If we have actions/rules/copies, we depend directly on those, but # otherwise we depend on dependent target's actions/rules/copies etc. # We never need to explicitly depend on previous target's link steps, # because no compile ever depends on them. compile_depends_stamp = ( self . target . actions_stamp or compile_depends ) # Write out the compilation steps, if any. link_deps = [ ] sources = spec . get ( 'sources' , [ ] ) + extra_sources if sources : pch = None if self . flavor == 'win' : pch = gyp . msvs_emulation . PrecompiledHeader ( self . msvs_settings , config_name , self . GypPathToNinja ) else : pch = gyp . xcode_emulation . MacPrefixHeader ( self . xcode_settings , self . GypPathToNinja , lambda path , lang : self . GypPathToUniqueOutput ( path + '-' + lang ) ) link_deps = self . WriteSources ( config_name , config , sources , compile_depends_stamp , pch , case_sensitive_filesystem ) # Some actions/rules output 'sources' that are already object files. link_deps += [ self . GypPathToNinja ( f ) for f in sources if f . endswith ( self . obj_ext ) ] if self . flavor == 'win' and self . target . type == 'static_library' : self . target . component_objs = link_deps # Write out a link step, if needed. output = None if link_deps or self . target . actions_stamp or actions_depends : output = self . WriteTarget ( spec , config_name , config , link_deps , self . target . actions_stamp or actions_depends ) if self . is_mac_bundle : mac_bundle_depends . append ( output ) # Bundle all of the above together, if needed. if self . is_mac_bundle : output = self . WriteMacBundle ( spec , mac_bundle_depends ) if not output : return None assert self . target . FinalOutput ( ) , output return self . target