Skip to content

Commit 7286ffc

Browse files
acozzettecopybara-github
authored andcommitted
Merge the protobuf and upb Bazel repos
A couple weeks ago we moved upb into the protobuf Git repo, and this change continues the merger of the two repos by making them into a single Bazel repo. This was mostly a matter of deleting upb's WORKSPACE file and fixing up a bunch of references to reflect the new structure. Most of the changes are pretty mechanical, but one thing that needed more invasive changes was the Python script for generating CMakeLists.txt, make_cmakelists.py. The WORKSPACE file it relied on no longer exists with this change, so I updated it to hardcode the information it needed from that file. PiperOrigin-RevId: 564810016
1 parent f175757 commit 7286ffc

File tree

341 files changed

+1978
-2170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

341 files changed

+1978
-2170
lines changed

.bazelignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# These are fetched as external repositories.
22
third_party/abseil-cpp
33
third_party/googletest
4-
# upb is its own Bazel repository for now.
5-
upb/
64
_build/

.github/workflows/test_python.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
version: [ "3.7", "3.8", "3.9", "3.10" ]
2121
include:
2222
- type: Pure
23-
targets: //python/... @upb//python/... //python:python_version
23+
targets: //python/... //upb/python/... //python:python_version
2424
flags: --define=use_fast_cpp_protos=false
2525
- type: C++
2626
targets: //python/... //python:python_version
@@ -57,7 +57,7 @@ jobs:
5757
version: [ "3.10" ]
5858
include:
5959
- type: Pure
60-
targets: //python/... @upb//python/... //python:python_version
60+
targets: //python/... //upb/python/... //python:python_version
6161
- type: C++
6262
targets: //python/... //python:python_version
6363
flags: --define=use_fast_cpp_protos=true

.github/workflows/test_upb.yml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
config:
2020
- { name: "Fastbuild" }
2121
- { name: "Optimized", flags: "-c opt" }
22-
- { name: "FastTable", flags: "--@upb//:fasttable_enabled=true" }
23-
- { name: "ASAN", flags: "--config=asan -c dbg", exclude-targets: "-@upb//benchmarks:benchmark -@upb//python/..." }
24-
- { name: "UBSAN", flags: "--config=ubsan -c dbg", exclude-targets: "-@upb//benchmarks:benchmark -@upb//python/... -@upb//lua/..." }
25-
- { name: "32-bit", flags: "--copt=-m32 --linkopt=-m32", exclude-targets: "-@upb//benchmarks:benchmark -@upb//python/..." }
22+
- { name: "FastTable", flags: "--//upb:fasttable_enabled=true" }
23+
- { name: "ASAN", flags: "--config=asan -c dbg", exclude-targets: "-//upb/benchmarks:benchmark -//upb/python/..." }
24+
- { name: "UBSAN", flags: "--config=ubsan -c dbg", exclude-targets: "-//upb/benchmarks:benchmark -//upb/python/... -//upb/lua/..." }
25+
- { name: "32-bit", flags: "--copt=-m32 --linkopt=-m32", exclude-targets: "-//upb/benchmarks:benchmark -//upb/python/..." }
2626
# TODO: b/297027295 - Add 32-bit ASAN test
2727

2828
name: ${{ matrix.config.name }}
@@ -39,7 +39,7 @@ jobs:
3939
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize@sha256:04cd765285bc52cbbf51d66c8c66d8603579cf0f19cc42df26b09d2c270541fb
4040
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
4141
bazel-cache: upb-bazel
42-
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 @upb//... ${{ matrix.config.flags }}
42+
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //upb/... ${{ matrix.config.flags }}
4343
exclude-targets: ${{ matrix.config.exclude-targets }}
4444

4545
linux-gcc:
@@ -58,12 +58,7 @@ jobs:
5858
image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-6.3.0-518b4fcd8d0ded2484c94f02e835526cacfdac2d"
5959
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
6060
bazel-cache: "upb-bazel-gcc"
61-
# The other test runs use the protobuf workspace. For this one let's
62-
# cd into upb and use its workspace instead, to make sure we cover
63-
# that use case.
64-
bash: >-
65-
cd upb &&
66-
bazel test $BAZEL_FLAGS --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt //...
61+
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt //upb/...
6762

