Search code examples
c++buck

In Buck, how do I used the output of a genrule as a header for a cxx_library?


I have a genrule that generates a C++ header-file using a proprietary tool. The header is then used in a cxx_library. Looking at code from this presentation, I have tried the following:

cxx_library(
  name = 'my-library',
  srcs = glob(['src/**/*.cpp']),
  exported_headers = {
    'my_header.h': genfile('my-header.h'),
  },
  ...

However, it seems that genfile has been deprecated. What should I use instead?


Solution

  • You just have to specify the build target of the genrule in place of genfile('my-header.h').

    genrule(
      name='my-header',
      cmd='some_command.py',
      out='my-header.h',
    )
    
    cxx_library(
      name = 'my-library',
      srcs = glob(['src/**/*.cpp']),
      exported_headers = {
        'my_header.h': ':my-header',
      },
      ...
    )