Skip to content

Commit

Permalink
[executorch][flat_tensor] Generate flatc files
Browse files Browse the repository at this point in the history
1. Move schema files under flat_tensor/serialize
2. Add targets to generate schema files

Differential Revision: [D66903492](https://our.internmc.facebook.com/intern/diff/D66903492/)

ghstack-source-id: 257299448
Pull Request resolved: #7255
  • Loading branch information
lucylq committed Dec 9, 2024
1 parent 384e7ed commit bfdc3a3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
16 changes: 16 additions & 0 deletions extension/flat_tensor/serialize/TARGETS
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load(":targets.bzl", "define_common_targets")

oncall("executorch")

define_common_targets()

runtime.python_library(
name = "schema",
srcs = [
"flat_tensor_schema.py",
],
visibility = [
"//executorch/...",
],
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions extension/flat_tensor/serialize/targets.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

def define_common_targets():
runtime.genrule(
name = "gen_schema",
srcs = [
"flat_tensor.fbs",
"scalar_type.fbs",
],
outs = {
"schema_generated.h": ["flat_tensor_generated.h"],
"scalar_type_generated.h": ["scalar_type_generated.h"]
},
cmd = " ".join([
"$(exe {})".format(runtime.external_dep_location("flatc")),
"--cpp",
"--cpp-std c++11",
"--scoped-enums",
"-o ${OUT}",
"${SRCS}",
]),
default_outs = ["."],
)

runtime.cxx_library(
name = "generated_headers",
srcs = [],
visibility = [
"//executorch/...",
],
exported_headers = {
"schema_generated.h": ":gen_schema[schema_generated.h]",
"scalar_type_generated.h": ":gen_schema[scalar_type_generated.h]",
},
exported_external_deps = ["flatbuffers-api"],
)

0 comments on commit bfdc3a3

Please sign in to comment.