Базель не находит сгенерированные заголовки - PullRequest
0 голосов
/ 28 января 2019

Я продолжаю получать сообщение об ошибке «Нет такого файла или каталога myheader.h» при попытке сборки.Я делаю что-то концептуально неправильно здесь?Я не понимаю, почему он не находит заголовки, я действительно не думаю, что я должен добавить копты -Ibazel-out/k8-fastbuild/genfiles/mylibrary, потому что этот путь изменяется в зависимости от параметров командной строки.

# BUILD file
load(":size.bzl", "size")
size(
    name = "blubhdrs",

    infiles =   [
        "myheader.h", # generates new file with the same name in genfiles
    ]
)

cc_library(
     name = "mylibrary",
     hdrs = [
            ":blubhdrs"
     ],
     srcs = [ "bla.cpp" ] # depends on generated header from :blubhdrs
)


# size.bzl
def _impl(ctx):

    outputfiles = []
    for input in ctx.files.infiles:
        name = input.basename
        myoutputfile = ctx.actions.declare_file(name)
        outputfiles.append(myoutputfile)
        # huge command, not important so I commented it out: 
        # ctx.actions.run_shell(...) 

    return DefaultInfo(files = depset(items = outputfiles))

size = rule(
    implementation = _impl,
    attrs = {
        "infiles": attr.label_list(allow_files = True),
    },
    output_to_genfiles = True
)

1 Ответ

0 голосов
/ 28 января 2019

Ладно, похоже, что канонический способ действительно сделать: copts = ["-I$(GENDIR)/myprojectdir"]

...