2016-07-12 18 views
1

Ich habe eine Dateigruppenregel erstellt, die alle .proto-Dateien einer Bibliothek in einem Etikett enthält.Bazel-Regeln und Dateigruppeninkonsistenz

filegroup(
    name = "protos_all_src", 
    srcs = glob(
     ["**/*.proto"], 
     exclude = [ 
      "protobuf/worker.proto", 
      "protobuf/worker_service.proto", 
      "protobuf/master.proto", 
      "protobuf/master_service.proto", 
     ], 
    ) 
) 

tf_proto_library(
    name = "protos_all", 
    srcs = ":protos_all_src", 
    ), 
... 
) 

aber seltsam mit diesem Format der andere Regel nicht:

cc_library(
    name = "lib_internal", 
    srcs = glob(
     [ 
      "lib/**/*.h", 
      "lib/**/*.cc", 
      "platform/*.h", 
      "platform/*.cc", 
     ] + tf_additional_lib_srcs(), 
     exclude = [ 
      "**/*test*", 
      "platform/**/cuda.h", 
      "platform/**/stream_executor.h", 
     ], 
    ), 
    hdrs = [ 
     "lib/core/blocking_counter.h", 
     "lib/core/refcount.h", 
     "lib/gtl/edit_distance.h", 
     "lib/gtl/int_type.h", 
     "lib/gtl/iterator_range.h", 
     "lib/gtl/manual_constructor.h", 
     "lib/gtl/top_n.h", 
     "lib/io/iterator.h", 
     "lib/io/match.h", 
     "lib/jpeg/jpeg_handle.h", 
     "lib/png/png_io.h", 
     "lib/random/random.h", 
     "lib/random/random_distributions.h", 
     "lib/random/weighted_picker.h", 
     "lib/strings/ordered_code.h", 
     "lib/strings/proto_text_util.h", 
     "lib/strings/regexp.h", 
     "lib/strings/scanner.h", 
     "lib/wav/wav_io.h", 
     "platform/demangle.h", 
     "platform/denormal.h", 
     "platform/platform.h", 
     "platform/tensor_coding.h", 
     "platform/tracing.h", 
    ], 
    copts = tf_copts(), 
    linkopts = ["-ldl"], 
    deps = [ 
     ":protos_all_cc", 
     "//tensorflow/core/platform/default/build_config:platformlib", 
     "//third_party/eigen3", 
    ], 
) 

Note der protos_all_cc Regel als dep.

wenn ich

wieder zurück
tf_proto_library(
    name = "protos_all", 
    srcs = glob(
     ["**/*.proto"], 
     exclude = [ 
      "protobuf/worker.proto", 
      "protobuf/worker_service.proto", 
      "protobuf/master.proto", 
      "protobuf/master_service.proto", 
     ], 
    ), 

alles funktioniert.

Ich würde erwarten, dass das erste und das zweite Format völlig gleich wäre. Was ich vermisse?

EDIT: Die tf_proto_library wird hier definiert:

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/platform/default/build_config.bzl#L26

und die cc_proto_library wird hier definiert:

https://github.com/google/protobuf/blob/master/protobuf.bzl#L109

bazel Version:

Build label: 0.2.3-homebrew 
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar 
Build time: Tue May 17 15:07:52 2016 (1463497672) 
Build timestamp: 1463497672 
Build timestamp as int: 1463497672 

Antwort

0

Das srcs Attribut sollte

tf_proto_library(
    name = "protos_all", 
    srcs = [":protos_all_src"], # note the list here 
    ... 
) 

eine Liste, so dass Ihre Definition von protos_all seine Vielleicht ist das nur ein Tippfehler in der Frage, und das eigentliche Problem ist etwas anderes sein sollte? Ich bekomme seltsame Permission denied Probleme, wenn ich Ihre filegroup Ansatz versuchen.

1

Können Sie Ihren tatsächlichen Code und die Fehlermeldung einfügen, die Sie bekommen? Es sieht so aus, als gäbe es mehrere Probleme und ich bin nicht sicher, welche Copy-Paste-Fehler und welche Code sind.

Ich vermute, das Problem, das Sie haben, ist, dass Sie keine Dateien (noch Dateigruppen) als deps in einer cc_library-Regel auflisten können, und ":protos_all_cc" ist eine Dateigruppe. deps müssen andere cc_libraries sein (es ist "Dinge, die diese Regel verknüpfen sollte"). Aber es ist sehr schwer, ohne die Fehlermeldung oder die Definition von protos_all_cc zu sagen.