6863
windows:
6964
strategy:
@@ -80,7 +75,7 @@ jobs:
8075
with:
8176
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
8277
bazel-cache: "upb-bazel-windows"
83-
bazel: test --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 @upb//upb/... @upb//upbc/... @upb//python/... @upb//protos/... @upb//protos_generator/...
78+
bazel: test --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 //upb/upb/... //upb/upbc/... //upb/python/... //upb/protos/... //upb/protos_generator/...
8479

8580
macos:
8681
strategy:
@@ -101,7 +96,7 @@ jobs:
10196
with:
10297
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
10398
bazel-cache: "upb-bazel-macos"
104-
bazel: ${{ matrix.config.bazel-command }} --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 ${{ matrix.config.flags }} @upb//...
99+
bazel: ${{ matrix.config.bazel-command }} --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 ${{ matrix.config.flags }} //upb/...
105100

106101
no-python:
107102
strategy:
@@ -123,4 +118,4 @@ jobs:
123118
which python3 &&
124119
mv `which python3` /tmp &&
125120
! which python3 &&
126-
bazel test $BAZEL_FLAGS --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 @upb//python/... -- -@upb//python/dist:source_wheel
121+
bazel test $BAZEL_FLAGS --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //upb/python/... -- -//upb/python/dist:source_wheel

BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,13 @@ alias(
294294
alias(
295295
name = "python_srcs",
296296
actual = "//python:python_srcs",
297-
visibility = ["@upb//:__subpackages__"],
297+
visibility = ["//upb:__subpackages__"],
298298
)
299299

300300
alias(
301301
name = "python_test_srcs",
302302
actual = "//python:python_test_srcs",
303-
visibility = ["@upb//:__subpackages__"],
303+
visibility = ["//upb:__subpackages__"],
304304
)
305305

306306
alias(

WORKSPACE

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ local_repository(
77
path = "examples",
88
)
99

10-
# We will soon merge upb and protobuf into the same Bazel repository, but for
11-
# now we depend on the separate Bazel repo in the upb/ directory. This is
12-
# important to ensure that the CI tests exercise upb at head instead of relying
13-
# on a stale version from protobuf_deps.bzl.
14-
local_repository(
15-
name = "upb",
16-
path = "upb",
17-
)
18-
1910
# Load common dependencies first to ensure we use the correct version
2011
load("//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps")
2112

@@ -116,13 +107,13 @@ ruby_bundle(
116107
gemfile = "//ruby:Gemfile",
117108
)
118109

119-
load("@upb//bazel:workspace_deps.bzl", "upb_deps")
110+
load("//upb/bazel:workspace_deps.bzl", "upb_deps")
120111

121112
upb_deps()
122113

123114
http_archive(
124115
name = "lua",
125-
build_file = "@upb//bazel:lua.BUILD",
116+
build_file = "//upb/bazel:lua.BUILD",
126117
sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b",
127118
strip_prefix = "lua-5.2.4",
128119
urls = [
@@ -143,11 +134,11 @@ http_archive(
143134
urls = ["https://github.com/googleapis/googleapis/archive/30ed2662a85403cbdeb9ea38df1e414a2a276b83.zip"],
144135
strip_prefix = "googleapis-30ed2662a85403cbdeb9ea38df1e414a2a276b83",
145136
sha256 = "4dfc28101127d22abd6f0f6308d915d490c4594c0cfcf7643769c446d6763a46",
146-
build_file = "@upb//benchmarks:BUILD.googleapis",
137+
build_file = "//upb/benchmarks:BUILD.googleapis",
147138
patch_cmds = ["find google -type f -name BUILD.bazel -delete"],
148139
)
149140

150-
load("@upb//bazel:system_python.bzl", "system_python")
141+
load("//upb/bazel:system_python.bzl", "system_python")
151142

152143
system_python(
153144
name = "system_python",
@@ -158,9 +149,9 @@ load("@system_python//:pip.bzl", "pip_parse")
158149

159150
pip_parse(
160151
name = "pip_deps",
161-
requirements = "@upb//python:requirements.txt",
152+
requirements = "//upb/python:requirements.txt",
162153
requirements_overrides = {
163-
"3.11": "@upb//python:requirements_311.txt",
154+
"3.11": "//upb/python:requirements_311.txt",
164155
},
165156
)
166157

objectivec/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@rules_cc//cc:defs.bzl", "objc_library")
22
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
3-
load("@upb//cmake:build_defs.bzl", "staleness_test")
3+
load("//upb/cmake:build_defs.bzl", "staleness_test")
44
load("//conformance:defs.bzl", "conformance_test")
55
load(":defs.bzl", "objc_proto_camel_case_name")
66

php/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup", "strip_prefix")
66
load("@rules_pkg//:pkg.bzl", "pkg_tar")
7-
load("@upb//cmake:build_defs.bzl", "staleness_test")
7+
load("//upb/cmake:build_defs.bzl", "staleness_test")
88
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
99
load("//conformance:defs.bzl", "conformance_test")
1010
load("//:protobuf_version.bzl", "PROTOBUF_PHP_VERSION", "PROTOC_VERSION")
@@ -85,14 +85,14 @@ conformance_test(
8585

8686
genrule(
8787
name = "copy_php_amalgamation_h",
88-
srcs = ["@upb//:php-upb.h"],
88+
srcs = ["//upb:php-upb.h"],
8989
outs = ["generated-in/ext/google/protobuf/php-upb.h"],
9090
cmd = "cp $< $@",
9191
)
9292

9393
genrule(
9494
name = "copy_php_amalgamation_c",
95-
srcs = ["@upb//:php-upb.c"],
95+
srcs = ["//upb:php-upb.c"],
9696
outs = ["generated-in/ext/google/protobuf/php-upb.c"],
9797
cmd = "cp $< $@",
9898
)

python/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal_py_proto_library(
4646
srcs_version = "PY2AND3",
4747
visibility = [
4848
"//:__pkg__",
49-
"@upb//:__subpackages__",
49+
"//upb:__subpackages__",
5050
],
5151
)
5252

@@ -152,7 +152,7 @@ py_library(
152152
srcs_version = "PY2AND3",
153153
visibility = [
154154
"//:__pkg__",
155-
"@upb//:__subpackages__",
155+
"//upb:__subpackages__",
156156
],
157157
)
158158

@@ -170,7 +170,7 @@ py_library(
170170
srcs_version = "PY3",
171171
visibility = [
172172
"//:__pkg__",
173-
"@upb//:__subpackages__",
173+
"//upb:__subpackages__",
174174
],
175175
)
176176

@@ -437,7 +437,7 @@ pkg_files(
437437
"tox.ini",
438438
],
439439
strip_prefix = "",
440-
visibility = ["@upb//:__subpackages__"],
440+
visibility = ["//upb:__subpackages__"],
441441
)
442442

443443
pkg_files(

python/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ If for some reason you wish to build the packages directly from this repo, you
2121
can use the following Bazel commands:
2222

2323
```
24-
$ bazel build @upb//python/dist:source_wheel
25-
$ bazel build @upb//python/dist:binary_wheel
24+
$ bazel build //upb/python/dist:source_wheel
25+
$ bazel build //upb/python/dist:binary_wheel
2626
```
2727

2828
The binary wheel will build against whatever version of Python is installed on
@@ -49,7 +49,7 @@ following values:
4949
better performance than any of the previous backends, and it is now the
5050
default. It is distributed in our PyPI packages, and requires no special
5151
installation. The code for this module lives in
52-
[@upb/python](https://github.com/protocolbuffers/upb/tree/main/python).
52+
[upb/python](https://github.com/protocolbuffers/protobuf/tree/main/upb/python).
5353
1. **cpp**: This extension module wraps the C++ protobuf library. It is
5454
deprecated and is no longer released in our PyPI packages, however it is
5555
still used in some legacy cases where apps want to perform zero-copy message

python/google/protobuf/internal/numpy/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ internal_py_test(
1818
],
1919
visibility = [
2020
"//python:__pkg__",
21-
"@upb//python/pb_unit_tests:__pkg__",
21+
"//upb/python/pb_unit_tests:__pkg__",
2222
]
2323
)

0 commit comments

Comments
 (0)