tools/clang/scripts/goma_link.py
def gen_ninja(self, ninjaname, params, gen_dir):
    """
    Generates a ninja build file at path ninjaname, using original command line
    params and with objs being a list of bitcode files for which to generate
    native code.
    """
    if self.gomacc:
      gomacc_prefix = ninjaenc(self.gomacc) + ' '
    else:
      gomacc_prefix = ''
    base = gen_dir + '/' + os.path.basename(params.output)
    ensure_dir(gen_dir)
    ensure_dir(os.path.dirname(ninjaname))
    codegen_cmd = ('%s%s -c %s -fthinlto-index=$index %s$bitcode -o $native' %
                   (gomacc_prefix, ninjaenc(params.compiler),
                    ninjajoin(params.codegen_params), self.XIR))
    if params.index_inputs:
      used_obj_file = base + '.objs'
      index_rsp = base + '.index.rsp'
      ensure_dir(os.path.dirname(used_obj_file))
      if params.splitfile:
        ensure_dir(os.path.dirname(params.splitfile))
        # We use grep here to only codegen native objects which are actually
        # used by the native link step. Ninja 1.10 introduced a dyndep feature
        # which allows for a more elegant implementation, but Chromium still
        # uses an older ninja version which doesn't have this feature.
        codegen_cmd = '( ! grep -qF $native %s || %s)' % (
            ninjaenc(used_obj_file), codegen_cmd)

    with open(ninjaname, 'w') as f:
      if params.index_inputs:
        self.write_rsp(index_rsp, params.index_params)
        f.write('\nrule index\n  command = %s %s %s @$rspfile\n' %
                (ninjaenc(params.linker),
                 ninjaenc(self.WL + self.TLTO + '-index-only' + self.SEP) +
                 '$out', self.WL + self.TLTO + '-emit-imports-files'))

      f.write(('\nrule native-link\n  command = %s @$rspname'
               '\n  rspfile = $rspname\n  rspfile_content = $params\n') %
              (ninjaenc(params.linker), ))

      f.write('\nrule codegen\n  command = %s && touch $out\n' %
              (codegen_cmd, ))

      native_link_deps = []
      if params.index_inputs:
        f.write(
            ('\nbuild %s | %s : index %s\n'
             '  rspfile = %s\n'
             '  rspfile_content = %s\n') %
            (ninjaenc(used_obj_file), ninjajoin(
                [x[2] for x in params.codegen]), ninjajoin(params.index_inputs),
             ninjaenc(index_rsp), ninjajoin(params.index_params)))
        native_link_deps.append(used_obj_file)

      for tup in params.codegen:
        obj, bitcode, index = tup
        stamp = obj + '.stamp'
        native_link_deps.append(obj)
        f.write(
            ('\nbuild %s : codegen %s %s\n'
             '  bitcode = %s\n'
             '  index = %s\n'
             '  native = %s\n'
             '\nbuild %s : phony %s\n') % tuple(
                 map(ninjaenc,
                     (stamp, bitcode, index, bitcode, index, obj, obj, stamp))))

      f.write(('\nbuild %s : native-link %s\n'
               '  rspname = %s\n  params = %s\n') %
              (ninjaenc(params.output),
               ninjajoin(list(params.final_inputs) + native_link_deps),
               ninjaenc(base + '.final.rsp'), ninjajoin(params.final_params)))

      f.write('\ndefault %s\n' % (ninjaenc(params.output), ))

    Generates a ninja build file at path ninjaname, using original command line
    params and with objs being a list of bitcode files for which to generate
    native code.
    
Generates a ninja build file at path ninjaname, using original command line
params and with objs being a list of bitcode files for which to generate
native code.
Generates a ninja build file at path ninjaname using original command line params and with objs being a list of bitcode files for which to generate native code .
def gen_ninja(self, ninjaname, params, gen_dir):
    if self.gomacc:
      gomacc_prefix = ninjaenc(self.gomacc) + ' '
    else:
      gomacc_prefix = ''
    base = gen_dir + '/' + os.path.basename(params.output)
    ensure_dir(gen_dir)
    ensure_dir(os.path.dirname(ninjaname))
    codegen_cmd = ('%s%s -c %s -fthinlto-index=$index %s$bitcode -o $native' %
                   (gomacc_prefix, ninjaenc(params.compiler),
                    ninjajoin(params.codegen_params), self.XIR))
    if params.index_inputs:
      used_obj_file = base + '.objs'
      index_rsp = base + '.index.rsp'
      ensure_dir(os.path.dirname(used_obj_file))
      if params.splitfile:
        ensure_dir(os.path.dirname(params.splitfile))
        codegen_cmd = '( ! grep -qF $native %s || %s)' % (
            ninjaenc(used_obj_file), codegen_cmd)
    with open(ninjaname, 'w') as f:
      if params.index_inputs:
        self.write_rsp(index_rsp, params.index_params)
        f.write('\nrule index\n  command = %s %s %s @$rspfile\n' %
                (ninjaenc(params.linker),
                 ninjaenc(self.WL + self.TLTO + '-index-only' + self.SEP) +
                 '$out', self.WL + self.TLTO + '-emit-imports-files'))
      f.write(('\nrule native-link\n  command = %s @$rspname'
               '\n  rspfile = $rspname\n  rspfile_content = $params\n') %
              (ninjaenc(params.linker), ))
      f.write('\nrule codegen\n  command = %s && touch $out\n' %
              (codegen_cmd, ))
      native_link_deps = []
      if params.index_inputs:
        f.write(
            ('\nbuild %s | %s : index %s\n'
             '  rspfile = %s\n'
             '  rspfile_content = %s\n') %
            (ninjaenc(used_obj_file), ninjajoin(
                [x[2] for x in params.codegen]), ninjajoin(params.index_inputs),
             ninjaenc(index_rsp), ninjajoin(params.index_params)))
        native_link_deps.append(used_obj_file)
      for tup in params.codegen:
        obj, bitcode, index = tup
        stamp = obj + '.stamp'
        native_link_deps.append(obj)
        f.write(
            ('\nbuild %s : codegen %s %s\n'
             '  bitcode = %s\n'
             '  index = %s\n'
             '  native = %s\n'
             '\nbuild %s : phony %s\n') % tuple(
                 map(ninjaenc,
                     (stamp, bitcode, index, bitcode, index, obj, obj, stamp))))
      f.write(('\nbuild %s : native-link %s\n'
               '  rspname = %s\n  params = %s\n') %
              (ninjaenc(params.output),
               ninjajoin(list(params.final_inputs) + native_link_deps),
               ninjaenc(base + '.final.rsp'), ninjajoin(params.final_params)))
      f.write('\ndefault %s\n' % (ninjaenc(params.output), ))
