Skip to content

Commit 501ecec

Browse files
Adam Cozzettecopybara-github
authored andcommitted
Reorganize upb file structure
This change moves almost everything in the `upb/` directory up one level, so that for example `upb/upb/generated_code_support.h` becomes just `upb/generated_code_support.h`. The only exceptions I made to this were that I left `upb/cmake` and `upb/BUILD` where they are, mostly because that avoids conflict with other files and the current locations seem reasonable for now. The `python/` directory is a little bit of a challenge because we had to merge the existing directory there with `upb/python/`. I made `upb/python/BUILD` into the BUILD file for the merged directory, and it effectively loads the contents of the other BUILD file via `python/build_targets.bzl`, but I plan to clean this up soon. PiperOrigin-RevId: 568651768
1 parent 30a7b23 commit 501ecec

454 files changed

Lines changed: 1889 additions & 1854 deletions

File tree

Some content is hidden

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

.github/BUILD.bazel

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,29 @@
66
# of Xcode.
77
xcode_version(
88
name = "version14_2_14C18",
9-
version = "14.2.14C18",
109
aliases = ["14C18"],
1110
default_ios_sdk_version = "16.2",
12-
default_tvos_sdk_version = "16.1",
1311
default_macos_sdk_version = "13.1",
12+
default_tvos_sdk_version = "16.1",
1413
default_watchos_sdk_version = "9.1",
14+
version = "14.2.14C18",
1515
)
1616

1717
xcode_version(
1818
name = "version14_1_0_14B47b",
19-
version = "14.1.0.14B47b",
2019
aliases = ["14B47b"],
2120
default_ios_sdk_version = "16.1",
22-
default_tvos_sdk_version = "16.1",
2321
default_macos_sdk_version = "13.0",
22+
default_tvos_sdk_version = "16.1",
2423
default_watchos_sdk_version = "9.1",
24+
version = "14.1.0.14B47b",
2525
)
2626

2727
xcode_config(
2828
name = "host_xcodes",
29-
versions = [":version14_2_14C18", ":version14_1_0_14B47b"],
3029
default = ":version14_1_0_14B47b",
30+
versions = [
31+
":version14_2_14C18",
32+
":version14_1_0_14B47b",
33+
],
3134
)

.github/workflows/test_python.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
version: ["3.8", "3.9", "3.10", "3.11" ]
2121
include:
2222
- type: Pure
23-
targets: //python/... //upb/python/... //python:python_version_test
23+
targets: //python/... //python:python_version_test
2424
flags: --define=use_fast_cpp_protos=false
2525
- type: C++
2626
targets: //python/... //python:python_version_test
@@ -46,6 +46,7 @@ jobs:
4646
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
4747
bazel-cache: python_linux/${{ matrix.type }}_${{ matrix.version }}
4848
bazel: test ${{ matrix.targets }} ${{ matrix.flags }} --test_env=KOKORO_PYTHON_VERSION
49+
exclude-targets: -//python/pb_unit_tests/...
4950

5051

5152
macos:
@@ -57,7 +58,7 @@ jobs:
5758
version: [ "3.11" ]
5859
include:
5960
- type: Pure
60-
targets: //python/... //upb/python/... //python:python_version_test
61+
targets: //python/... //python:python_version_test
6162
- type: C++
6263
targets: //python/... //python:python_version_test
6364
flags: --define=use_fast_cpp_protos=true
@@ -95,3 +96,4 @@ jobs:
9596
test ${{ matrix.targets }} ${{ matrix.flags }}
9697
--test_env=KOKORO_PYTHON_VERSION=${{ matrix.version }}
9798
--macos_minimum_os=10.9
99+
exclude-targets: -//python/pb_unit_tests/...

