Advait Jain | 4ff9841 | 2022-07-20 15:10:20 -0700 | [diff] [blame] | 1 | load("@build_bazel_rules_android//android:rules.bzl", "android_library") |
| 2 | load(":build_defs.bzl", "flatbuffer_py_strip_prefix_srcs") |
| 3 | |
| 4 | package(default_visibility = ["//visibility:public"]) |
| 5 | |
| 6 | licenses(["notice"]) # Apache 2.0 |
| 7 | |
| 8 | exports_files(["LICENSE.txt"]) |
| 9 | |
| 10 | licenses(["notice"]) |
| 11 | |
| 12 | config_setting( |
| 13 | name = "freebsd", |
| 14 | values = {"cpu": "freebsd"}, |
| 15 | ) |
| 16 | |
| 17 | config_setting( |
| 18 | name = "windows", |
| 19 | values = {"cpu": "x64_windows"}, |
| 20 | ) |
| 21 | |
| 22 | load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") |
| 23 | |
| 24 | # Public flatc library to compile flatbuffer files at runtime. |
| 25 | cc_library( |
| 26 | name = "flatbuffers", |
| 27 | hdrs = ["//:public_headers"], |
| 28 | linkstatic = 1, |
| 29 | strip_include_prefix = "/include", |
| 30 | visibility = ["//visibility:public"], |
| 31 | deps = ["//src:flatbuffers"], |
| 32 | ) |
| 33 | |
| 34 | # Public C++ headers for the Flatbuffers library. |
| 35 | filegroup( |
| 36 | name = "public_headers", |
| 37 | srcs = [ |
| 38 | "include/flatbuffers/base.h", |
| 39 | "include/flatbuffers/code_generators.h", |
| 40 | "include/flatbuffers/flatbuffers.h", |
| 41 | "include/flatbuffers/flexbuffers.h", |
| 42 | "include/flatbuffers/hash.h", |
| 43 | "include/flatbuffers/idl.h", |
| 44 | "include/flatbuffers/minireflect.h", |
| 45 | "include/flatbuffers/reflection.h", |
| 46 | "include/flatbuffers/reflection_generated.h", |
| 47 | "include/flatbuffers/registry.h", |
| 48 | "include/flatbuffers/stl_emulation.h", |
| 49 | "include/flatbuffers/util.h", |
| 50 | ], |
| 51 | visibility = ["//:__subpackages__"], |
| 52 | ) |
| 53 | |
| 54 | # Public flatc compiler library. |
| 55 | cc_library( |
| 56 | name = "flatc_library", |
| 57 | linkstatic = 1, |
| 58 | visibility = ["//visibility:public"], |
| 59 | deps = [ |
| 60 | "@flatbuffers//src:flatc_library", |
| 61 | ], |
| 62 | ) |
| 63 | |
| 64 | # Public flatc compiler. |
| 65 | cc_binary( |
| 66 | name = "flatc", |
| 67 | linkopts = select({ |
| 68 | ":freebsd": [ |
| 69 | "-lm", |
| 70 | ], |
| 71 | ":windows": [], |
| 72 | "//conditions:default": [ |
| 73 | "-lm", |
| 74 | "-ldl", |
| 75 | ], |
| 76 | }), |
| 77 | visibility = ["//visibility:public"], |
| 78 | deps = [ |
| 79 | "@flatbuffers//src:flatc", |
| 80 | ], |
| 81 | ) |
| 82 | |
| 83 | filegroup( |
| 84 | name = "flatc_headers", |
| 85 | srcs = [ |
| 86 | "include/flatbuffers/flatc.h", |
| 87 | ], |
| 88 | visibility = ["//:__subpackages__"], |
| 89 | ) |
| 90 | |
| 91 | # Library used by flatbuffer_cc_library rules. |
| 92 | cc_library( |
| 93 | name = "runtime_cc", |
| 94 | hdrs = [ |
| 95 | "include/flatbuffers/base.h", |
| 96 | "include/flatbuffers/flatbuffers.h", |
| 97 | "include/flatbuffers/flexbuffers.h", |
| 98 | "include/flatbuffers/stl_emulation.h", |
| 99 | "include/flatbuffers/util.h", |
| 100 | ], |
| 101 | linkstatic = 1, |
| 102 | strip_include_prefix = "/include", |
| 103 | visibility = ["//visibility:public"], |
| 104 | ) |
| 105 | |
| 106 | flatbuffer_py_strip_prefix_srcs( |
| 107 | name = "flatbuffer_py_strip_prefix", |
| 108 | srcs = [ |
| 109 | "python/flatbuffers/__init__.py", |
| 110 | "python/flatbuffers/builder.py", |
| 111 | "python/flatbuffers/compat.py", |
| 112 | "python/flatbuffers/encode.py", |
| 113 | "python/flatbuffers/number_types.py", |
| 114 | "python/flatbuffers/packer.py", |
| 115 | "python/flatbuffers/table.py", |
| 116 | "python/flatbuffers/util.py", |
| 117 | ], |
| 118 | strip_prefix = "python/flatbuffers/", |
| 119 | ) |
| 120 | |
| 121 | filegroup( |
| 122 | name = "runtime_py_srcs", |
| 123 | srcs = [ |
| 124 | "__init__.py", |
| 125 | "builder.py", |
| 126 | "compat.py", |
| 127 | "encode.py", |
| 128 | "number_types.py", |
| 129 | "packer.py", |
| 130 | "table.py", |
| 131 | "util.py", |
| 132 | ], |
| 133 | ) |
| 134 | |
| 135 | py_library( |
| 136 | name = "runtime_py", |
| 137 | srcs = [":runtime_py_srcs"], |
| 138 | visibility = ["//visibility:public"], |
| 139 | ) |
| 140 | |
| 141 | filegroup( |
| 142 | name = "runtime_java_srcs", |
| 143 | srcs = glob(["java/com/google/flatbuffers/**/*.java"]), |
| 144 | ) |
| 145 | |
| 146 | java_library( |
| 147 | name = "runtime_java", |
| 148 | srcs = [":runtime_java_srcs"], |
| 149 | visibility = ["//visibility:public"], |
| 150 | ) |
| 151 | |
| 152 | android_library( |
| 153 | name = "runtime_android", |
| 154 | srcs = [":runtime_java_srcs"], |
| 155 | visibility = ["//visibility:public"], |
| 156 | ) |