Uploaded image for project: 'Qbs ("Cubes")'
  1. Qbs ("Cubes")
  2. QBS-1259

Introduce command like gn refs

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 1.10.0
    • Command Line Frontend
    • None

    Description

      GN has a useful command called "gn refs".
      Here is a snippet of the help content returned from the command

      gn refs <out_dir> (<label_pattern>|<label>|<file>|@<response_file>)*
              [--all] [--all-toolchains] [--as=...] [--testonly=...] [--type=...]
      
        Finds reverse dependencies (which targets reference something). The input is
        a list containing:
      
         - Target label: The result will be which targets depend on it.
      
         - Config label: The result will be which targets list the given config in
           its "configs" or "public_configs" list.
      
         - Label pattern: The result will be which targets depend on any target
           matching the given pattern. Patterns will not match configs. These are not
           general regular expressions, see "gn help label_pattern" for details.
      
         - File name: The result will be which targets list the given file in its
           "inputs", "sources", "public", "data", or "outputs". Any input that does
           not contain wildcards and does not match a target or a config will be
           treated as a file.
      
         - Response file: If the input starts with an "@", it will be interpreted as
           a path to a file containing a list of labels or file names, one per line.
           This allows us to handle long lists of inputs without worrying about
           command line limits.
      

      and a few examples provided by them

      Examples (target input)
      
        gn refs out/Debug //tools/gn:gn
            Find all targets depending on the given exact target name.
      
        gn refs out/Debug //base:i18n --as=buildfiles | xargs gvim
            Edit all .gn files containing references to //base:i18n
      
        gn refs out/Debug //base --all
            List all targets depending directly or indirectly on //base:base.
      
        gn refs out/Debug "//base/*"
            List all targets depending directly on any target in //base or
            its subdirectories.
      
        gn refs out/Debug "//base:*"
            List all targets depending directly on any target in
            //base/BUILD.gn.
      
        gn refs out/Debug //base --tree
            Print a reverse dependency tree of //base:base
      
      Examples (file input)
      
        gn refs out/Debug //base/macros.h
            Print target(s) listing //base/macros.h as a source.
      
        gn refs out/Debug //base/macros.h --tree
            Display a reverse dependency tree to get to the given file. This
            will show how dependencies will reference that file.
      
        gn refs out/Debug //base/macros.h //base/at_exit.h --all
            Display all unique targets with some dependency path to a target
            containing either of the given files as a source.
      
        gn refs out/Debug //base/macros.h --testonly=true --type=executable
                --all --as=output
            Display the executable file names of all test executables
            potentially affected by a change to the given file.
      

      It would be nice to have similar functionality in qbs, to answer questions like: which .qbs file generates an artifact (executable, shared library), when given the path to the built artifact as input. Or list all products (targets in GN lingo) that end up depending on another product.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kandeler Christian Kandeler
            alexandru.croitor Alexandru Croitor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes