njlr / buck-qt-workaround

Example of how to use your system Qt with Buck
MIT License
0 stars 0 forks source link

Invoking moc? #1

Open csetlow opened 5 years ago

csetlow commented 5 years ago

Hi njlr,

The .buckconfig in this repo is empty and I don't see any rules in the BUCK file to invoke moc. Am I correct in assuming this example doesn't support Qt features that depend on Q_OBJECT and moc?

njlr commented 5 years ago

Hi @csetlow

I have updated the example to show how you can call moc.

Basically, you would use a genrule like so:

genrule(
  name = 'my-class',
  out = 'my-class.cpp',
  srcs = [
    'my-class.cpp',
  ],
  cmd = 'moc $SRCS > $OUT',
)

You could even make your own macro:

function moc(name, src):
  native.genrule(
    name = name,
    out = 'moc.cpp',
    srcs = [ src ], 
    cmd = 'moc $SRCS > $OUT', 
  )

Used like so:

moc(
  name = 'my-class', 
  src = 'my-class.cpp',
)