def gen_ninja ( self , ninjaname , params , gen_dir ) : if self . gomacc : gomacc_prefix = ninjaenc ( self . gomacc ) + ' ' else : gomacc_prefix = '' base = gen_dir + '/' + os . path . basename ( params . output ) ensure_dir ( gen_dir ) ensure_dir ( os . path . dirname ( ninjaname ) ) codegen_cmd = ( '%s%s -c %s -fthinlto-index=$index %s$bitcode -o $native' % ( gomacc_prefix , ninjaenc ( params . compiler ) , ninjajoin ( params . codegen_params ) , self . XIR ) ) if params . index_inputs : used_obj_file = base + '.objs' index_rsp = base + '.index.rsp' ensure_dir ( os . path . dirname ( used_obj_file ) ) if params . splitfile : ensure_dir ( os . path . dirname ( params . splitfile ) ) codegen_cmd = '( ! grep -qF $native %s || %s)' % ( ninjaenc ( used_obj_file ) , codegen_cmd ) with open ( ninjaname , 'w' ) as f : if params . index_inputs : self . write_rsp ( index_rsp , params . index_params ) f . write ( '\nrule index\n  command = %s %s %s @$rspfile\n' % ( ninjaenc ( params . linker ) , ninjaenc ( self . WL + self . TLTO + '-index-only' + self . SEP ) + '$out' , self . WL + self . TLTO + '-emit-imports-files' ) ) f . write ( ( '\nrule native-link\n  command = %s @$rspname' '\n  rspfile = $rspname\n  rspfile_content = $params\n' ) % ( ninjaenc ( params . linker ) , ) ) f . write ( '\nrule codegen\n  command = %s && touch $out\n' % ( codegen_cmd , ) ) native_link_deps = [ ] if params . index_inputs : f . write ( ( '\nbuild %s | %s : index %s\n' '  rspfile = %s\n' '  rspfile_content = %s\n' ) % ( ninjaenc ( used_obj_file ) , ninjajoin ( [ x [ 2 ] for x in params . codegen ] ) , ninjajoin ( params . index_inputs ) , ninjaenc ( index_rsp ) , ninjajoin ( params . index_params ) ) ) native_link_deps . append ( used_obj_file ) for tup in params . codegen : obj , bitcode , index = tup stamp = obj + '.stamp' native_link_deps . append ( obj ) f . write ( ( '\nbuild %s : codegen %s %s\n' '  bitcode = %s\n' '  index = %s\n' '  native = %s\n' '\nbuild %s : phony %s\n' ) % tuple ( map ( ninjaenc , ( stamp , bitcode , index , bitcode , index , obj , obj , stamp ) ) ) ) f . write ( ( '\nbuild %s : native-link %s\n' '  rspname = %s\n  params = %s\n' ) % ( ninjaenc ( params . output ) , ninjajoin ( list ( params . final_inputs ) + native_link_deps ) , ninjaenc ( base + '.final.rsp' ) , ninjajoin ( params . final_params ) ) ) f . write ( '\ndefault %s\n' % ( ninjaenc ( params . output ) , ) )
Generates a ninja build file at path ninjaname, using original command line
params and with objs being a list of bitcode files for which to generate
native code.
Generates a ninja build file at path ninjaname using original command line params and with objs being a list of bitcode files for which to generate native code .
"""
    Generates a ninja build file at path ninjaname, using original command line
    params and with objs being a list of bitcode files for which to generate
    native code.
    """ # We use grep here to only codegen native objects which are actually # used by the native link step. Ninja 1.10 introduced a dyndep feature # which allows for a more elegant implementation, but Chromium still # uses an older ninja version which doesn't have this feature.
self
ninjaname
params
gen_dir