1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") 2 3def define_flatcc_targets(): 4 # Flatcc public headers 5 PUBLIC_HEADERS = [ 6 "flatcc/config/config.h", 7 "flatcc/include/flatcc/flatcc.h", 8 "flatcc/include/flatcc/flatcc_assert.h", 9 "flatcc/include/flatcc/flatcc_version.h", 10 "flatcc/include/flatcc/flatcc_emitter.h", 11 "flatcc/include/flatcc/flatcc_alloc.h", 12 "flatcc/include/flatcc/flatcc_json_printer.h", 13 "flatcc/include/flatcc/flatcc_verifier.h", 14 "flatcc/include/flatcc/flatcc_refmap.h", 15 "flatcc/include/flatcc/flatcc_unaligned.h", 16 "flatcc/include/flatcc/portable/grisu3_print.h", 17 "flatcc/include/flatcc/portable/pprintfp.h", 18 "flatcc/include/flatcc/portable/pbase64.h", 19 "flatcc/include/flatcc/portable/punaligned.h", 20 "flatcc/include/flatcc/portable/pdiagnostic.h", 21 "flatcc/include/flatcc/portable/pinttypes.h", 22 "flatcc/include/flatcc/portable/pinline.h", 23 "flatcc/include/flatcc/portable/pprintint.h", 24 "flatcc/include/flatcc/portable/pdiagnostic_pop.h", 25 "flatcc/include/flatcc/portable/include/std/stdalign.h", 26 "flatcc/include/flatcc/portable/include/std/inttypes.h", 27 "flatcc/include/flatcc/portable/include/std/stdbool.h", 28 "flatcc/include/flatcc/portable/include/std/stdint.h", 29 "flatcc/include/flatcc/portable/include/linux/endian.h", 30 "flatcc/include/flatcc/portable/pversion.h", 31 "flatcc/include/flatcc/portable/pstdalign.h", 32 "flatcc/include/flatcc/portable/pdiagnostic_push.h", 33 "flatcc/include/flatcc/portable/pendian_detect.h", 34 "flatcc/include/flatcc/portable/paligned_alloc.h", 35 "flatcc/include/flatcc/portable/pendian.h", 36 "flatcc/include/flatcc/portable/pstatic_assert.h", 37 "flatcc/include/flatcc/portable/pwarnings.h", 38 "flatcc/include/flatcc/portable/pparsefp.h", 39 "flatcc/include/flatcc/portable/portable_basic.h", 40 "flatcc/include/flatcc/portable/portable.h", 41 "flatcc/include/flatcc/portable/grisu3_math.h", 42 "flatcc/include/flatcc/portable/pstdint.h", 43 "flatcc/include/flatcc/portable/pstdbool.h", 44 "flatcc/include/flatcc/portable/pstatic_assert_scope.h", 45 "flatcc/include/flatcc/portable/grisu3_parse.h", 46 "flatcc/include/flatcc/portable/pparseint.h", 47 "flatcc/include/flatcc/flatcc_endian.h", 48 "flatcc/include/flatcc/flatcc_iov.h", 49 "flatcc/include/flatcc/flatcc_rtconfig.h", 50 "flatcc/include/flatcc/flatcc_accessors.h", 51 "flatcc/include/flatcc/flatcc_epilogue.h", 52 "flatcc/include/flatcc/flatcc_identifier.h", 53 "flatcc/include/flatcc/flatcc_prologue.h", 54 "flatcc/include/flatcc/flatcc_builder.h", 55 "flatcc/include/flatcc/support/readfile.h", 56 "flatcc/include/flatcc/support/cdump.h", 57 "flatcc/include/flatcc/support/elapsed.h", 58 "flatcc/include/flatcc/support/hexdump.h", 59 "flatcc/include/flatcc/flatcc_json_parser.h", 60 "flatcc/include/flatcc/flatcc_flatbuffers.h", 61 "flatcc/include/flatcc/flatcc_portable.h", 62 "flatcc/include/flatcc/flatcc_types.h", 63 "flatcc/include/flatcc/reflection/reflection_reader.h", 64 "flatcc/include/flatcc/reflection/flatbuffers_common_reader.h", 65 "flatcc/include/flatcc/reflection/reflection_builder.h", 66 "flatcc/include/flatcc/reflection/reflection_verifier.h", 67 "flatcc/include/flatcc/reflection/flatbuffers_common_builder.h", 68 ] 69 70 # FlatCC static libraries 71 72 runtime.cxx_library( 73 name = "flatccrt", 74 srcs = [ 75 "flatcc/src/runtime/builder.c", 76 "flatcc/src/runtime/emitter.c", 77 "flatcc/src/runtime/refmap.c", 78 "flatcc/src/runtime/verifier.c", 79 "flatcc/src/runtime/json_parser.c", 80 "flatcc/src/runtime/json_printer.c", 81 ], 82 public_include_directories = [ 83 "flatcc/include", 84 "flatcc/config", 85 "include", 86 ], 87 headers = PUBLIC_HEADERS, 88 visibility = ["@EXECUTORCH_CLIENTS"], 89 ) 90 91 runtime.cxx_library( 92 name = "flatcc", 93 srcs = [ 94 "flatcc/external/hash/cmetrohash64.c", 95 "flatcc/external/hash/ptr_set.c", 96 "flatcc/external/hash/str_set.c", 97 "flatcc/src/compiler/codegen_c.c", 98 "flatcc/src/compiler/codegen_c_builder.c", 99 "flatcc/src/compiler/codegen_c_json_parser.c", 100 "flatcc/src/compiler/codegen_c_json_printer.c", 101 "flatcc/src/compiler/codegen_c_reader.c", 102 "flatcc/src/compiler/codegen_c_sort.c", 103 "flatcc/src/compiler/codegen_c_sorter.c", 104 "flatcc/src/compiler/codegen_c_verifier.c", 105 "flatcc/src/compiler/codegen_schema.c", 106 "flatcc/src/compiler/coerce.c", 107 "flatcc/src/compiler/fileio.c", 108 "flatcc/src/compiler/flatcc.c", 109 "flatcc/src/compiler/hash_tables/name_table.c", 110 "flatcc/src/compiler/hash_tables/schema_table.c", 111 "flatcc/src/compiler/hash_tables/scope_table.c", 112 "flatcc/src/compiler/hash_tables/symbol_table.c", 113 "flatcc/src/compiler/hash_tables/value_set.c", 114 "flatcc/src/compiler/parser.c", 115 "flatcc/src/compiler/semantics.c", 116 ], 117 compiler_flags = [ 118 "-D FLATCC_REFLECTION=1", 119 "-D FLATCC_ALLOW_RPC_SERVICE_ATTRIBUTES=1", 120 "-D FLATCC_ALLOW_RPC_METHOD_ATTRIBUTES=1", 121 "-D FLATCC_JSON_PARSE_FORCE_DEFAULTS=0", 122 ], 123 include_directories = [ 124 "flatcc/external", 125 ], 126 public_include_directories = [ 127 "flatcc/include", 128 "flatcc/config", 129 ], 130 headers = PUBLIC_HEADERS + [ 131 "flatcc/external/lex/tokens.h", 132 "flatcc/external/lex/luthor.h", 133 "flatcc/external/lex/luthor.c", 134 "flatcc/external/hash/hash_table_impl_rh.h", 135 "flatcc/external/hash/ht64rh.h", 136 "flatcc/external/hash/unaligned.h", 137 "flatcc/external/hash/ht64.h", 138 "flatcc/external/hash/PMurHash.h", 139 "flatcc/external/hash/ht_portable.h", 140 "flatcc/external/hash/hash_table_def.h", 141 "flatcc/external/hash/int_set.h", 142 "flatcc/external/hash/hash_table.h", 143 "flatcc/external/hash/cmetrohash.h", 144 "flatcc/external/hash/ht_hash_function.h", 145 "flatcc/external/hash/ht32rh.h", 146 "flatcc/external/hash/ptr_set.h", 147 "flatcc/external/hash/hash_table_impl.h", 148 "flatcc/external/hash/ht32.h", 149 "flatcc/external/hash/ht_trace.h", 150 "flatcc/external/hash/pstdint.h", 151 "flatcc/external/hash/str_set.h", 152 "flatcc/external/hash/token_map.h", 153 "flatcc/external/hash/hash.h", 154 "flatcc/external/grisu3/grisu3_print.h", 155 "flatcc/external/grisu3/grisu3_math.h", 156 "flatcc/external/grisu3/grisu3_parse.h", 157 "flatcc/src/compiler/symbols.h", 158 "flatcc/src/compiler/parser.h", 159 "flatcc/src/compiler/codegen_c.h", 160 "flatcc/src/compiler/semantics.h", 161 "flatcc/src/compiler/catalog.h", 162 "flatcc/src/compiler/codegen.h", 163 "flatcc/src/compiler/coerce.h", 164 "flatcc/src/compiler/pstrutil.h", 165 "flatcc/src/compiler/fileio.h", 166 "flatcc/src/compiler/keywords.h", 167 "flatcc/src/compiler/codegen_c_sort.h", 168 ], 169 visibility = ["@EXECUTORCH_CLIENTS"], 170 deps = [":flatccrt"], 171 ) 172 173 runtime.cxx_library( 174 name = "flatcc-host", 175 srcs = [ 176 "flatcc/external/hash/cmetrohash64.c", 177 "flatcc/external/hash/ptr_set.c", 178 "flatcc/external/hash/str_set.c", 179 "flatcc/src/compiler/codegen_c.c", 180 "flatcc/src/compiler/codegen_c_builder.c", 181 "flatcc/src/compiler/codegen_c_json_parser.c", 182 "flatcc/src/compiler/codegen_c_json_printer.c", 183 "flatcc/src/compiler/codegen_c_reader.c", 184 "flatcc/src/compiler/codegen_c_sort.c", 185 "flatcc/src/compiler/codegen_c_sorter.c", 186 "flatcc/src/compiler/codegen_c_verifier.c", 187 "flatcc/src/compiler/codegen_schema.c", 188 "flatcc/src/compiler/coerce.c", 189 "flatcc/src/compiler/fileio.c", 190 "flatcc/src/compiler/flatcc.c", 191 "flatcc/src/compiler/hash_tables/name_table.c", 192 "flatcc/src/compiler/hash_tables/schema_table.c", 193 "flatcc/src/compiler/hash_tables/scope_table.c", 194 "flatcc/src/compiler/hash_tables/symbol_table.c", 195 "flatcc/src/compiler/hash_tables/value_set.c", 196 "flatcc/src/compiler/parser.c", 197 "flatcc/src/compiler/semantics.c", 198 "flatcc/src/runtime/builder.c", 199 "flatcc/src/runtime/emitter.c", 200 "flatcc/src/runtime/refmap.c", 201 ], 202 compiler_flags = [ 203 "-D FLATCC_REFLECTION=1", 204 "-D FLATCC_JSON_PARSE_FORCE_DEFAULTS=0", 205 ], 206 include_directories = [ 207 "flatcc/external", 208 ], 209 public_include_directories = [ 210 "flatcc/include", 211 "flatcc/config", 212 ], 213 headers = PUBLIC_HEADERS.append([ 214 "flatcc/external/lex/tokens.h", 215 "flatcc/external/lex/luthor.h", 216 "flatcc/external/lex/luthor.c", 217 "flatcc/external/hash/hash_table_impl_rh.h", 218 "flatcc/external/hash/ht64rh.h", 219 "flatcc/external/hash/unaligned.h", 220 "flatcc/external/hash/ht64.h", 221 "flatcc/external/hash/PMurHash.h", 222 "flatcc/external/hash/ht_portable.h", 223 "flatcc/external/hash/hash_table_def.h", 224 "flatcc/external/hash/int_set.h", 225 "flatcc/external/hash/hash_table.h", 226 "flatcc/external/hash/cmetrohash.h", 227 "flatcc/external/hash/ht_hash_function.h", 228 "flatcc/external/hash/ht32rh.h", 229 "flatcc/external/hash/ptr_set.h", 230 "flatcc/external/hash/hash_table_impl.h", 231 "flatcc/external/hash/ht32.h", 232 "flatcc/external/hash/ht_trace.h", 233 "flatcc/external/hash/pstdint.h", 234 "flatcc/external/hash/str_set.h", 235 "flatcc/external/hash/token_map.h", 236 "flatcc/external/hash/hash.h", 237 "flatcc/external/grisu3/grisu3_print.h", 238 "flatcc/external/grisu3/grisu3_math.h", 239 "flatcc/external/grisu3/grisu3_parse.h", 240 "flatcc/src/compiler/symbols.h", 241 "flatcc/src/compiler/parser.h", 242 "flatcc/src/compiler/codegen_c.h", 243 "flatcc/src/compiler/semantics.h", 244 "flatcc/src/compiler/catalog.h", 245 "flatcc/src/compiler/codegen.h", 246 "flatcc/src/compiler/coerce.h", 247 "flatcc/src/compiler/pstrutil.h", 248 "flatcc/src/compiler/fileio.h", 249 "flatcc/src/compiler/keywords.h", 250 "flatcc/src/compiler/codegen_c_sort.h", 251 ]), 252 visibility = ["@EXECUTORCH_CLIENTS"], 253 ) 254 255 # FlatCC CLI 256 runtime.cxx_binary( 257 name = "flatcc-cli", 258 srcs = [ 259 "flatcc/src/cli/flatcc_cli.c", 260 ], 261 compiler_flags = [ 262 "-D FLATCC_REFLECTION=1", 263 ], 264 include_directories = [ 265 "flatcc/include", 266 "flatcc/config", 267 ], 268 deps = [":flatcc-host"], 269 visibility = ["@EXECUTORCH_CLIENTS"], 270 ) 271