diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..aa8cb63 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +bcr/** text eol=lf diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 9f9ed85..f1a98e7 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -116,10 +116,12 @@ jobs: path: artifacts/x86_64-windows-gnu/watchman.exe if-no-files-found: error - build-windows-host: - name: Build Windows binary on Windows + smoke-windows-msvc: + name: Smoke test (x86_64-windows-msvc) runs-on: windows-2022 timeout-minutes: 120 + env: + USE_BAZEL_VERSION: 9.2.0 steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 @@ -127,11 +129,46 @@ jobs: with: bazelisk-cache: true cache-save: ${{ github.event_name != 'pull_request' }} - disk-cache: ${{ github.workflow }}-windows-x64 + disk-cache: ${{ github.workflow }}-windows-msvc repository-cache: true - - name: Build Windows distribution - run: bazel build //:watchman-x86_64-windows-gnu + - name: Build and smoke test with MSVC + shell: pwsh + run: | + $registry = "file:///" + $env:GITHUB_WORKSPACE.Replace("\", "/") + "/bcr" + $bazelArgs = @( + "--registry=$registry" + "--registry=https://bcr.bazel.build" + "--incompatible_autoload_externally=+@rules_cc" + ) + + Push-Location tests/bcr + try { + bazel build @bazelArgs "@watchman//:watchman" + if ($LASTEXITCODE -ne 0) { + throw "MSVC build failed with code $LASTEXITCODE" + } + + $outputs = bazel cquery @bazelArgs --output=files "@watchman//:watchman" + if ($LASTEXITCODE -ne 0) { + throw "MSVC output query failed with code $LASTEXITCODE" + } + + $relativeBinary = @($outputs | Where-Object { $_ -like "*.exe" }) + if ($relativeBinary.Count -ne 1) { + throw "expected one Watchman executable, got $($relativeBinary.Count)" + } + + $executionRoot = bazel info execution_root + if ($LASTEXITCODE -ne 0) { + throw "Bazel execution-root query failed with code $LASTEXITCODE" + } + $watchman = Join-Path $executionRoot $relativeBinary[0] + } finally { + Pop-Location + } + + ./tests/watchman_smoke_test.ps1 -Watchman $watchman smoke: name: Smoke test (${{ matrix.triple }}) diff --git a/bcr/modules/watchman/2026.07.06.00/overlay/BUILD.bazel b/bcr/modules/watchman/2026.07.06.00/overlay/BUILD.bazel index 92d73f1..31861ee 100644 --- a/bcr/modules/watchman/2026.07.06.00/overlay/BUILD.bazel +++ b/bcr/modules/watchman/2026.07.06.00/overlay/BUILD.bazel @@ -204,9 +204,11 @@ watchman_binary( ["watchman/**/*.h"], exclude = ["watchman/thirdparty/deelevate_binding/**"], ), - copts = [ - "-Wall", - "-Wextra", + copts = select({ + "@rules_cc//cc/compiler:clang-cl": ["/W4"], + "@rules_cc//cc/compiler:msvc-cl": ["/W4"], + "//conditions:default": ["-Wall", "-Wextra"], + }) + [ "-DGLOG_NO_ABBREVIATED_SEVERITIES", "-I.", ] + select({ @@ -302,7 +304,6 @@ watchman_binary( "@folly//folly/chrono:conv", "@folly//folly/concurrency:unbounded_queue", "@folly//folly/concurrency/container:lock_free_ring_buffer", - "@folly//folly/debugging/symbolizer", "@folly//folly/executors:cpu_thread_pool_executor", "@folly//folly/futures:core", "@folly//folly/init", @@ -311,7 +312,6 @@ watchman_binary( "@folly//folly/portability:fcntl", "@folly//folly/portability:filesystem", "@folly//folly/portability:sockets", - "@folly//folly/portability:sys_mman", "@folly//folly/portability:sys_stat", "@folly//folly/portability:sys_time", "@folly//folly/portability:sys_types", @@ -322,6 +322,12 @@ watchman_binary( "@folly//folly/system:thread_name", "@glog", ] + select({ + ":windows": [], + "//conditions:default": [ + "@folly//folly/debugging/symbolizer", + "@folly//folly/portability:sys_mman", + ], + }) + select({ ":linux": ["@openssl//:crypto"], "//conditions:default": [], }), diff --git a/bcr/modules/watchman/2026.07.06.00/patches/watchman-bazel.patch b/bcr/modules/watchman/2026.07.06.00/patches/watchman-bazel.patch index e473b51..5e446e5 100644 --- a/bcr/modules/watchman/2026.07.06.00/patches/watchman-bazel.patch +++ b/bcr/modules/watchman/2026.07.06.00/patches/watchman-bazel.patch @@ -3,7 +3,7 @@ diff --git a/watchman_binary.bzl b/watchman_binary.bzl new file mode 100644 --- /dev/null +++ b/watchman_binary.bzl -@@ -0,0 +1,9 @@ +@@ -0,0 +1,13 @@ +"""Watchman binary rule with required transitive C++ settings.""" + +load("@rules_cc//cc:defs.bzl", "cc_binary") @@ -11,7 +11,11 @@ new file mode 100644 + +_watchman_builder = with_cfg(cc_binary) +_watchman_builder.extend("copt", ["-O2"]) -+_watchman_builder.extend("cxxopt", ["-std=gnu++20"]) ++_watchman_builder.extend("cxxopt", select({ ++ "@rules_cc//cc/compiler:clang-cl": ["/std:c++20", "/utf-8"], ++ "@rules_cc//cc/compiler:msvc-cl": ["/std:c++20", "/utf-8"], ++ "//conditions:default": ["-std=gnu++20"], ++})) +watchman_binary, _watchman_binary_internal = _watchman_builder.build() diff --git a/watchman/ClientContext.h b/watchman/ClientContext.h --- a/watchman/ClientContext.h diff --git a/bcr/modules/watchman/2026.07.06.00/source.json b/bcr/modules/watchman/2026.07.06.00/source.json index 7107b56..079cd51 100644 --- a/bcr/modules/watchman/2026.07.06.00/source.json +++ b/bcr/modules/watchman/2026.07.06.00/source.json @@ -3,7 +3,7 @@ "integrity": "sha256-5G72uY4OpCAe9gPmKOrHgWVXOozEusEsdM2rgTxF+fc=", "strip_prefix": "watchman-2026.07.06.00", "overlay": { - "BUILD.bazel": "sha256-NVQROyGBD58UdLnZLQ0TdTduVYIdHaL8zW+nQvAB9uE=", + "BUILD.bazel": "sha256-NbEbc5UUuRl18tle9i9ht3bi6eC+nR8jh5ruZdW/LGc=", "MODULE.bazel": "sha256-cofDyYwAbnAzhvgElmk6d7CJReE/v45MtgnN4lQJCNg=", "bazel/patches/BUILD.bazel": "sha256-bMzIuyOaQOqAyg7TZ36UZjp0iHUaT9KAqHDuhenE56Q=", "bazel/patches/edencommon-mingw.patch": "sha256-013B4B2vvHTG4aiKntIFuneADC/fIQA+2fxGargtaI4=", @@ -13,6 +13,6 @@ }, "patch_strip": 1, "patches": { - "watchman-bazel.patch": "sha256-ikaVrXCDr8YpYQHPqfUNAwbm7nrlkORtosQL2Z0NG/Q=" + "watchman-bazel.patch": "sha256-U+ckNjBVifZu0d7iXtoCzR4lI6A3yya7QMTnbXIuus8=" } } diff --git a/tests/bcr/BUILD.bazel b/tests/bcr/BUILD.bazel index ffd0fb0..d0d43b3 100644 --- a/tests/bcr/BUILD.bazel +++ b/tests/bcr/BUILD.bazel @@ -1 +1,6 @@ package(default_visibility = ["//visibility:public"]) + +exports_files([ + "folly-windows.patch", + "libevent-windows.patch", +]) diff --git a/tests/bcr/MODULE.bazel b/tests/bcr/MODULE.bazel index 4df4341..7ce7eeb 100644 --- a/tests/bcr/MODULE.bazel +++ b/tests/bcr/MODULE.bazel @@ -4,3 +4,18 @@ bazel_dep( name = "watchman", version = "2026.07.06.00", ) + +# libevent's Windows backend includes event2/rpc.h from event_core, but the +# BCR BUILD file only declares that header on event_extra. +single_version_override( + module_name = "libevent", + patch_strip = 1, + patches = ["//:libevent-windows.patch"], +) + +# Folly's init target only uses its Unix symbolizer on Linux and macOS. +single_version_override( + module_name = "folly", + patch_strip = 1, + patches = ["//:folly-windows.patch"], +) diff --git a/tests/bcr/folly-windows.patch b/tests/bcr/folly-windows.patch new file mode 100644 index 0000000..0a8ea73 --- /dev/null +++ b/tests/bcr/folly-windows.patch @@ -0,0 +1,111 @@ +diff --git a/folly/debugging/symbolizer/BUILD.bazel b/folly/debugging/symbolizer/BUILD.bazel +index 853a9f2..d97ff3a 100644 +--- a/folly/debugging/symbolizer/BUILD.bazel ++++ b/folly/debugging/symbolizer/BUILD.bazel +@@ -32 +31,0 @@ cpp_library( +- "//folly/portability/provide:libdwarf", +@@ -33 +32,4 @@ cpp_library( +- ], ++ ] + select({ ++ "@platforms//os:windows": [], ++ "//conditions:default": ["//folly/portability/provide:libdwarf"], ++ }), +diff --git a/folly/BUILD.bazel b/folly/BUILD.bazel +index d39b8ea..691e80c 100644 +--- a/folly/BUILD.bazel ++++ b/folly/BUILD.bazel +@@ -275,18 +275,11 @@ cmake_configure_file( + defines = [ + "FOLLY_HAVE_LIBGLOG", + "FOLLY_HAVE_LIBGFLAGS", +- "FOLLY_HAVE_PTHREAD", +- "FOLLY_HAVE_PTHREAD_ATFORK", +- "FOLLY_HAVE_PREADV", +- "FOLLY_HAVE_PWRITEV", + "FOLLY_HAVE_CLOCK_GETTIME", + "FOLLY_HAVE_UNALIGNED_ACCESS", + "FOLLY_HAVE_VLA", + "FOLLY_HAVE_WCHAR_SUPPORT", + "HAVE_VSNPRINTF_ERRORS", +- "FOLLY_HAVE_DWARF", +- "FOLLY_HAVE_SWAPCONTEXT", +- "FOLLY_HAVE_BACKTRACE", + "FOLLY_HAVE_SHADOW_LOCAL_WARNINGS", + "FOLLY_HAVE_LIBLZ4", + "FOLLY_HAVE_LIBLZMA", +@@ -298,11 +291,26 @@ cmake_configure_file( + "@platforms//os:windows": [ + # TODO(kgk): What defines should be set here? + ], +- "@platforms//os:macos": [], ++ "@platforms//os:macos": [ ++ "FOLLY_HAVE_BACKTRACE", ++ "FOLLY_HAVE_DWARF", ++ "FOLLY_HAVE_PTHREAD", ++ "FOLLY_HAVE_PTHREAD_ATFORK", ++ "FOLLY_HAVE_PREADV", ++ "FOLLY_HAVE_PWRITEV", ++ "FOLLY_HAVE_SWAPCONTEXT", ++ ], + "@platforms//os:linux": [ + "FOLLY_HAVE_ACCEPT4", ++ "FOLLY_HAVE_BACKTRACE", ++ "FOLLY_HAVE_DWARF", + "FOLLY_HAVE_GETRANDOM", ++ "FOLLY_HAVE_PTHREAD", ++ "FOLLY_HAVE_PTHREAD_ATFORK", ++ "FOLLY_HAVE_PREADV", ++ "FOLLY_HAVE_PWRITEV", + "FOLLY_HAVE_PIPE2", ++ "FOLLY_HAVE_SWAPCONTEXT", + "FOLLY_HAVE_IFUNC", + "FOLLY_HAVE_WEAK_SYMBOLS", + "FOLLY_HAVE_LINUX_VDSO", +@@ -312,11 +320,6 @@ cmake_configure_file( + "FOLLY_USE_SYMBOLIZER", + ], +- }) + select({ +- "@platforms//cpu:x86_64": [ +- "FOLLY_HAVE_EXTRANDOM_SFMT19937", +- ], +- "//conditions:default": [], + }) + select({ + ":with_int128_setting": ["FOLLY_HAVE_INT128_T"], + "//conditions:default": [], + }), +diff --git a/folly/Portability.h b/folly/Portability.h +index f36cb00..fe0184a 100644 +--- a/folly/Portability.h ++++ b/folly/Portability.h +@@ -25,3 +25,8 @@ ++#ifdef _MSC_VER ++#undef FOLLY_HAVE_INT128_T ++#define FOLLY_HAVE_INT128_T 0 ++#endif ++ + #if defined(_MSC_VER) + #define FOLLY_CPLUSPLUS _MSVC_LANG + #else +diff --git a/folly/init/BUILD.bazel b/folly/init/BUILD.bazel +index 8afad13..6d6fd5f 100644 +--- a/folly/init/BUILD.bazel ++++ b/folly/init/BUILD.bazel +@@ -20,6 +20,7 @@ cpp_library( + ] + select({ + "@platforms//os:linux": ["//folly/debugging/symbolizer:signal_handler"], + "@platforms//os:macos": ["//folly/debugging/symbolizer:signal_handler"], ++ "@platforms//os:windows": ["//folly/debugging/symbolizer:signal_handler"], + "//conditions:default": [], + }), + ) +diff --git a/folly/portability/BUILD.bazel b/folly/portability/BUILD.bazel +index 9c3a4b1..c522440 100644 +--- a/folly/portability/BUILD.bazel ++++ b/folly/portability/BUILD.bazel +@@ -293,5 +293,6 @@ cpp_library( + }), + deps = [ ++ ":sys_types", + ":windows", + "//folly:portability", + ], diff --git a/tests/bcr/libevent-windows.patch b/tests/bcr/libevent-windows.patch new file mode 100644 index 0000000..bc11908 --- /dev/null +++ b/tests/bcr/libevent-windows.patch @@ -0,0 +1,12 @@ +diff --git a/BUILD.bazel b/BUILD.bazel +index 96132f1..5fa50fa 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -149,6 +149,7 @@ cc_library( + # arc4random.c is textually included by evutil_rand.c when + # arc4random() is not available. It is not compiled by itself. + "arc4random.c", ++ "include/event2/rpc.h", + ], + visibility = ["//visibility:public"], + deps = [