Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nfc] Refactor bazel dependencies #1169

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion src/workerd/api/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("//:build/kj_test.bzl", "kj_test")
load("//:build/wd_cc_capnp_library.bzl", "wd_cc_capnp_library")
load("//:build/wd_cc_library.bzl", "wd_cc_library")
load("//:build/wd_test.bzl", "wd_test")

filegroup(
Expand All @@ -8,12 +9,16 @@ filegroup(
"//src/workerd/io:set_enable_experimental_webgpu": glob(
["**/*.c++"],
exclude = [
"html-rewriter.c++",
"rtti.c++",
"**/*test*.c++",
],
),
"//conditions:default": glob(
["**/*.c++"],
exclude = [
"html-rewriter.c++",
"rtti.c++",
"**/*test*.c++",
"gpu/*.c++",
],
Expand All @@ -28,12 +33,18 @@ filegroup(
"//src/workerd/io:set_enable_experimental_webgpu": glob(
["**/*.h"],
exclude = [
"html-rewriter.h",
"modules.h",
"rtti.h",
"**/*test*.h",
],
),
"//conditions:default": glob(
["**/*.h"],
exclude = [
"html-rewriter.h",
"modules.h",
"rtti.h",
"**/*test*.h",
"gpu/*.h",
],
Expand All @@ -42,6 +53,33 @@ filegroup(
visibility = ["//visibility:public"],
)

wd_cc_library(
name = "rtti",
srcs = ["rtti.c++"],
hdrs = [
"rtti.h",
"modules.h",
],
visibility = ["//visibility:public"],
deps = [
":html-rewriter",
"//src/workerd/io",
],
)

# Moved out of io library so that it does not depend on lolhtml and the associated rust crates.
# This reduces the linker input size for tests based on io.
wd_cc_library(
name = "html-rewriter",
srcs = ["html-rewriter.c++"],
hdrs = ["html-rewriter.h"],
visibility = ["//visibility:public"],
deps = [
"//src/workerd/io",
"@com_cloudflare_lol_html//:lolhtml",
],
)

wd_cc_capnp_library(
name = "r2-api_capnp",
srcs = ["r2-api.capnp"],
Expand All @@ -58,11 +96,11 @@ wd_cc_capnp_library(
src = f,
deps = [
"//src/workerd/io",
"//src/workerd/jsg:rtti",
],
) for f in glob(
["**/*-test.c++"],
exclude = [
"api-rtti-test.c++",
"cf-property-test.c++",
"node/*-test.c++",
],
Expand All @@ -73,6 +111,15 @@ kj_test(
deps = ["//src/workerd/tests:test-fixture"],
)

kj_test(
src = "api-rtti-test.c++",
deps = [
":html-rewriter",
"//src/workerd/io",
"//src/workerd/jsg:rtti",
],
)

kj_test(
src = "cf-property-test.c++",
deps = ["//src/workerd/tests:test-fixture"],
Expand Down
2 changes: 1 addition & 1 deletion src/workerd/api/html-rewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#pragma once

#include "workerd/api/http.h"
#include <workerd/jsg/jsg.h>
#include <v8.h>
#include "http.h"

struct lol_html_HtmlRewriterBuilder;
struct lol_html_HtmlRewriter;
Expand Down
1 change: 0 additions & 1 deletion src/workerd/io/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ wd_cc_library(
"@capnp-cpp//src/kj:kj-async",
"@capnp-cpp//src/kj/compat:kj-brotli",
"@capnp-cpp//src/kj/compat:kj-gzip",
"@com_cloudflare_lol_html//:lolhtml",
] + select({
":set_enable_experimental_webgpu": ["@dawn"],
"//conditions:default": [],
Expand Down
21 changes: 19 additions & 2 deletions src/workerd/jsg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ wd_cc_library(
deps = [
":rtti_capnp",
":jsg",
# todo: move text encoding out
"@capnp-cpp//src/capnp:capnpc",
],
)

wd_cc_library(
name = "macro-meta",
hdrs = ["macro-meta.h"],
visibility = ["//visibility:public"],
)

wd_cc_capnp_library(
name = "modules_capnp",
srcs = ["modules.capnp"],
Expand All @@ -106,17 +110,30 @@ wd_cc_library(
["*-test.c++"],
exclude = [
# defined below
"macro-meta-test.c++",
"resource-test.c++",
"rtti-test.c++",
],
)]

# Moved out as macro-meta-test does not depend on V8 or JSG proper, this makes the test much
# smaller.
kj_test(
src = "macro-meta-test.c++",
tags = ["no-arm64"],
deps = [
":macro-meta",
],
)

kj_test(
src = "rtti-test.c++",
tags = ["no-arm64"],
deps = [
":rtti",
":rtti_test_capnp",
# todo: move text encoding out
"@capnp-cpp//src/capnp:capnpc",
],
)

Expand Down
4 changes: 3 additions & 1 deletion src/workerd/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ wd_cc_binary(
":server",
":workerd-meta_capnp",
":workerd_capnp",
"@capnp-cpp//src/capnp:capnpc",
] + select({
"@platforms//os:windows": [],
"//conditions:default": ["@workerd//src/workerd/util:symbolizer"],
Expand Down Expand Up @@ -93,9 +94,10 @@ wd_cc_library(
deps = [
":alarm-scheduler",
":workerd_capnp",
"//src/workerd/api:html-rewriter",
"//src/workerd/api:rtti",
"//src/workerd/io",
"//src/workerd/jsg",
"@capnp-cpp//src/capnp:capnpc",
],
)

Expand Down
3 changes: 2 additions & 1 deletion src/workerd/tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ load("//:build/wd_cc_library.bzl", "wd_cc_library")
wd_cc_library(
name = "api_encoder_lib",
deps = [
"//src/workerd/api:html-rewriter",
"//src/workerd/io",
"//src/workerd/jsg",
"//src/workerd/jsg:rtti",
"@capnp-cpp//src/capnp:capnpc",
"@capnp-cpp//src/capnp",
],
)

Expand Down
Loading