Files
zeekay d9c73505fa Finish build-system rebrand (capnp->zap) and fix whitespace-desugar bugs
Build system (autotools/CMake/Bazel) capnp->zap rebrand completed so the
c++/ tree configures cleanly: `autoreconf -i && ./configure` succeeds,
emitting Makefile, all zap*.pc / kj*.pc and the Zap CMake config. configure.ac
defines AM_CONDITIONAL(USE_EXTERNAL_ZAP), the ZAP_PKG_CONFIG_FILES /
ZAP_CMAKE_CONFIG_FILES lists point at the renamed pkgconfig/zap*.pc.in and
cmake/Zap*.cmake.in, and Makefile.am's `if USE_EXTERNAL_ZAP` matches. Bazel
loads @zap-cpp//src/zap:cc_zap_library.bzl. Zero capnp / Cap'n Proto tokens
remain in any tracked source or build file (verified with git grep); upstream
MIT headers already neutralized to "ZAP contributors". quick-test.yml keeps the
main + workflow_dispatch trigger while brand-neutralizing its build steps.

Whitespace-significant schema desugar (compiler/desugar.c++) — fix three HIGH
correctness bugs and make the preprocessor total:

  * Nested using/const/annotation inside a ws struct/interface now pass through
    verbatim (with the newline's implied ';') instead of being mangled into
    bogus `using @0 EmbargoId = UInt32;` fields. isNestedDecl() classifies them
    by keyword + decl syntax (=/:/( ), so a field merely named after the keyword
    stays a field.
  * Ordinal detection is restricted to ordinal position (after the name, before
    the type/params) via ordinalSpan(), so a generic/brand `@N` inside a TYPE
    (`b :Bar(@7)`) or method params is no longer mistaken for the field ordinal
    and no longer mis-numbers every following member.
  * Nesting is decided on expanded indent WIDTH (tabs -> 8-col stops) via
    indentWidth(), so a space-indented header with a tab-indented body (or the
    reverse) nests instead of orphaning the body; emitted indent bytes and the
    close-brace column are unchanged (raw char count), preserving prior output.
  * Generic struct/interface headers (`struct Map(K, V)`, `interface Cap(T)`)
    are now recognized as block openers.
  * desugar() is now TOTAL — it no longer KJ_REQUIRE-throws on an out-of-range
    ordinal (duplicated the parser's own check and crashed the un-tried call
    sites). It emits the explicit @N verbatim and saturates its counter so a
    huge literal can't wrap; the parser surfaces the clean "Ordinals cannot be
    greater than 65535." diagnostic at the right file:line:col. Removed the now
    redundant validateAutoOrdinal and the dead kj/debug.h include. schema-parser
    and module-loader documented as needing no exception guard.

desugar-test.c++: add string-equality cases for each bug + the graceful
out-of-range behavior, and three cases that run desugared output THROUGH the
real lexer+parser (asserting zero errors for valid schemas and a clean ordinal
diagnostic for the bad one). Brace back-compat proven byte-identical over the
18-file corpus; sample.ws.zap still desugars to sample.brace.zap exactly.
2026-06-20 00:02:20 -07:00

89 lines
3.8 KiB
Plaintext

common --enable_platform_specific_config
# Needed for Brotli, which does not import rules_cc symbols itself (otherwise needed with Bazel 9)
common --incompatible_autoload_externally=+cc_library,+cc_binary
# Debug build configuration with maximum runtime checks
build:dbg -c dbg
build:dbg --config=max-debug-info
build:dbg --//src/kj:debug_memory=True
# use this config for maximum possible debug information
build:max-debug-info --copt='-g3'
build:max-debug-info --copt='-fno-omit-frame-pointer'
build:max-debug-info --copt='-mno-omit-leaf-frame-pointer'
# Opt build
build:opt -c opt
build:opt --copt='-O3'
build:opt --linkopt="-Wl,-O3"
build:thin-lto --config=opt
build:thin-lto --cxxopt='-flto=thin'
build:thin-lto --linkopt='-flto=thin'
build:thin-lto --dynamic_mode=off
build:profile --config=thin-lto
build:unix --cxxopt='-std=c++23' --host_cxxopt='-std=c++23' --force_pic --verbose_failures
build:unix --cxxopt='-Wall'
build:unix --cxxopt='-Wextra'
build:unix --cxxopt='-Wunreachable-code'
build:unix --cxxopt='-Wsuggest-override'
build:unix --cxxopt='-Wno-strict-aliasing' --host_cxxopt='-Wno-strict-aliasing'
build:unix --cxxopt='-Wno-sign-compare' --host_cxxopt='-Wno-sign-compare'
build:unix --cxxopt='-Wno-unused-parameter' --host_cxxopt='-Wno-unused-parameter'
build:unix --cxxopt='-DKJ_HEADER_WARNINGS'
build:unix --cxxopt='-DZAP_HEADER_WARNINGS'
# enable libdl integration for stacktrace symbolization
build:unix --//src/kj:libdl=True
# I needed these magic spells to build locally with clang-11 and clang-12 on Ubuntu. clang-13 and up
# work out-of-the-box.
# TODO(2.0): Remove this when we support g++ again.
build:linux --cxxopt=-stdlib=libc++ --host_cxxopt=-stdlib=libc++
build:linux --linkopt='-stdlib=libc++' --host_linkopt='-stdlib=libc++'
# Drop default link flags, which include libstdc++ for Linux
build:linux --features=-default_link_libs --host_features=-default_link_libs
build:linux --linkopt='-lc++' --linkopt='-lm'
build:linux --host_linkopt='-lc++' --host_linkopt='-lm'
# Limit recursive header includes within libc++. This improves compliance with IWYU, helps avoid
# errors with downstream projects that implicitly define this already and reduces total include size.
https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html
build:unix --cxxopt=-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES
build:unix --host_cxxopt=-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES
build:linux --config=unix
build:macos --config=unix
# See https://bazel.build/configure/windows#symlink
startup --windows_enable_symlinks
# We use LLVM's MSVC-compatible compiler driver to compile our code on Windows under Bazel. MSVC is
# natively supported when using CMake builds.
build:windows --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl
build:windows --extra_execution_platforms=//:x64_windows-clang-cl
build:windows --cxxopt='/std:c++23preview' --host_cxxopt='/std:c++23preview' --verbose_failures
# The `/std:c++23preview` argument is unused during boringssl compilation and we don't
# want a warning when compiling each file.
build:windows --cxxopt='-Wno-unused-command-line-argument' --host_cxxopt='-Wno-unused-command-line-argument'
# MSVC disappointingly sets __cplusplus to 199711L by default. Defining /Zc:__cplusplus makes it
# set the correct value.
build:windows --cxxopt='/Zc:__cplusplus' --host_cxxopt='/Zc:__cplusplus'
# build with ssl, zlib and bazel by default
build --//src/kj:openssl=True
build --//src/kj:zlib=True
build --//src/kj:brotli=True
build:sanitizers-common --copt="-Og"
build:sanitizers-common --copt="-fno-optimize-sibling-calls"
build:sanitizers-common --config=max-debug-info
# sanitizers often do work on shutdown, do it cleanly
build:sanitizers-common --test_env=KJ_CLEAN_SHUTDOWN=1
build:asan --config=sanitizers-common
build:asan --copt="-fsanitize=address" --linkopt="-fsanitize=address"
build:asan --test_env=ASAN_OPTIONS=abort_on_error=1