Skip to content

Commit d260ab3

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Add windows CI
PiperOrigin-RevId: 520478558
1 parent c642e43 commit d260ab3

File tree

14 files changed

+69
-49
lines changed

14 files changed

+69
-49
lines changed

.bazelrc

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ build --features=-debug_prefix_map_pwd_is_dot
33

44
# Pin to C++17
55
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
6+
build:cpp17_msvc --cxxopt=/std:c++17 --host_cxxopt=/std:c++17
67

78
# Use our custom-configured c++ toolchain.
89

.github/workflows/bazel_tests.yml

+37-33
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ jobs:
2020
fail-fast: false # Don't cancel all jobs if one fails.
2121
matrix:
2222
include:
23-
# Temporarily disabled until Copybara fixes its cap of 30 jobs per PR.
24-
# - { NAME: "Fastbuild", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "" }
25-
# - { NAME: "Optmized", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "-c opt" } # Some warnings only fire with -c opt
23+
- { NAME: "Fastbuild", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "" }
24+
- { NAME: "Optmized", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "-c opt" } # Some warnings only fire with -c opt
2625
- { NAME: "GCC Optimized", BAZEL: bazel, CC: gcc-12, os: ubuntu-22.04, flags: "-c opt" }
2726
- { NAME: "FastTable", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--//:fasttable_enabled=true -- -cmake:test_generated_files" }
2827
- { NAME: "ASAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=asan -c dbg -- -benchmarks:benchmark -python/..." }
2928
- { NAME: "UBSAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=ubsan -c dbg -- -benchmarks:benchmark -python/... -lua/...", install: "libunwind-dev" }
3029
- { NAME: "32-bit", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--copt=-m32 --linkopt=-m32 -- -... benchmarks:benchmark ", install: "g++-multilib" }
31-
- { NAME: "macOS", BAZEL: bazel, CC: clang, os: macos-11, flags: "" }
30+
- { NAME: "macOS", BAZEL: bazel, CC: clang, os: macos-11 }
31+
- { NAME: "windows", BAZEL: bazel, os: windows-2019, startup-flags: "--output_user_root=C:/tmp", flags: "--config=cpp17_msvc", targets: "upb/... upbc/... python/... protos/... protos_generator/..." }
3232
# We support two Bazel versions back per https://opensource.google/documentation/policies/cplusplus-support
33-
- { NAME: "Bazel 4.1.0", BAZEL: bazel-4.1.0-linux-x86_64, CC: clang, os: ubuntu-20-large, flags: "" }
34-
- { NAME: "Bazel 5.3.0", BAZEL: bazel-5.3.0-linux-x86_64, CC: clang, os: ubuntu-20-large, flags: "" }
33+
- { NAME: "Bazel 4.1.0", BAZEL: bazel-4.1.0-linux-x86_64, CC: clang, os: ubuntu-20-large }
34+
- { NAME: "Bazel 5.3.0", BAZEL: bazel-5.3.0-linux-x86_64, CC: clang, os: ubuntu-20-large }
3535

3636
name: ${{ matrix.NAME }}
3737

@@ -52,44 +52,48 @@ jobs:
5252
wget -O $FILENAME https://github.com/bazelbuild/bazel/releases/download/$VERSION/${{ matrix.BAZEL }}
5353
chmod a+x $FILENAME
5454
if: ${{ matrix.BAZEL != 'bazel' }}
55-
- name: Check tool versions
56-
run: |
57-
${{ matrix.CC }} --version
58-
${{ matrix.BAZEL }} --version
55+
- name: Check compiler versions
56+
if: matrix.CC
57+
run: ${{ matrix.CC }} --version
58+
- name: Check Bazel versions
59+
run: ${{ matrix.BAZEL }} --version
5960
- id: bazel-cache
6061
name: Set up Bazel caching
6162
uses: ./.github/actions/setup-bazel-cache
6263
- name: Setup Python venv
64+
if: ${{ runner.os != 'Windows' }}
6365
run: rm -rf /tmp/venv && python3 -m venv /tmp/venv && source /tmp/venv/bin/activate && python3 --version
6466
- name: Install dependencies
6567
run: sudo apt update && sudo apt install -y ${{ matrix.install }}
6668
if: matrix.install != ''
6769
- name: Install numpy
68-
run: source /tmp/venv/bin/activate && pip3 install numpy
70+
run: pip3 install numpy
71+
- name: Setup environment variables
72+
if: matrix.CC
73+
run: echo "CC=${{ matrix.CC }}" >> $GITHUB_ENV
6974
- name: Run tests
70-
run: cd ${{ github.workspace }} && source /tmp/venv/bin/activate && CC=${{ matrix.CC }} ${{ matrix.BAZEL }} test --test_output=errors ${{ steps.bazel-cache.outputs.cache_args }} ... ${{ matrix.flags }}
75+
run: cd ${{ github.workspace }} && ${{ matrix.BAZEL }} ${{ matrix.startup-flags }} test --test_output=errors ${{ steps.bazel-cache.outputs.cache_args }} ${{ matrix.targets | "..." }} ${{ matrix.flags }}
7176

72-
# Temporarily disabled until Copybara fixes its cap of 30 jobs per PR.
73-
# no-python:
74-
# runs-on: ubuntu-20-large
77+
no-python:
78+
runs-on: ubuntu-20-large
7579

76-
# strategy:
77-
# fail-fast: false # Don't cancel all jobs if one fails.
80+
strategy:
81+
fail-fast: false # Don't cancel all jobs if one fails.
7882

79-
# name: "No System Python"
83+
name: "No System Python"
8084

81-
# steps:
82-
# - uses: actions/checkout@v2
83-
# - name: Set up Cloud SDK
84-
# uses: google-github-actions/auth@v0
85-
# with:
86-
# credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
87-
# export_environment_variables: true
88-
# if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }}
89-
# - id: bazel-cache
90-
# name: Set up Bazel caching
91-
# uses: ./.github/actions/setup-bazel-cache
92-
# - name: Uninstall python
93-
# run: which python3 && sudo mv `which python3` /tmp && ! which python3
94-
# - name: Run tests
95-
# run: cd ${{ github.workspace }} && bazel test --test_output=errors ${{ steps.bazel-cache.outputs.cache_args }} //python/... -- -//python/dist:source_wheel
85+
steps:
86+
- uses: actions/checkout@v2
87+
- name: Set up Cloud SDK
88+
uses: google-github-actions/auth@v0
89+
with:
90+
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
91+
export_environment_variables: true
92+
if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }}
93+
- id: bazel-cache
94+
name: Set up Bazel caching
95+
uses: ./.github/actions/setup-bazel-cache
96+
- name: Uninstall python
97+
run: which python3 && sudo mv `which python3` /tmp && ! which python3
98+
- name: Run tests
99+
run: cd ${{ github.workspace }} && bazel test --test_output=errors ${{ steps.bazel-cache.outputs.cache_args }} //python/... -- -//python/dist:source_wheel

BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ cc_test(
677677
],
678678
# TODO(b/259158612): fix this test on Windows.
679679
target_compatible_with = select({
680-
"@platforms//os:windows": ["//third_party/bazel_platforms:incompatible"],
680+
"@platforms//os:windows": ["@platforms//:incompatible"],
681681
"//conditions:default": [],
682682
}),
683683
deps = [

cmake/BUILD.bazel

+4
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,9 @@ sh_test(
102102
"//:cmake_files",
103103
"@utf8_range//:utf8_range_srcs",
104104
],
105+
target_compatible_with = select({
106+
"@platforms//os:windows": ["@platforms//:incompatible"],
107+
"//conditions:default": [],
108+
}),
105109
deps = ["@bazel_tools//tools/bash/runfiles"],
106110
)

protos_generator/gen_extensions.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ void WriteExtensionIdentifier(const protobuf::FieldDescriptor* ext,
8484
if (ext->extension_scope()) {
8585
output(
8686
R"cc(
87-
constexpr ::protos::internal::ExtensionIdentifier<$0, $3> $4::$2(&$1);
87+
const ::protos::internal::ExtensionIdentifier<$0, $3> $4::$2(&$1);
8888
)cc",
8989
ContainingTypeName(ext), mini_table_name, ext->name(),
9090
CppTypeParameterName(ext), ClassName(ext->extension_scope()));
9191
} else {
9292
output(
9393
R"cc(
94-
constexpr ::protos::internal::ExtensionIdentifier<$0, $3> $2(&$1);
94+
const ::protos::internal::ExtensionIdentifier<$0, $3> $2(&$1);
9595
)cc",
9696
ContainingTypeName(ext), mini_table_name, ext->name(),
9797
CppTypeParameterName(ext));