.github/workflows/test_upb.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
- { name: "Fastbuild" }
2121
- { name: "Optimized", flags: "-c opt" }
2222
- { 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/..." }
23+
- { name: "ASAN", flags: "--config=asan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/..." }
24+
- { name: "UBSAN", flags: "--config=ubsan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/... -//lua/..." }
25+
- { name: "32-bit", flags: "--copt=-m32 --linkopt=-m32", exclude-targets: "-//benchmarks:benchmark -//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 //bazel/... //benchmarks/... //lua/... //protos/... //protos_generator/... //python/... //upb/... //upbc/... ${{ matrix.config.flags }}
4343
exclude-targets: ${{ matrix.config.exclude-targets }}
4444

4545
linux-gcc:
@@ -58,7 +58,7 @@ jobs:
5858
image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-6.3.0-63dd26c0c7a808d92673a3e52e848189d4ab0f17"
5959
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
6060
bazel-cache: "upb-bazel-gcc"
61-
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt //upb/...
61+
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt //bazel/... //benchmarks/... //lua/... //protos/... //protos_generator/... //python/... //upb/... //upbc/...
6262

6363
windows:
6464
strategy:
@@ -75,7 +75,8 @@ jobs:
7575
with:
7676
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
7777
bazel-cache: "upb-bazel-windows"
78-
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/... //upbc/... //python/... //protos/... //protos_generator/...
79+
exclude-targets: -//python:conformance_test -//upb:def_builder_test
7980

8081
macos:
8182
strategy:
@@ -96,7 +97,7 @@ jobs:
9697
with:
9798
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
9899
bazel-cache: "upb-bazel-macos"
99-
bazel: ${{ matrix.config.bazel-command }} --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 ${{ matrix.config.flags }} //upb/...
100+
bazel: ${{ matrix.config.bazel-command }} --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 ${{ matrix.config.flags }} //bazel/... //benchmarks/... //lua/... //protos/... //protos_generator/... //python/... //upb/... //upbc/...
100101

101102
no-python:
102103
strategy:
@@ -118,7 +119,7 @@ jobs:
118119
which python3 &&
119120
mv `which python3` /tmp &&
120121
! which python3 &&
121-
bazel test $BAZEL_FLAGS --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //upb/python/... -- -//upb/python/dist:source_wheel
122+
bazel test $BAZEL_FLAGS --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //python/... -- -//python/dist:source_wheel
122123
123124
build_wheels:
124125
name: Build Wheels
@@ -135,7 +136,7 @@ jobs:
135136
image: us-docker.pkg.dev/protobuf-build/release-containers/linux/apple@sha256:b3dc9b75d8e599b0e95ed245d89f44b5a4231112f975da89dd02006a484a58df
136137
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
137138
bazel-cache: upb-bazel-python
138-
bazel: build --crosstool_top=//toolchain:clang_suite --//toolchain:release=true --symlink_prefix=/ -c dbg //upb/python/dist //upb/python/dist:test_wheel //upb/python/dist:source_wheel
139+
bazel: build --crosstool_top=//toolchain:clang_suite --//toolchain:release=true --symlink_prefix=/ -c dbg //python/dist //python/dist:test_wheel //python/dist:source_wheel
139140
- name: Move Wheels
140141
run: mkdir wheels && find _build/out \( -name 'protobuf*.whl' -o -name 'protobuf-*.tar.gz' \) -exec mv '{}' wheels ';'
141142
- uses: actions/upload-artifact@v3
@@ -146,7 +147,7 @@ jobs:
146147
with:
147148
name: requirements
148149
# Tests shouldn't have access to the whole upb repo, upload the one file we need
149-
path: upb/python/requirements.txt
150+
path: python/requirements.txt
150151

151152
test_wheels:
152153
name: Test Wheels

BUILD.bazel

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Bazel (https://bazel.build/) BUILD file for Protobuf.
22

33
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
4+
load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_library")
45
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
56
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
6-
load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_library")
77
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
88
load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library", "internal_ruby_proto_library")
99

@@ -153,8 +153,8 @@ filegroup(
153153
internal_ruby_proto_library(
154154
name = "well_known_ruby_protos",
155155
srcs = [":well_known_protos"],
156-
includes = ["src"],
157156
default_runtime = "",
157+
includes = ["src"],
158158
visibility = [
159159
"//conformance:__pkg__",
160160
"//ruby:__subpackages__",
@@ -182,14 +182,14 @@ cc_binary(
182182
cc_binary(
183183
name = "protoc_static",
184184
copts = COPTS,
185-
linkopts = LINK_OPTS,
186185
features = select({
187-
# This isn't possible on mac because there is no static library for lcrt0.o
188-
"@platforms//os:osx": [],
189-
"//build_defs:config_osx": [],
190-
# When cross-compiling we need to statically link all C++ libraries.
191-
"//conditions:default": ["fully_static_link"],
186+
# This isn't possible on mac because there is no static library for lcrt0.o
187+
"@platforms//os:osx": [],
188+
"//build_defs:config_osx": [],
189+
# When cross-compiling we need to statically link all C++ libraries.
190+
"//conditions:default": ["fully_static_link"],
192191
}),
192+
linkopts = LINK_OPTS,
193193
visibility = ["//visibility:public"],
194194
deps = ["//src/google/protobuf/compiler:protoc_lib"],
195195
)
@@ -201,9 +201,9 @@ cc_binary(
201201
# Expose the runtime for the proto_lang_toolchain so that it can also be used in
202202
# a user-defined proto_lang_toolchain.
203203
alias(
204-
name = "protobuf_nowkt",
205-
actual = "//src/google/protobuf:protobuf_nowkt",
206-
visibility = ["//visibility:public"],
204+
name = "protobuf_nowkt",
205+
actual = "//src/google/protobuf:protobuf_nowkt",
206+
visibility = ["//visibility:public"],
207207
)
208208

209209
# The "lite" runtime works for .proto files that specify the option:
@@ -302,13 +302,13 @@ alias(
302302
alias(
303303
name = "python_srcs",
304304
actual = "//python:python_srcs",
305-
visibility = ["//upb:__subpackages__"],
305+
visibility = ["//python:__subpackages__"],
306306
)
307307

308308
alias(
309309
name = "python_test_srcs",
310310
actual = "//python:python_test_srcs",
311-
visibility = ["//upb:__subpackages__"],
311+
visibility = ["//python:__subpackages__"],
312312
)
313313

314314
alias(
@@ -545,11 +545,11 @@ internal_ruby_proto_library(
545545
# The above must come first.
546546
"src",
547547
],
548-
deps = [":well_known_ruby_protos"],
549548
visibility = [
550549
"//conformance:__pkg__",
551550
"//ruby:__subpackages__",
552551
],
552+
deps = [":well_known_ruby_protos"],
553553
)
554554

555555
filegroup(

WORKSPACE

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ ruby_bundle(
107107
gemfile = "//ruby:Gemfile",
108108
)
109109

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

112112
upb_deps()
113113

114114
http_archive(
115115
name = "lua",
116-
build_file = "//upb/bazel:lua.BUILD",
116+
build_file = "//bazel:lua.BUILD",
117117
sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b",
118118
strip_prefix = "lua-5.2.4",
119119
urls = [
@@ -134,11 +134,11 @@ http_archive(
134134
urls = ["https://github.com/googleapis/googleapis/archive/30ed2662a85403cbdeb9ea38df1e414a2a276b83.zip"],
135135
strip_prefix = "googleapis-30ed2662a85403cbdeb9ea38df1e414a2a276b83",
136136
sha256 = "4dfc28101127d22abd6f0f6308d915d490c4594c0cfcf7643769c446d6763a46",
137-
build_file = "//upb/benchmarks:BUILD.googleapis",
137+
build_file = "//benchmarks:BUILD.googleapis",
138138
patch_cmds = ["find google -type f -name BUILD.bazel -delete"],
139139
)
140140

141-
load("//upb/bazel:system_python.bzl", "system_python")
141+
load("//bazel:system_python.bzl", "system_python")
142142

143143
system_python(
144144
name = "system_python",
@@ -149,7 +149,7 @@ load("@system_python//:pip.bzl", "pip_parse")
149149

150150
pip_parse(
151151
name = "pip_deps",
152-
requirements = "//upb/python:requirements.txt",
152+
requirements = "//python:requirements.txt",
153153
)
154154

155155
load("@pip_deps//:requirements.bzl", "install_deps")
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ upb_amalgamation = rule(
5454
"_amalgamator": attr.label(
5555
executable = True,
5656
cfg = "exec",
57-
default = "//upb/bazel:amalgamate",
57+
default = "//bazel:amalgamate",
5858
),
5959
"prefix": attr.string(
6060
default = "",
File renamed without changes.

0 commit comments

Comments
 (0)