2019-12-02 22:14:48 +00:00
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
|
2019-09-19 16:58:36 +00:00
|
|
|
|
2021-02-11 18:16:57 +00:00
|
|
|
licenses(["notice"])
|
|
|
|
|
2018-02-05 18:23:15 +00:00
|
|
|
package(
|
|
|
|
default_visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
exports_files([
|
|
|
|
"LICENSE",
|
2022-03-10 18:08:13 +00:00
|
|
|
"tsconfig.json",
|
2018-02-05 18:23:15 +00:00
|
|
|
])
|
|
|
|
|
2021-09-27 19:07:04 +00:00
|
|
|
config_setting(
|
|
|
|
name = "platform_freebsd",
|
|
|
|
constraint_values = [
|
|
|
|
"@platforms//os:freebsd",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
config_setting(
|
|
|
|
name = "platform_openbsd",
|
|
|
|
constraint_values = [
|
|
|
|
"@platforms//os:openbsd",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
Migrate from rules_nodejs to rules_js/rules_ts (take 2) (#7928)
* Migrate from rules_nodejs to rules_js/rules_ts (take 2)
This is the second version of patch #7923. The first version got
reverted because bazel query was failing:
$ bazel --nosystem_rc --nohome_rc query tests(set('//...')) except tests(attr("tags", "manual", set('//...')))
ERROR: Traceback (most recent call last):
File "/workdir/tests/ts/bazel_repository_test_dir/BUILD", line 6, column 22, in <toplevel>
npm_link_all_packages(name = "node_modules")
File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/ec321eb2cc2d0f8f91b676b6d4c66c29/external/npm/defs.bzl", line 188, column 13, in npm_link_all_packages
fail(msg)
Error in fail: The npm_link_all_packages() macro loaded from @npm//:defs.bzl and called in bazel package 'tests/ts/bazel_repository_test_dir' may only be called in bazel packages that correspond to the pnpm root package '' and pnpm workspace projects ''
This was happening because the `.bazelrc` file only added
`--deleted_packages` to the `build` command. We also need it for the
`query` command. This second version of the patch fixes that.
Original commit message:
This patch migrates the current use of rules_nodejs to the new rules_js.
rules_js is the intended replacement of rules_nodejs as per this note:
https://github.com/aspect-build/rules_js#relationship-to-rules_nodejs
> rules_js is an alternative to the build_bazel_rules_nodejs Bazel module
> and accompanying npm packages hosted in
> https://github.com/bazelbuild/rules_nodejs, which is now
> unmaintained. All users are recommended to use rules_js instead.
There are a few notable changes in this patch:
1. The `flatbuffer_ts_library` macro no longer accepts a `package_name`
attribute. This is because rules_js appears to manage the import
naming of dependencies via top-level `npm_link_package` targets.
Users will have to migrate.
2. I added a few more arguments to `flatbuffer_library_public()`. These
helped with exposing esbuild to `ts/compile_flat_file.sh`.
3. I pinned the version of `typescript` in `package.json` so that
rules_ts can download the exact same version. rules_ts doesn't know
what to do if the version isn't exact.
4. Since rules_js uses the pnpm locking mechanism, we now have a
`pnpm-lock.yaml` file instead of a yarn lock file.
4. I added bazel targets for a few of the existing tests in `tests/ts`.
They can be run with `bazel test //test/ts:all`. Since there is no
flexbuffers bazel target, I did not add a bazel target for the
corresponding test.
5. I added a separate workspace in `tests/ts/bazel_repository_test_dir/`
to validate that the flatbuffers code can be imported as an external
repository. You can run the test with
`bazel test //test/ts:bazel_repository_test`. For this to work, I
needed to expose a non-trivial chunk of the flatbuffers code to the
test. I achieved this through some recursive `distribution`
filegroups. This is inspired by rules_python's workspace tests.
I did not do anything special to validate that the `gen_reflections`
parameter works the same. This patch doesn't change anything about
the TypeScript generation.
As a side note: I am not an expert with rules_js. This patch is my
attempt based on my limited understanding of the rule set.
Fixes #7817
* Fix the query
---------
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-03 18:48:15 +00:00
|
|
|
filegroup(
|
|
|
|
name = "distribution",
|
|
|
|
srcs = [
|
2024-04-18 05:06:06 +00:00
|
|
|
".bazelignore",
|
|
|
|
".npmrc",
|
Migrate from rules_nodejs to rules_js/rules_ts (take 2) (#7928)
* Migrate from rules_nodejs to rules_js/rules_ts (take 2)
This is the second version of patch #7923. The first version got
reverted because bazel query was failing:
$ bazel --nosystem_rc --nohome_rc query tests(set('//...')) except tests(attr("tags", "manual", set('//...')))
ERROR: Traceback (most recent call last):
File "/workdir/tests/ts/bazel_repository_test_dir/BUILD", line 6, column 22, in <toplevel>
npm_link_all_packages(name = "node_modules")
File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/ec321eb2cc2d0f8f91b676b6d4c66c29/external/npm/defs.bzl", line 188, column 13, in npm_link_all_packages
fail(msg)
Error in fail: The npm_link_all_packages() macro loaded from @npm//:defs.bzl and called in bazel package 'tests/ts/bazel_repository_test_dir' may only be called in bazel packages that correspond to the pnpm root package '' and pnpm workspace projects ''
This was happening because the `.bazelrc` file only added
`--deleted_packages` to the `build` command. We also need it for the
`query` command. This second version of the patch fixes that.
Original commit message:
This patch migrates the current use of rules_nodejs to the new rules_js.
rules_js is the intended replacement of rules_nodejs as per this note:
https://github.com/aspect-build/rules_js#relationship-to-rules_nodejs
> rules_js is an alternative to the build_bazel_rules_nodejs Bazel module
> and accompanying npm packages hosted in
> https://github.com/bazelbuild/rules_nodejs, which is now
> unmaintained. All users are recommended to use rules_js instead.
There are a few notable changes in this patch:
1. The `flatbuffer_ts_library` macro no longer accepts a `package_name`
attribute. This is because rules_js appears to manage the import
naming of dependencies via top-level `npm_link_package` targets.
Users will have to migrate.
2. I added a few more arguments to `flatbuffer_library_public()`. These
helped with exposing esbuild to `ts/compile_flat_file.sh`.
3. I pinned the version of `typescript` in `package.json` so that
rules_ts can download the exact same version. rules_ts doesn't know
what to do if the version isn't exact.
4. Since rules_js uses the pnpm locking mechanism, we now have a
`pnpm-lock.yaml` file instead of a yarn lock file.
4. I added bazel targets for a few of the existing tests in `tests/ts`.
They can be run with `bazel test //test/ts:all`. Since there is no
flexbuffers bazel target, I did not add a bazel target for the
corresponding test.
5. I added a separate workspace in `tests/ts/bazel_repository_test_dir/`
to validate that the flatbuffers code can be imported as an external
repository. You can run the test with
`bazel test //test/ts:bazel_repository_test`. For this to work, I
needed to expose a non-trivial chunk of the flatbuffers code to the
test. I achieved this through some recursive `distribution`
filegroups. This is inspired by rules_python's workspace tests.
I did not do anything special to validate that the `gen_reflections`
parameter works the same. This patch doesn't change anything about
the TypeScript generation.
As a side note: I am not an expert with rules_js. This patch is my
attempt based on my limited understanding of the rule set.
Fixes #7817
* Fix the query
---------
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-03 18:48:15 +00:00
|
|
|
"BUILD.bazel",
|
|
|
|
"WORKSPACE",
|
|
|
|
"build_defs.bzl",
|
2024-04-18 05:06:06 +00:00
|
|
|
"package.json",
|
|
|
|
"pnpm-lock.yaml",
|
Migrate from rules_nodejs to rules_js/rules_ts (take 2) (#7928)
* Migrate from rules_nodejs to rules_js/rules_ts (take 2)
This is the second version of patch #7923. The first version got
reverted because bazel query was failing:
$ bazel --nosystem_rc --nohome_rc query tests(set('//...')) except tests(attr("tags", "manual", set('//...')))
ERROR: Traceback (most recent call last):
File "/workdir/tests/ts/bazel_repository_test_dir/BUILD", line 6, column 22, in <toplevel>
npm_link_all_packages(name = "node_modules")
File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/ec321eb2cc2d0f8f91b676b6d4c66c29/external/npm/defs.bzl", line 188, column 13, in npm_link_all_packages
fail(msg)
Error in fail: The npm_link_all_packages() macro loaded from @npm//:defs.bzl and called in bazel package 'tests/ts/bazel_repository_test_dir' may only be called in bazel packages that correspond to the pnpm root package '' and pnpm workspace projects ''
This was happening because the `.bazelrc` file only added
`--deleted_packages` to the `build` command. We also need it for the
`query` command. This second version of the patch fixes that.
Original commit message:
This patch migrates the current use of rules_nodejs to the new rules_js.
rules_js is the intended replacement of rules_nodejs as per this note:
https://github.com/aspect-build/rules_js#relationship-to-rules_nodejs
> rules_js is an alternative to the build_bazel_rules_nodejs Bazel module
> and accompanying npm packages hosted in
> https://github.com/bazelbuild/rules_nodejs, which is now
> unmaintained. All users are recommended to use rules_js instead.
There are a few notable changes in this patch:
1. The `flatbuffer_ts_library` macro no longer accepts a `package_name`
attribute. This is because rules_js appears to manage the import
naming of dependencies via top-level `npm_link_package` targets.
Users will have to migrate.
2. I added a few more arguments to `flatbuffer_library_public()`. These
helped with exposing esbuild to `ts/compile_flat_file.sh`.
3. I pinned the version of `typescript` in `package.json` so that
rules_ts can download the exact same version. rules_ts doesn't know
what to do if the version isn't exact.
4. Since rules_js uses the pnpm locking mechanism, we now have a
`pnpm-lock.yaml` file instead of a yarn lock file.
4. I added bazel targets for a few of the existing tests in `tests/ts`.
They can be run with `bazel test //test/ts:all`. Since there is no
flexbuffers bazel target, I did not add a bazel target for the
corresponding test.
5. I added a separate workspace in `tests/ts/bazel_repository_test_dir/`
to validate that the flatbuffers code can be imported as an external
repository. You can run the test with
`bazel test //test/ts:bazel_repository_test`. For this to work, I
needed to expose a non-trivial chunk of the flatbuffers code to the
test. I achieved this through some recursive `distribution`
filegroups. This is inspired by rules_python's workspace tests.
I did not do anything special to validate that the `gen_reflections`
parameter works the same. This patch doesn't change anything about
the TypeScript generation.
As a side note: I am not an expert with rules_js. This patch is my
attempt based on my limited understanding of the rule set.
Fixes #7817
* Fix the query
---------
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-05-03 18:48:15 +00:00
|
|
|
"typescript.bzl",
|
|
|
|
"//grpc/src/compiler:distribution",
|
|
|
|
"//reflection:distribution",
|
|
|
|
"//src:distribution",
|
|
|
|
"//ts:distribution",
|
|
|
|
] + glob([
|
|
|
|
"include/flatbuffers/*.h",
|
|
|
|
]),
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
2018-02-05 18:23:15 +00:00
|
|
|
# Public flatc library to compile flatbuffer files at runtime.
|
|
|
|
cc_library(
|
|
|
|
name = "flatbuffers",
|
2019-12-02 22:14:48 +00:00
|
|
|
hdrs = ["//:public_headers"],
|
2018-02-05 18:23:15 +00:00
|
|
|
linkstatic = 1,
|
2019-12-02 22:14:48 +00:00
|
|
|
strip_include_prefix = "/include",
|
|
|
|
deps = ["//src:flatbuffers"],
|
2018-02-05 18:23:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Public C++ headers for the Flatbuffers library.
|
|
|
|
filegroup(
|
|
|
|
name = "public_headers",
|
|
|
|
srcs = [
|
2021-11-11 06:26:09 +00:00
|
|
|
"include/flatbuffers/allocator.h",
|
|
|
|
"include/flatbuffers/array.h",
|
2018-02-05 18:23:15 +00:00
|
|
|
"include/flatbuffers/base.h",
|
2021-11-11 06:26:09 +00:00
|
|
|
"include/flatbuffers/buffer.h",
|
|
|
|
"include/flatbuffers/buffer_ref.h",
|
2023-01-08 23:01:33 +00:00
|
|
|
"include/flatbuffers/code_generator.h",
|
2018-02-05 18:23:15 +00:00
|
|
|
"include/flatbuffers/code_generators.h",
|
2021-11-11 06:26:09 +00:00
|
|
|
"include/flatbuffers/default_allocator.h",
|
|
|
|
"include/flatbuffers/detached_buffer.h",
|
2023-04-06 01:49:29 +00:00
|
|
|
"include/flatbuffers/file_manager.h",
|
2021-11-11 06:26:09 +00:00
|
|
|
"include/flatbuffers/flatbuffer_builder.h",
|
2018-02-05 18:23:15 +00:00
|
|
|
"include/flatbuffers/flatbuffers.h",
|
2022-04-05 23:29:42 +00:00
|
|
|
"include/flatbuffers/flex_flat_util.h",
|
2018-02-05 18:23:15 +00:00
|
|
|
"include/flatbuffers/flexbuffers.h",
|
2020-07-21 18:08:01 +00:00
|
|
|
"include/flatbuffers/grpc.h",
|
2018-02-05 18:23:15 +00:00
|
|
|
"include/flatbuffers/hash.h",
|
|
|
|
"include/flatbuffers/idl.h",
|
2018-07-23 23:28:49 +00:00
|
|
|
"include/flatbuffers/minireflect.h",
|
2018-02-05 18:23:15 +00:00
|
|
|
"include/flatbuffers/reflection.h",
|
|
|
|
"include/flatbuffers/reflection_generated.h",
|
2019-12-02 22:14:48 +00:00
|
|
|
"include/flatbuffers/registry.h",
|
2018-02-05 18:23:15 +00:00
|
|
|
"include/flatbuffers/stl_emulation.h",
|
2021-11-11 06:26:09 +00:00
|
|
|
"include/flatbuffers/string.h",
|
|
|
|
"include/flatbuffers/struct.h",
|
|
|
|
"include/flatbuffers/table.h",
|
2018-02-05 18:23:15 +00:00
|
|
|
"include/flatbuffers/util.h",
|
2021-11-11 06:26:09 +00:00
|
|
|
"include/flatbuffers/vector.h",
|
|
|
|
"include/flatbuffers/vector_downward.h",
|
|
|
|
"include/flatbuffers/verifier.h",
|
2018-02-05 18:23:15 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Public flatc compiler library.
|
|
|
|
cc_library(
|
|
|
|
name = "flatc_library",
|
2019-12-02 22:14:48 +00:00
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
"//src:flatc_library",
|
2018-02-05 18:23:15 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Public flatc compiler.
|
|
|
|
cc_binary(
|
|
|
|
name = "flatc",
|
2022-03-10 18:08:13 +00:00
|
|
|
data = ["//reflection:reflection_fbs_schema"],
|
2018-02-05 18:23:15 +00:00
|
|
|
deps = [
|
2019-12-02 22:14:48 +00:00
|
|
|
"//src:flatc",
|
2018-02-05 18:23:15 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-12-02 22:14:48 +00:00
|
|
|
filegroup(
|
|
|
|
name = "flatc_headers",
|
|
|
|
srcs = [
|
|
|
|
"include/flatbuffers/flatc.h",
|
|
|
|
],
|
|
|
|
visibility = ["//:__subpackages__"],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Library used by flatbuffer_cc_library rules.
|
2018-10-15 19:18:15 +00:00
|
|
|
cc_library(
|
|
|
|
name = "runtime_cc",
|
|
|
|
hdrs = [
|
|
|
|
"include/flatbuffers/base.h",
|
|
|
|
"include/flatbuffers/flatbuffers.h",
|
2018-12-10 20:23:40 +00:00
|
|
|
"include/flatbuffers/flexbuffers.h",
|
2018-10-15 19:18:15 +00:00
|
|
|
"include/flatbuffers/stl_emulation.h",
|
|
|
|
"include/flatbuffers/util.h",
|
2021-11-11 06:26:09 +00:00
|
|
|
"include/flatbuffers/vector.h",
|
|
|
|
"include/flatbuffers/verifier.h",
|
2018-10-15 19:18:15 +00:00
|
|
|
],
|
|
|
|
linkstatic = 1,
|
2019-12-02 22:14:48 +00:00
|
|
|
strip_include_prefix = "/include",
|
2019-08-01 21:31:48 +00:00
|
|
|
)
|