python/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pkg_files(
192192
# end:github_only
193193
# begin:google_only
194194
# _message_target_compatible_with = {
195-
# "@platforms//os:windows": ["//third_party/bazel_platforms:incompatible"],
195+
# "@platforms//os:windows": ["@platforms//:incompatible"],
196196
# "//conditions:default": [],
197197
# }
198198
# end:google_only

python/dist/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ pkg_tar(
220220
extension = "tar.gz",
221221
package_dir = "protobuf",
222222
package_file_name = "protobuf.tar.gz",
223+
target_compatible_with = select({
224+
"@system_python//:none": ["@platforms//:incompatible"],
225+
"//conditions:default": [],
226+
}),
223227
)
224228

225229
genrule(
@@ -234,6 +238,10 @@ genrule(
234238
cd ..
235239
mv protobuf/dist/*.tar.gz $@
236240
""",
241+
target_compatible_with = select({
242+
"@system_python//:none": ["@platforms//:incompatible"],
243+
"//conditions:default": [],
244+
}),
237245
)
238246

239247
py_wheel(

python/pb_unit_tests/pyproto_test_wrapper.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def pyproto_test_wrapper(name, deps = []):
3636
# "//net/proto2/python/public:use_upb_protos",
3737
# ],
3838
# target_compatible_with = select({
39-
# "@platforms//os:windows": ["//third_party/bazel_platforms:incompatible"],
39+
# "@platforms//os:windows": ["@platforms//:incompatible"],
4040
# "//conditions:default": [],
4141
# }),
4242
# )

upb/conformance/BUILD

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ cc_binary(
7575
copts = UPB_DEFAULT_COPTS,
7676
data = ["conformance_upb_failures.txt"],
7777
target_compatible_with = select({
78-
"@platforms//os:windows": ["//third_party/bazel_platforms:incompatible"],
78+
"@platforms//os:windows": ["@platforms//:incompatible"],
7979
"//conditions:default": [],
8080
}),
8181
deps = [
@@ -109,7 +109,7 @@ sh_test(
109109
"@com_google_protobuf//conformance:conformance_test_runner",
110110
],
111111
target_compatible_with = select({
112-
"@platforms//os:windows": ["//third_party/bazel_platforms:incompatible"],
112+
"@platforms//os:windows": ["@platforms//:incompatible"],
113113
"//conditions:default": [],
114114
}),
115115
deps = ["@bazel_tools//tools/bash/runfiles"],
@@ -124,7 +124,7 @@ cc_binary(
124124
],
125125
data = ["conformance_upb_failures.txt"],
126126
target_compatible_with = select({
127-
"@platforms//os:windows": ["//third_party/bazel_platforms:incompatible"],
127+
"@platforms//os:windows": ["@platforms//:incompatible"],
128128
"//conditions:default": [],
129129
}),
130130
deps = [

upb/message/accessors.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ UPB_API_INLINE upb_Message* upb_Message_GetOrCreateMutableMessage(
572572
UPB_API_INLINE const upb_Array* upb_Message_GetArray(
573573
const upb_Message* msg, const upb_MiniTableField* field) {
574574
_upb_MiniTableField_CheckIsArray(field);
575-
const upb_Array* ret;
575+
upb_Array* ret;
576576
const upb_Array* default_val = NULL;
577577
_upb_Message_GetNonExtensionField(msg, field, &default_val, &ret);
578578
return ret;
@@ -626,7 +626,7 @@ UPB_API_INLINE bool upb_MiniTableField_IsClosedEnum(
626626
UPB_API_INLINE const upb_Map* upb_Message_GetMap(
627627
const upb_Message* msg, const upb_MiniTableField* field) {
628628
_upb_MiniTableField_CheckIsMap(field);
629-
const upb_Map* ret;
629+
upb_Map* ret;
630630
const upb_Map* default_val = NULL;
631631
_upb_Message_GetNonExtensionField(msg, field, &default_val, &ret);
632632
return ret;

upb/mini_table/decode.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,26 @@ UPB_API upb_MiniTableExtension* _upb_MiniTableExtension_Build(
104104
UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_Build(
105105
const char* data, size_t len, const upb_MiniTable* extendee,
106106
upb_Arena* arena, upb_Status* status) {
107-
upb_MiniTableSub sub = {.submsg = NULL};
107+
upb_MiniTableSub sub;
108+
sub.submsg = NULL;
108109
return _upb_MiniTableExtension_Build(
109110
data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status);
110111
}
111112

112113
UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_BuildMessage(
113114
const char* data, size_t len, const upb_MiniTable* extendee,
114115
upb_MiniTable* submsg, upb_Arena* arena, upb_Status* status) {
115-
upb_MiniTableSub sub = {.submsg = submsg};
116+
upb_MiniTableSub sub;
117+
sub.submsg = submsg;
116118
return _upb_MiniTableExtension_Build(
117119
data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status);
118120
}
119121

120122
UPB_API_INLINE upb_MiniTableExtension* upb_MiniTableExtension_BuildEnum(
121123
const char* data, size_t len, const upb_MiniTable* extendee,
122124
upb_MiniTableEnum* subenum, upb_Arena* arena, upb_Status* status) {
123-
upb_MiniTableSub sub = {.subenum = subenum};
125+
upb_MiniTableSub sub;
126+
sub.subenum = subenum;
124127
return _upb_MiniTableExtension_Build(
125128
data, len, extendee, sub, kUpb_MiniTablePlatform_Native, arena, status);
126129
}

upb/util/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ cc_test(
153153
srcs = ["compare_test.cc"],
154154
# TODO(b/259158757): fix this test on Windows.
155155
target_compatible_with = select({
156-
"@platforms//os:windows": ["//third_party/bazel_platforms:incompatible"],
156+
"@platforms//os:windows": ["@platforms//:incompatible"],
157157
"//conditions:default": [],
158158
}),
159159
deps = [

upbc/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ cc_binary(
290290
],
291291
copts = UPB_DEFAULT_CPPOPTS,
292292
target_compatible_with = select({
293-
"@platforms//os:windows": ["//third_party/bazel_platforms:incompatible"],
293+
"@platforms//os:windows": ["@platforms//:incompatible"],
294294
"//conditions:default": [],
295295
}),
296296
visibility = ["//visibility:public"],

upbc/subprocess.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <cstring>
3535
#include <iostream>
3636

37-
#ifndef _WIN32
37+
#ifndef _MSVC_LANG
3838
#include <errno.h>
3939
#include <signal.h>
4040
#include <sys/select.h>

0 commit comments

Comments
 (0)