diff --git a/third_party/mlir/tblgen.bzl b/third_party/mlir/tblgen.bzl index 8f8c3179dec..da57bccf70f 100644 --- a/third_party/mlir/tblgen.bzl +++ b/third_party/mlir/tblgen.bzl @@ -1,6 +1,6 @@ """BUILD extensions for MLIR table generation.""" -def gentbl(name, tblgen, td_file, tbl_outs, td_srcs = [], strip_include_prefix = None): +def gentbl(name, tblgen, td_file, tbl_outs, td_srcs = [], td_includes = [], strip_include_prefix = None): """gentbl() generates tabular code from a table definition file. Args: @@ -11,6 +11,7 @@ def gentbl(name, tblgen, td_file, tbl_outs, td_srcs = [], strip_include_prefix = options passed to tblgen, and the out is the corresponding output file produced. td_srcs: A list of table definition files included transitively. + td_includes: A list of include paths for relative includes. strip_include_prefix: attribute to pass through to cc_library. """ srcs = [] @@ -20,8 +21,10 @@ def gentbl(name, tblgen, td_file, tbl_outs, td_srcs = [], strip_include_prefix = # Add google_mlir/include directory as include so derived op td files can # import relative to that. - td_includes = "-I external/local_config_mlir/include -I external/org_tensorflow " - td_includes += "-I $$(dirname $(location %s)) " % td_file + td_includes_str = "-I external/local_config_mlir/include -I external/org_tensorflow " + for td_include in td_includes: + td_includes_str += "-I %s " % td_include + td_includes_str += "-I $$(dirname $(location %s)) " % td_file for (opts, out) in tbl_outs: rule_suffix = "_".join(opts.replace("-", "_").replace("=", "_").split(" ")) native.genrule( @@ -32,7 +35,7 @@ def gentbl(name, tblgen, td_file, tbl_outs, td_srcs = [], strip_include_prefix = message = "Generating code from table: %s" % td_file, cmd = (("$(location %s) %s %s $(location %s) -o $@") % ( tblgen, - td_includes, + td_includes_str, opts, td_file, )),