Skip to content

Build failure when depending on target in // #31

Open

Description

@AustinSchuh

When I depend on a target in the root package, I get an annoying build failure.

doxygen(    
    name = "doxygen",                                                                                                                                                                                                                                                                                                                                 
    srcs = [                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
        "//:LICENSE.md",                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    ],                                                                                                                                                                                                                                                                                                                                                           
    outs = ["html"],    
    doxyfile_template = "Doxyfile",                                                                                                                                                                                                                                                                                                                              
    exclude = "wpiutil/src/main/native/resources/wpilib-128.png docs/theme.css",                                                                                                                                                                                                                                                           
    html_extra_stylesheet = "docs/theme.css",                                                                                                                                                                                                                                                                                                              
    project_logo = "wpiutil/src/main/native/resources/wpilib-128.png",                                                                                                                                                                                                                                                                                         
    project_name = "WPILibC++",                                                                                                                                                                                                                                                                                              
    project_number = "$(WPILIB_VERSION)",                                                                                                                                                                                                                                                                                                         
    strip_from_inc_path = paths,    
    strip_from_path = paths,                                                                                                                                                                                                                                                                                  
    target_compatible_with = select({                                                                                                                                                                                                                                                                                          
        "@platforms//cpu:x86_64": [],                                                                                                                                                                                                                                                                                            
        "//conditions:default": ["@platforms//:incompatible"],                                                                                                                                                                                                                                                                                       
    }),                                                                                                                                                                                                                                                                                                                                    
)
austin[3762] server1868-1 (doxygen) ~/local/allwpilib3
$ bazel test -c opt //...
INFO: Analyzed 1176 targets (36 packages loaded, 6482 targets configured).
ERROR: /home/austin/local/allwpilib3/docs/BUILD.bazel:55:8: Building doxygen documentation for rule 'doxygen' failed: (Exit 2): doxygen failed: error executing DoxygenBuild command (from target //docs:doxygen) external/doxygen/linux/doxygen bazel-out/k8-opt/bin/docs/Doxyfile

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
/dev/shm/bazel-sandbox.4d3c097c0a97f2da7a46adb4ecfab883763059ef5c0a7cd7d6c5786cd12fe713/linux-sandbox/647/execroot/__main__/bazel-out/k8-opt/bin/docs/Doxyfile:2904: warning: Reached end of file while still inside a (nested) comment. Nesting level 1 (probable line reference: 1044)
/dev/shm/bazel-sandbox.4d3c097c0a97f2da7a46adb4ecfab883763059ef5c0a7cd7d6c5786cd12fe713/linux-sandbox/647/execroot/__main__/external/doxygen/linux/doxygen:259971: warning: the \endcond does not have a corresponding \cond in this file
input buffer overflow, can't enlarge buffer because scanner uses REJECT
    lexical analyzer: /mnt/hgfs/dimitri/doxygen.git/src/pre.l (for: /dev/shm/bazel-sandbox.4d3c097c0a97f2da7a46adb4ecfab883763059ef5c0a7cd7d6c5786cd12fe713/linux-sandbox/647/execroot/__main__/external/doxygen/linux/doxygen)

INFO: Elapsed time: 1.512s, Critical Path: 1.13s
INFO: 5 processes: 13216 action cache hit, 5 internal.
ERROR: Build did NOT complete successfully

Digging in, this is because . gets added to the inputs path, which then tries to parse external/doxygen and overflows the input buffer.

I fixed it by copying the file out of //, but it would be wonderful if either the rule exploded when I did it, or if it handled it correctly.

wpilibsuite/allwpilib#8157 has the full change (with workaround).

Activity

  1. TendTo commented on Aug 5, 2025

    @TendTo
    Owner

    Hi, thanks for the detailed report.
    I was able to reproduce the issue thanks to your pointer.
    It is not a problem I had encountered before, but it makes complete sense.

    As for the solution, I'm not sure if it something that can be fixed without dangerously limiting other valid potential use cases. But a possible simpler workaround would be to use the exclude_patterns configuration property doxygen exposes. You can add more paths you know doxygen has no business investigating.
    Using the following modified docs/BUILD.bazel file to build the documentation in your project seems to work:

    load("@doxygen//:doxygen.bzl", "doxygen")
    load("@rules_jvm_external//:defs.bzl", "maven_export")
    load("@rules_pkg//:pkg.bzl", "pkg_zip")
    
    paths = [
       "apriltag/src/main/native/include",
       "cameraserver/src/generated/main/native/include",
       "cameraserver/src/main/native/include",
       "cscore/src/main/native/include",
       "hal/src/main/native/include",
       "ntcore/src/main/native/include",
       "romiVendordep/src/generated/main/native/include",
       "romiVendordep/src/main/native/include",
       "wpilibNewCommands/src/generated/main/native/include",
       "wpilibNewCommands/src/main/native/include",
       "wpilibc/src/generated/main/native/include",
       "wpilibc/src/main/native/include",
       "wpimath/src/main/native/include",
       "wpinet/src/main/native/include",
       "wpiutil/src/main/native/include",
       "wpiutil/src/main/native/thirdparty/argparse/include",
       "wpiutil/src/main/native/thirdparty/debugging/include",
       "wpiutil/src/main/native/thirdparty/expected/include",
       "wpiutil/src/main/native/thirdparty/fmtlib/include",
       "wpiutil/src/main/native/thirdparty/json/include",
       "wpiutil/src/main/native/thirdparty/llvm/include",
       "wpiutil/src/main/native/thirdparty/mpack/include",
       "wpiutil/src/main/native/thirdparty/nanopb/include",
       "wpiutil/src/main/native/thirdparty/protobuf/include",
       "wpiutil/src/main/native/thirdparty/sigslot/include",
       "xrpVendordep/src/generated/main/native/include",
       "xrpVendordep/src/main/native/include",
    ]
    
    doxygen(
       name = "doxygen",
       srcs = [
           ":theme.css",
           "//:LICENSE.md",
           "//:ThirdPartyNotices.txt",
           "//apriltag:doxygen-files",
           "//cameraserver:doxygen-files",
           "//cscore:doxygen-files",
           "//hal:doxygen-files",
           "//ntcore:doxygen-files",
           "//romiVendordep:doxygen-files",
           "//wpilibNewCommands:doxygen-files",
           "//wpilibc:doxygen-files",
           "//wpimath:doxygen-files",
           "//wpinet:doxygen-files",
           "//wpiutil:doxygen-files",
           "//wpiutil:src/main/native/resources/wpilib-128.png",
           "//xrpVendordep:doxygen-files",
       ],
       outs = ["html"],
       doxyfile_template = "Doxyfile",
       exclude = "wpiutil/src/main/native/resources/wpilib-128.png docs/theme.css",
       exclude_patterns = ["*/external/*"],  # Avoid including external/* in the docs
       html_extra_stylesheet = "docs/theme.css",
       project_logo = "wpiutil/src/main/native/resources/wpilib-128.png",
       project_name = "WPILibC++",
       project_number = "$(WPILIB_VERSION)",
       strip_from_inc_path = paths,
       strip_from_path = paths,
       target_compatible_with = select({
           "@platforms//cpu:x86_64": [],
           "//conditions:default": ["@platforms//:incompatible"],
       }),
       warnings = "NO",
    )
    
    pkg_zip(
       name = "doxygen-zip",
       srcs = [":doxygen"],
       strip_prefix = "html",
    )
    
    maven_export(
       name = "wpilibc_publish",
       maven_coordinates = "edu.wpi.first.wpilibc:documentation:$(WPILIB_VERSION)",
       target = ":doxygen-zip",
       visibility = ["//visibility:public"],
    )
  2. AustinSchuh commented on Aug 10, 2025

    @AustinSchuh
    Author

    Yea, that's what I ended up doing to work around it. Thanks! I filed this bug for 2 reasons.

    1. It would be nice if the ruleset caught this automatically. Not a requirement given there's a workaround.
    2. Hopefully some poor soul running into this issue in the future might stumble across this and save some time.
  3. TendTo commented on Aug 11, 2025

    @TendTo
    Owner

    It makes complete sense. I think I may add a warning (and a flag to disable it) if the rule detects that the path . is used, suggesting including exclude_patterns = ["*/external/*"] to the rule. This will not preclude access to people who may want to use that folder.

  4. AustinSchuh commented on Aug 11, 2025

    @AustinSchuh
    Author

    I like that! That would have saved me a good chunk of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions