kandi background
Explore Kits

bazel | a fast, scalable, multilanguage and extensible build system | Build Tool library

 by   bazelbuild Java Version: 6.0.0-pre.20220411.2 License: Apache-2.0

 by   bazelbuild Java Version: 6.0.0-pre.20220411.2 License: Apache-2.0

Download this library from

kandi X-RAY | bazel Summary

bazel is a Java library typically used in Utilities, Build Tool applications. bazel has a Permissive License and it has high support. However bazel has 3137 bugs, it has 18 vulnerabilities and it build file is not available. You can download it from GitHub.
Build and test software of any size, quickly and reliably.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • bazel has a highly active ecosystem.
  • It has 18479 star(s) with 3386 fork(s). There are 602 watchers for this library.
  • There were 10 major release(s) in the last 6 months.
  • There are 2345 open issues and 7342 have been closed. On average issues are closed in 200 days. There are 184 open pull requests and 0 closed requests.
  • It has a negative sentiment in the developer community.
  • The latest version of bazel is 6.0.0-pre.20220411.2
bazel Support
Best in #Build Tool
Average in #Build Tool
bazel Support
Best in #Build Tool
Average in #Build Tool

quality kandi Quality

  • bazel has 3137 bugs (105 blocker, 12 critical, 1358 major, 1662 minor) and 34552 code smells.
bazel Quality
Best in #Build Tool
Average in #Build Tool
bazel Quality
Best in #Build Tool
Average in #Build Tool

securitySecurity

  • bazel has 1 vulnerability issues reported (0 critical, 1 high, 0 medium, 0 low).
  • bazel code analysis shows 17 unresolved vulnerabilities (16 blocker, 1 critical, 0 major, 0 minor).
  • There are 311 security hotspots that need review.
bazel Security
Best in #Build Tool
Average in #Build Tool
bazel Security
Best in #Build Tool
Average in #Build Tool

license License

  • bazel is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
bazel License
Best in #Build Tool
Average in #Build Tool
bazel License
Best in #Build Tool
Average in #Build Tool

buildReuse

  • bazel releases are available to install and integrate.
  • bazel has no build file. You will be need to create the build yourself to build the component from source.
  • Installation instructions are available. Examples and code snippets are not available.
  • bazel saves you 2068197 person hours of effort in developing the same functionality from scratch.
  • It has 847515 lines of code, 63294 functions and 6202 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
bazel Reuse
Best in #Build Tool
Average in #Build Tool
bazel Reuse
Best in #Build Tool
Average in #Build Tool
Top functions reviewed by kandi - BETA

kandi has reviewed bazel and discovered the below as its top functions. This is intended to give you an instant insight into bazel implemented functionality, and help decide if they suit your requirements.

  • Add legacy features .
  • Execute the given command and return the result .
  • Creates a new target .
  • The binary operator .
  • Parse the member specification arguments .
  • Evaluate a single instruction block .
  • Visit an instruction .
  • Visit a program class .
  • Configures the skyframe execution .
  • Search for cycles .

bazel Key Features

Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Build and run a Qt application on macOS via Bazel

copy iconCopydownload iconDownload
 % bazel build --cxxopt=-std=c++17  //...
 DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path:  /usr/local/opt/qt5
 INFO: Analyzed 14 targets (0 packages loaded, 0 targets configured).
 INFO: Found 14 targets...
 ERROR: /Users/home/Git/my_repo/bazel_rules_qt/tests/qt_qml/BUILD:4:10: Compiling tests/qt_qml/main.cc failed: (Aborted): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' ... (remaining 38 argument(s) skipped)

 Use --sandbox_debug to see verbose messages from the sandbox
 tests/qt_qml/main.cc:1:10: fatal error: 'QtQml/QQmlApplicationEngine' file not found
 #include <QtQml/QQmlApplicationEngine>
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1 error generated.
 Error in child process '/usr/bin/xcrun'. 1
 INFO: Elapsed time: 0,594s, Critical Path: 0,32s
 INFO: 3 processes: 3 internal.
 FAILED: Build did NOT complete successfully
 diff --git a/qt.BUILD b/qt.BUILD
 index 517c8db..8f110b5 100644
 --- a/qt.BUILD
 +++ b/qt.BUILD
 @@ -28,11 +28,12 @@ QT_LIBRARIES = [
      cc_library(
          name = "qt_%s_osx" % name,
          # When being on Windows this glob will be empty
 -        hdrs = glob(["%s/**" % include_folder], allow_empty = True),
 +        hdrs = glob(["include/%s/**" % include_folder], allow_empty = True),
          includes = ["."],
          linkopts = ["-F/usr/local/opt/qt5/lib"] + [
              "-framework %s" % library_name.replace("5", "") # macOS qt libs do not contain a 5 - e.g. instead of Qt5Core the lib is called QtCore
              ],
 +        strip_include_prefix= "include"
          # Available from Bazel 4.0.0
          # target_compatible_with = ["@platforms//os:osx"],
      )
 % bazel build --cxxopt=-std=c++17  //...
 DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path:  /usr/local/opt/qt5
 INFO: Analyzed 14 targets (1 packages loaded, 7422 targets configured).
 INFO: Found 14 targets...
 INFO: Elapsed time: 11,761s, Critical Path: 7,23s
 INFO: 3 processes: 1 internal, 2 darwin-sandbox.
 INFO: Build completed successfully, 3 total actions
 % bazel run --cxxopt=-std=c++17 //tests/qt_resource:main
 DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path:  /usr/local/opt/qt5
 INFO: Analyzed target //tests/qt_resource:main (0 packages loaded, 0 targets configured).
 INFO: Found 1 target...
 Target //tests/qt_resource:main up-to-date:
 bazel-bin/tests/qt_resource/main
 INFO: Elapsed time: 3,657s, Critical Path: 0,00s
 INFO: 1 process: 1 internal.
 INFO: Build completed successfully, 1 total action
 INFO: Build completed successfully, 1 total action
 opened resource file
 file1
-----------------------
 % bazel build --cxxopt=-std=c++17  //...
 DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path:  /usr/local/opt/qt5
 INFO: Analyzed 14 targets (0 packages loaded, 0 targets configured).
 INFO: Found 14 targets...
 ERROR: /Users/home/Git/my_repo/bazel_rules_qt/tests/qt_qml/BUILD:4:10: Compiling tests/qt_qml/main.cc failed: (Aborted): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' ... (remaining 38 argument(s) skipped)

 Use --sandbox_debug to see verbose messages from the sandbox
 tests/qt_qml/main.cc:1:10: fatal error: 'QtQml/QQmlApplicationEngine' file not found
 #include <QtQml/QQmlApplicationEngine>
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1 error generated.
 Error in child process '/usr/bin/xcrun'. 1
 INFO: Elapsed time: 0,594s, Critical Path: 0,32s
 INFO: 3 processes: 3 internal.
 FAILED: Build did NOT complete successfully
 diff --git a/qt.BUILD b/qt.BUILD
 index 517c8db..8f110b5 100644
 --- a/qt.BUILD
 +++ b/qt.BUILD
 @@ -28,11 +28,12 @@ QT_LIBRARIES = [
      cc_library(
          name = "qt_%s_osx" % name,
          # When being on Windows this glob will be empty
 -        hdrs = glob(["%s/**" % include_folder], allow_empty = True),
 +        hdrs = glob(["include/%s/**" % include_folder], allow_empty = True),
          includes = ["."],
          linkopts = ["-F/usr/local/opt/qt5/lib"] + [
              "-framework %s" % library_name.replace("5", "") # macOS qt libs do not contain a 5 - e.g. instead of Qt5Core the lib is called QtCore
              ],
 +        strip_include_prefix= "include"
          # Available from Bazel 4.0.0
          # target_compatible_with = ["@platforms//os:osx"],
      )
 % bazel build --cxxopt=-std=c++17  //...
 DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path:  /usr/local/opt/qt5
 INFO: Analyzed 14 targets (1 packages loaded, 7422 targets configured).
 INFO: Found 14 targets...
 INFO: Elapsed time: 11,761s, Critical Path: 7,23s
 INFO: 3 processes: 1 internal, 2 darwin-sandbox.
 INFO: Build completed successfully, 3 total actions
 % bazel run --cxxopt=-std=c++17 //tests/qt_resource:main
 DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path:  /usr/local/opt/qt5
 INFO: Analyzed target //tests/qt_resource:main (0 packages loaded, 0 targets configured).
 INFO: Found 1 target...
 Target //tests/qt_resource:main up-to-date:
 bazel-bin/tests/qt_resource/main
 INFO: Elapsed time: 3,657s, Critical Path: 0,00s
 INFO: 1 process: 1 internal.
 INFO: Build completed successfully, 1 total action
 INFO: Build completed successfully, 1 total action
 opened resource file
 file1
-----------------------
 % bazel build --cxxopt=-std=c++17  //...
 DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path:  /usr/local/opt/qt5
 INFO: Analyzed 14 targets (0 packages loaded, 0 targets configured).
 INFO: Found 14 targets...
 ERROR: /Users/home/Git/my_repo/bazel_rules_qt/tests/qt_qml/BUILD:4:10: Compiling tests/qt_qml/main.cc failed: (Aborted): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' ... (remaining 38 argument(s) skipped)

 Use --sandbox_debug to see verbose messages from the sandbox
 tests/qt_qml/main.cc:1:10: fatal error: 'QtQml/QQmlApplicationEngine' file not found
 #include <QtQml/QQmlApplicationEngine>
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1 error generated.
 Error in child process '/usr/bin/xcrun'. 1
 INFO: Elapsed time: 0,594s, Critical Path: 0,32s
 INFO: 3 processes: 3 internal.
 FAILED: Build did NOT complete successfully
 diff --git a/qt.BUILD b/qt.BUILD
 index 517c8db..8f110b5 100644
 --- a/qt.BUILD
 +++ b/qt.BUILD
 @@ -28,11 +28,12 @@ QT_LIBRARIES = [
      cc_library(
          name = "qt_%s_osx" % name,
          # When being on Windows this glob will be empty
 -        hdrs = glob(["%s/**" % include_folder], allow_empty = True),
 +        hdrs = glob(["include/%s/**" % include_folder], allow_empty = True),
          includes = ["."],
          linkopts = ["-F/usr/local/opt/qt5/lib"] + [
              "-framework %s" % library_name.replace("5", "") # macOS qt libs do not contain a 5 - e.g. instead of Qt5Core the lib is called QtCore
              ],
 +        strip_include_prefix= "include"
          # Available from Bazel 4.0.0
          # target_compatible_with = ["@platforms//os:osx"],
      )
 % bazel build --cxxopt=-std=c++17  //...
 DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path:  /usr/local/opt/qt5
 INFO: Analyzed 14 targets (1 packages loaded, 7422 targets configured).
 INFO: Found 14 targets...
 INFO: Elapsed time: 11,761s, Critical Path: 7,23s
 INFO: 3 processes: 1 internal, 2 darwin-sandbox.
 INFO: Build completed successfully, 3 total actions
 % bazel run --cxxopt=-std=c++17 //tests/qt_resource:main
 DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path:  /usr/local/opt/qt5
 INFO: Analyzed target //tests/qt_resource:main (0 packages loaded, 0 targets configured).
 INFO: Found 1 target...
 Target //tests/qt_resource:main up-to-date:
 bazel-bin/tests/qt_resource/main
 INFO: Elapsed time: 3,657s, Critical Path: 0,00s
 INFO: 1 process: 1 internal.
 INFO: Build completed successfully, 1 total action
 INFO: Build completed successfully, 1 total action
 opened resource file
 file1

How to build header only C++ library within Bazel workspace?

copy iconCopydownload iconDownload
http_archive(
    name = "xtensor",
    build_file_content = all_content,
    strip_prefix = "xtensor-master",
    urls = ["https://github.com/xtensor-stack/xtensor/archive/refs/heads/master.zip"],
    build_file_content = """
cc_library(
    name = "xtensor",
    visibility = ["//visibility:public"],
    hdrs = glob(["xtensor/*.hpp"]),
    defines = [
        "XTENSOR_ENABLE_ASSERT",
    ],
    deps = [
        "@tbb",
    ],
)
""",
)
genrule(
    name = "gen_single_include",
    outs = ["xtensor.hpp"],
    cmd = "\n".join([
        "cat > $@ <<'END'",
        "#ifndef XTENSOR",
        "#define XTENSOR",
    ] + ["#include \"%s\"" % h[len("xtensor/"):]
         for h in glob(["xtensor/*.hpp"])
         if h not in [
             "xtensor/xexpression_holder.hpp",
             "xtensor/xjson.hpp",
             "xtensor/xmime.hpp",
             "xtensor/xnpy.hpp",
          ]] + [
        "#endif",
        "END",
    ]),
-----------------------
http_archive(
    name = "xtensor",
    build_file_content = all_content,
    strip_prefix = "xtensor-master",
    urls = ["https://github.com/xtensor-stack/xtensor/archive/refs/heads/master.zip"],
    build_file_content = """
cc_library(
    name = "xtensor",
    visibility = ["//visibility:public"],
    hdrs = glob(["xtensor/*.hpp"]),
    defines = [
        "XTENSOR_ENABLE_ASSERT",
    ],
    deps = [
        "@tbb",
    ],
)
""",
)
genrule(
    name = "gen_single_include",
    outs = ["xtensor.hpp"],
    cmd = "\n".join([
        "cat > $@ <<'END'",
        "#ifndef XTENSOR",
        "#define XTENSOR",
    ] + ["#include \"%s\"" % h[len("xtensor/"):]
         for h in glob(["xtensor/*.hpp"])
         if h not in [
             "xtensor/xexpression_holder.hpp",
             "xtensor/xjson.hpp",
             "xtensor/xmime.hpp",
             "xtensor/xnpy.hpp",
          ]] + [
        "#endif",
        "END",
    ]),

Bazel build docker container with local golang module

copy iconCopydownload iconDownload
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
load("@io_bazel_rules_docker//container:container.bzl", "container_image")

go_library(
    name = "hello_lib",
    srcs = ["main.go"],
    importpath = "go-example/cmd/hello",
    visibility = ["//visibility:private"],
    deps = ["//pkg/echo"],
)

go_binary(
    name = "hello",
    embed = [":hello_lib"],
    visibility = ["//visibility:public"],
)

go_image(
    name = "hello_go_image",
    embed = [":hello_lib"],
    goarch = "amd64",
    goos = "linux",
    pure = "on",
)

container_image(
    name = "docker",
    base = ":hello_go_image",
)

Using Rules Foreign CC to Build AWS C++ SDK with Bazel

copy iconCopydownload iconDownload
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

rules_foreign_cc_dependencies()

AWS_BUILD = """\
filegroup(
    name = "sdk",
    srcs = glob(["**"]),
    visibility = ["//visibility:public"],
)
"""

new_git_repository(
    name = "aws_sdk",
    build_file_content = _ALL_CONTENT,
    commit = "2550901e1011e0ee1dc1bae44b42e1a2c6947c24",
    recursive_init_submodules = True,
    remote = "https://github.com/aws/aws-sdk-cpp",
    shallow_since = "1628277923 +0000",
)
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

cmake(
    name = "aws_sdk",
    cache_entries = {
        "CMAKE_BUILD_TYPE": "Release",
        "BUILD_ONLY": "s3",
        "BUILD_SHARED_LIBS": "ON", 
        "ENABLE_TESTING": "OFF",
    },
    install = True,
    lib_source = "@aws_sdk//:sdk",
    out_shared_libs = [
        "libaws-cpp-sdk-core.so",
        "libaws-cpp-sdk-s3.so",
    ]
)
-----------------------
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

rules_foreign_cc_dependencies()

AWS_BUILD = """\
filegroup(
    name = "sdk",
    srcs = glob(["**"]),
    visibility = ["//visibility:public"],
)
"""

new_git_repository(
    name = "aws_sdk",
    build_file_content = _ALL_CONTENT,
    commit = "2550901e1011e0ee1dc1bae44b42e1a2c6947c24",
    recursive_init_submodules = True,
    remote = "https://github.com/aws/aws-sdk-cpp",
    shallow_since = "1628277923 +0000",
)
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

cmake(
    name = "aws_sdk",
    cache_entries = {
        "CMAKE_BUILD_TYPE": "Release",
        "BUILD_ONLY": "s3",
        "BUILD_SHARED_LIBS": "ON", 
        "ENABLE_TESTING": "OFF",
    },
    install = True,
    lib_source = "@aws_sdk//:sdk",
    out_shared_libs = [
        "libaws-cpp-sdk-core.so",
        "libaws-cpp-sdk-s3.so",
    ]
)

How to do configuration and variant handling in Bazel?

copy iconCopydownload iconDownload
constraint_setting(name = "has_x")

constraint_value(
    name = "x_v1",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_v2",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_none",
    constraint_setting = ":has_x",
)

constraint_setting(name = "interface")

constraint_value(
    name = "interface_usb",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_ethernet",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_uart",
    constraint_setting = ":interface",
)

constraint_setting(name = "failure_reporting")

constraint_value(
    name = "fail_fast",
    constraint_setting = ":failure_reporting",
)

constraint_value(
    name = "fail_bugreport",
    constraint_setting = ":failure_reporting",
)

platform(
    name = "customer_1",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_ethernet",
        ":fail_fast",
    ],
)

platform(
    name = "customer_2",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_usb",
        ":fail_fast",
    ],
)

platform(
    name = "customer_3",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_usb",
        ":fail_bugreport",
    ],
)

platform(
    name = "debug_hw",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_uart",
        ":fail_fast",
    ],
)
cc_library(
    name = "generic_linked_list",
    <etc>
)
cc_library(
    name = "hardware_x_driver",
    target_compatible_with = [":x_v1", ":x_v2"],
    <etc>
)

cc_library(
    name = "ethernet_driver",
    # Or you could have a separate constraint for "has ethernet hardware",
    # to use for some platforms which have the hardware but don't use it
    # as the primary interface.
    target_compatible_with = [":interface_ethernet"],
    <etc>
)
cc_library(
    name = "selected_connection",
    copts = select({
        ":interface_usb": [ "-DVARIANT_POINT_CONNECTED_USB" ],
        ":interface_ethernet": ["-DVARIANT_POINT_CONNECTED_ETH" ],
        ":interface_uart": ["-DVARIANT_POINT_CONNECTED_UART" ],
    }),
    deps = select({
        ":interface_ethernet": [ ":ethernet_driver" ],
        "//conditions:default": [],
    }),
    <etc>
)
build:customer_1 --platforms=//some/long/and/annoying/package:customer_1
-----------------------
constraint_setting(name = "has_x")

constraint_value(
    name = "x_v1",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_v2",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_none",
    constraint_setting = ":has_x",
)

constraint_setting(name = "interface")

constraint_value(
    name = "interface_usb",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_ethernet",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_uart",
    constraint_setting = ":interface",
)

constraint_setting(name = "failure_reporting")

constraint_value(
    name = "fail_fast",
    constraint_setting = ":failure_reporting",
)

constraint_value(
    name = "fail_bugreport",
    constraint_setting = ":failure_reporting",
)

platform(
    name = "customer_1",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_ethernet",
        ":fail_fast",
    ],
)

platform(
    name = "customer_2",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_usb",
        ":fail_fast",
    ],
)

platform(
    name = "customer_3",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_usb",
        ":fail_bugreport",
    ],
)

platform(
    name = "debug_hw",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_uart",
        ":fail_fast",
    ],
)
cc_library(
    name = "generic_linked_list",
    <etc>
)
cc_library(
    name = "hardware_x_driver",
    target_compatible_with = [":x_v1", ":x_v2"],
    <etc>
)

cc_library(
    name = "ethernet_driver",
    # Or you could have a separate constraint for "has ethernet hardware",
    # to use for some platforms which have the hardware but don't use it
    # as the primary interface.
    target_compatible_with = [":interface_ethernet"],
    <etc>
)
cc_library(
    name = "selected_connection",
    copts = select({
        ":interface_usb": [ "-DVARIANT_POINT_CONNECTED_USB" ],
        ":interface_ethernet": ["-DVARIANT_POINT_CONNECTED_ETH" ],
        ":interface_uart": ["-DVARIANT_POINT_CONNECTED_UART" ],
    }),
    deps = select({
        ":interface_ethernet": [ ":ethernet_driver" ],
        "//conditions:default": [],
    }),
    <etc>
)
build:customer_1 --platforms=//some/long/and/annoying/package:customer_1
-----------------------
constraint_setting(name = "has_x")

constraint_value(
    name = "x_v1",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_v2",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_none",
    constraint_setting = ":has_x",
)

constraint_setting(name = "interface")

constraint_value(
    name = "interface_usb",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_ethernet",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_uart",
    constraint_setting = ":interface",
)

constraint_setting(name = "failure_reporting")

constraint_value(
    name = "fail_fast",
    constraint_setting = ":failure_reporting",
)

constraint_value(
    name = "fail_bugreport",
    constraint_setting = ":failure_reporting",
)

platform(
    name = "customer_1",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_ethernet",
        ":fail_fast",
    ],
)

platform(
    name = "customer_2",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_usb",
        ":fail_fast",
    ],
)

platform(
    name = "customer_3",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_usb",
        ":fail_bugreport",
    ],
)

platform(
    name = "debug_hw",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_uart",
        ":fail_fast",
    ],
)
cc_library(
    name = "generic_linked_list",
    <etc>
)
cc_library(
    name = "hardware_x_driver",
    target_compatible_with = [":x_v1", ":x_v2"],
    <etc>
)

cc_library(
    name = "ethernet_driver",
    # Or you could have a separate constraint for "has ethernet hardware",
    # to use for some platforms which have the hardware but don't use it
    # as the primary interface.
    target_compatible_with = [":interface_ethernet"],
    <etc>
)
cc_library(
    name = "selected_connection",
    copts = select({
        ":interface_usb": [ "-DVARIANT_POINT_CONNECTED_USB" ],
        ":interface_ethernet": ["-DVARIANT_POINT_CONNECTED_ETH" ],
        ":interface_uart": ["-DVARIANT_POINT_CONNECTED_UART" ],
    }),
    deps = select({
        ":interface_ethernet": [ ":ethernet_driver" ],
        "//conditions:default": [],
    }),
    <etc>
)
build:customer_1 --platforms=//some/long/and/annoying/package:customer_1
-----------------------
constraint_setting(name = "has_x")

constraint_value(
    name = "x_v1",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_v2",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_none",
    constraint_setting = ":has_x",
)

constraint_setting(name = "interface")

constraint_value(
    name = "interface_usb",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_ethernet",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_uart",
    constraint_setting = ":interface",
)

constraint_setting(name = "failure_reporting")

constraint_value(
    name = "fail_fast",
    constraint_setting = ":failure_reporting",
)

constraint_value(
    name = "fail_bugreport",
    constraint_setting = ":failure_reporting",
)

platform(
    name = "customer_1",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_ethernet",
        ":fail_fast",
    ],
)

platform(
    name = "customer_2",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_usb",
        ":fail_fast",
    ],
)

platform(
    name = "customer_3",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_usb",
        ":fail_bugreport",
    ],
)

platform(
    name = "debug_hw",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_uart",
        ":fail_fast",
    ],
)
cc_library(
    name = "generic_linked_list",
    <etc>
)
cc_library(
    name = "hardware_x_driver",
    target_compatible_with = [":x_v1", ":x_v2"],
    <etc>
)

cc_library(
    name = "ethernet_driver",
    # Or you could have a separate constraint for "has ethernet hardware",
    # to use for some platforms which have the hardware but don't use it
    # as the primary interface.
    target_compatible_with = [":interface_ethernet"],
    <etc>
)
cc_library(
    name = "selected_connection",
    copts = select({
        ":interface_usb": [ "-DVARIANT_POINT_CONNECTED_USB" ],
        ":interface_ethernet": ["-DVARIANT_POINT_CONNECTED_ETH" ],
        ":interface_uart": ["-DVARIANT_POINT_CONNECTED_UART" ],
    }),
    deps = select({
        ":interface_ethernet": [ ":ethernet_driver" ],
        "//conditions:default": [],
    }),
    <etc>
)
build:customer_1 --platforms=//some/long/and/annoying/package:customer_1
-----------------------
constraint_setting(name = "has_x")

constraint_value(
    name = "x_v1",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_v2",
    constraint_setting = ":has_x",
)

constraint_value(
    name = "x_none",
    constraint_setting = ":has_x",
)

constraint_setting(name = "interface")

constraint_value(
    name = "interface_usb",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_ethernet",
    constraint_setting = ":interface",
)

constraint_value(
    name = "interface_uart",
    constraint_setting = ":interface",
)

constraint_setting(name = "failure_reporting")

constraint_value(
    name = "fail_fast",
    constraint_setting = ":failure_reporting",
)

constraint_value(
    name = "fail_bugreport",
    constraint_setting = ":failure_reporting",
)

platform(
    name = "customer_1",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_ethernet",
        ":fail_fast",
    ],
)

platform(
    name = "customer_2",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_v1",
        ":interface_usb",
        ":fail_fast",
    ],
)

platform(
    name = "customer_3",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_usb",
        ":fail_bugreport",
    ],
)

platform(
    name = "debug_hw",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
        ":x_none",
        ":interface_uart",
        ":fail_fast",
    ],
)
cc_library(
    name = "generic_linked_list",
    <etc>
)
cc_library(
    name = "hardware_x_driver",
    target_compatible_with = [":x_v1", ":x_v2"],
    <etc>
)

cc_library(
    name = "ethernet_driver",
    # Or you could have a separate constraint for "has ethernet hardware",
    # to use for some platforms which have the hardware but don't use it
    # as the primary interface.
    target_compatible_with = [":interface_ethernet"],
    <etc>
)
cc_library(
    name = "selected_connection",
    copts = select({
        ":interface_usb": [ "-DVARIANT_POINT_CONNECTED_USB" ],
        ":interface_ethernet": ["-DVARIANT_POINT_CONNECTED_ETH" ],
        ":interface_uart": ["-DVARIANT_POINT_CONNECTED_UART" ],
    }),
    deps = select({
        ":interface_ethernet": [ ":ethernet_driver" ],
        "//conditions:default": [],
    }),
    <etc>
)
build:customer_1 --platforms=//some/long/and/annoying/package:customer_1

Bazel function: git_repository vs new_git_repository?

copy iconCopydownload iconDownload
# GoogleTest- Google Testing and Mocking Framework
git_repository(
    name = "googletest",
    commit = "703bd9caab50b139428cea1aaff9974ebee5742e",  # googletest v1.10.0
    remote = "https://github.com/google/googletest",
    shallow_since = "1570114335 -0400",
)
cc_test(
    name = "tests",
    timeout = "short",
    srcs = ["test.cpp"],
    deps = [
        "@googletest//:gtest_main", # Use GoogleTest as a dependency
    ],
)
cc_library(
    name = "fmt",
    srcs = [
        "include/fmt/args.h",
        "include/fmt/chrono.h",
        "include/fmt/color.h",
        "include/fmt/compile.h",
        "include/fmt/core.h",
        "include/fmt/format.h",
        "include/fmt/format-inl.h",
        "include/fmt/locale.h",
        "include/fmt/os.h",
        "include/fmt/ostream.h",
        "include/fmt/printf.h",
        "include/fmt/ranges.h",
        "include/fmt/xchar.h",
        #"src/fmt.cc", # No C++ module support
        "src/format.cc",
        "src/os.cc",
    ],
    hdrs = [
        "include/fmt/core.h",
        "include/fmt/format.h",
    ],
    includes = [
        "include",
        "src",
    ],
    strip_include_prefix = "include",
    visibility = ["//visibility:public"],
)
new_git_repository(
    name = "fmt",
    build_file = "//third_party:fmt.BUILD",
    ...
)
-----------------------
# GoogleTest- Google Testing and Mocking Framework
git_repository(
    name = "googletest",
    commit = "703bd9caab50b139428cea1aaff9974ebee5742e",  # googletest v1.10.0
    remote = "https://github.com/google/googletest",
    shallow_since = "1570114335 -0400",
)
cc_test(
    name = "tests",
    timeout = "short",
    srcs = ["test.cpp"],
    deps = [
        "@googletest//:gtest_main", # Use GoogleTest as a dependency
    ],
)
cc_library(
    name = "fmt",
    srcs = [
        "include/fmt/args.h",
        "include/fmt/chrono.h",
        "include/fmt/color.h",
        "include/fmt/compile.h",
        "include/fmt/core.h",
        "include/fmt/format.h",
        "include/fmt/format-inl.h",
        "include/fmt/locale.h",
        "include/fmt/os.h",
        "include/fmt/ostream.h",
        "include/fmt/printf.h",
        "include/fmt/ranges.h",
        "include/fmt/xchar.h",
        #"src/fmt.cc", # No C++ module support
        "src/format.cc",
        "src/os.cc",
    ],
    hdrs = [
        "include/fmt/core.h",
        "include/fmt/format.h",
    ],
    includes = [
        "include",
        "src",
    ],
    strip_include_prefix = "include",
    visibility = ["//visibility:public"],
)
new_git_repository(
    name = "fmt",
    build_file = "//third_party:fmt.BUILD",
    ...
)
-----------------------
# GoogleTest- Google Testing and Mocking Framework
git_repository(
    name = "googletest",
    commit = "703bd9caab50b139428cea1aaff9974ebee5742e",  # googletest v1.10.0
    remote = "https://github.com/google/googletest",
    shallow_since = "1570114335 -0400",
)
cc_test(
    name = "tests",
    timeout = "short",
    srcs = ["test.cpp"],
    deps = [
        "@googletest//:gtest_main", # Use GoogleTest as a dependency
    ],
)
cc_library(
    name = "fmt",
    srcs = [
        "include/fmt/args.h",
        "include/fmt/chrono.h",
        "include/fmt/color.h",
        "include/fmt/compile.h",
        "include/fmt/core.h",
        "include/fmt/format.h",
        "include/fmt/format-inl.h",
        "include/fmt/locale.h",
        "include/fmt/os.h",
        "include/fmt/ostream.h",
        "include/fmt/printf.h",
        "include/fmt/ranges.h",
        "include/fmt/xchar.h",
        #"src/fmt.cc", # No C++ module support
        "src/format.cc",
        "src/os.cc",
    ],
    hdrs = [
        "include/fmt/core.h",
        "include/fmt/format.h",
    ],
    includes = [
        "include",
        "src",
    ],
    strip_include_prefix = "include",
    visibility = ["//visibility:public"],
)
new_git_repository(
    name = "fmt",
    build_file = "//third_party:fmt.BUILD",
    ...
)
-----------------------
# GoogleTest- Google Testing and Mocking Framework
git_repository(
    name = "googletest",
    commit = "703bd9caab50b139428cea1aaff9974ebee5742e",  # googletest v1.10.0
    remote = "https://github.com/google/googletest",
    shallow_since = "1570114335 -0400",
)
cc_test(
    name = "tests",
    timeout = "short",
    srcs = ["test.cpp"],
    deps = [
        "@googletest//:gtest_main", # Use GoogleTest as a dependency
    ],
)
cc_library(
    name = "fmt",
    srcs = [
        "include/fmt/args.h",
        "include/fmt/chrono.h",
        "include/fmt/color.h",
        "include/fmt/compile.h",
        "include/fmt/core.h",
        "include/fmt/format.h",
        "include/fmt/format-inl.h",
        "include/fmt/locale.h",
        "include/fmt/os.h",
        "include/fmt/ostream.h",
        "include/fmt/printf.h",
        "include/fmt/ranges.h",
        "include/fmt/xchar.h",
        #"src/fmt.cc", # No C++ module support
        "src/format.cc",
        "src/os.cc",
    ],
    hdrs = [
        "include/fmt/core.h",
        "include/fmt/format.h",
    ],
    includes = [
        "include",
        "src",
    ],
    strip_include_prefix = "include",
    visibility = ["//visibility:public"],
)
new_git_repository(
    name = "fmt",
    build_file = "//third_party:fmt.BUILD",
    ...
)

Failed to connect to port 8080: Connection timed out

copy iconCopydownload iconDownload
curl https://bazel-remote.dev.azr.myhost.com/status

I can't properly add external dependency with bazel

copy iconCopydownload iconDownload
workspace(name = "GTestDemo")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
  name = "gtest",
  url = "https://github.com/google/googletest/archive/release-1.10.0.tar.gz",
  sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
  strip_prefix = "googletest-release-1.10.0",
)
cc_test(
    name = "tests",
    srcs = ["test.cpp"],
    deps = [
        "@gtest//:gtest",
        "@gtest//:gtest_main",
    ],
)
#include <iostream>
#include <fstream>

#include "gtest/gtest.h"

using namespace std;

TEST(sample_test_case, sample_test) {
    EXPECT_EQ(1, 1);
}
-----------------------
workspace(name = "GTestDemo")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
  name = "gtest",
  url = "https://github.com/google/googletest/archive/release-1.10.0.tar.gz",
  sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
  strip_prefix = "googletest-release-1.10.0",
)
cc_test(
    name = "tests",
    srcs = ["test.cpp"],
    deps = [
        "@gtest//:gtest",
        "@gtest//:gtest_main",
    ],
)
#include <iostream>
#include <fstream>

#include "gtest/gtest.h"

using namespace std;

TEST(sample_test_case, sample_test) {
    EXPECT_EQ(1, 1);
}
-----------------------
workspace(name = "GTestDemo")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
  name = "gtest",
  url = "https://github.com/google/googletest/archive/release-1.10.0.tar.gz",
  sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
  strip_prefix = "googletest-release-1.10.0",
)
cc_test(
    name = "tests",
    srcs = ["test.cpp"],
    deps = [
        "@gtest//:gtest",
        "@gtest//:gtest_main",
    ],
)
#include <iostream>
#include <fstream>

#include "gtest/gtest.h"

using namespace std;

TEST(sample_test_case, sample_test) {
    EXPECT_EQ(1, 1);
}

Bazel Remote Cache not working with certificates/TLS

copy iconCopydownload iconDownload
bazel test --remote_cache=grpcs://localhost:9094 --tls_client_certificate=/path/to/client.crt --tls_client_key=/path/to/client.pem --tls_certificate=/path/to/ca.crt //...
subjectAltName=IP:<SERVER_IP>
openssl x509 -req -passin pass:1111 -days 358000 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -extfile extensions.cnf
-----------------------
bazel test --remote_cache=grpcs://localhost:9094 --tls_client_certificate=/path/to/client.crt --tls_client_key=/path/to/client.pem --tls_certificate=/path/to/ca.crt //...
subjectAltName=IP:<SERVER_IP>
openssl x509 -req -passin pass:1111 -days 358000 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -extfile extensions.cnf
-----------------------
bazel test --remote_cache=grpcs://localhost:9094 --tls_client_certificate=/path/to/client.crt --tls_client_key=/path/to/client.pem --tls_certificate=/path/to/ca.crt //...
subjectAltName=IP:<SERVER_IP>
openssl x509 -req -passin pass:1111 -days 358000 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -extfile extensions.cnf

How to use Bazel rules_docker container_flatten to create a Docker image?

copy iconCopydownload iconDownload
container_image(
  name = "debian10",
  tars = [":debian10_flatten.tar"],
)

Community Discussions

Trending Discussions on bazel
  • Build from source error: missing input file 'external/net_sf_jchart2d/jar/jchart2d.jar'
  • Build and run a Qt application on macOS via Bazel
  • How to build header only C++ library within Bazel workspace?
  • Bazel: how to import/build a go_binary for a go_test
  • Use bazel library inside cmake project
  • Bazel build docker container with local golang module
  • Using Rules Foreign CC to Build AWS C++ SDK with Bazel
  • How to find logs from bazel's previous runs
  • Golang: fatal error: unexpected signal during runtime execution
  • How to do configuration and variant handling in Bazel?
Trending Discussions on bazel

QUESTION

Build from source error: missing input file 'external/net_sf_jchart2d/jar/jchart2d.jar'

Asked 2022-Mar-05 at 15:32

I try to build drake1.0.0 from source using bazel. However I encounter the following error:

ERROR: /home/chenwang/drake-build/_bazel_chenwang/bcff9e14963ec4b6ed21d9b7e9e180fc/external/net_sf_jchart2d/jar/BUILD.bazel:2:12: Extracting interface @net_sf_jchart2d//jar:jar failed: missing input file 'external/net_sf_jchart2d/jar/jchart2d.jar', owner: '@net_sf_jchart2d//jar:jchart2d.jar'
ERROR: /home/chenwang/drake-build/_bazel_chenwang/bcff9e14963ec4b6ed21d9b7e9e180fc/external/net_sf_jchart2d/jar/BUILD.bazel:2:12: Extracting interface @net_sf_jchart2d//jar:jar failed: 1 input file(s) do not exist
Target //:install failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/chenwang/drake-build/_bazel_chenwang/bcff9e14963ec4b6ed21d9b7e9e180fc/external/net_sf_jchart2d/jar/BUILD.bazel:2:12 Extracting interface @net_sf_jchart2d//jar:jar failed: 1 input file(s) do not exist
INFO: Elapsed time: 23.087s, Critical Path: 8.22s
INFO: 2890 processes: 2584 internal, 306 linux-sandbox.
FAILED: Build did NOT complete successfully
CMakeFiles/drake_cxx_python.dir/build.make:110: recipe for target 'drake_cxx_python-prefix/src/drake_cxx_python-stamp/drake_cxx_python-build' failed
make[2]: *** [drake_cxx_python-prefix/src/drake_cxx_python-stamp/drake_cxx_python-build] Error 1
CMakeFiles/Makefile2:931: recipe for target 'CMakeFiles/drake_cxx_python.dir/all' failed
make[1]: *** [CMakeFiles/drake_cxx_python.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

I have built older version drake from source successfully. It seems that I miss some third-party library for building the new version drake. Thank you for your help!

ANSWER

Answered 2022-Mar-05 at 15:32

It turns out that the install_repreqs.sh has been updated and I forget to rerun it. After installing the prerequisite by rerunning install_repreqs.sh, I can build drake from source successfully.

Source https://stackoverflow.com/questions/71362872

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install bazel

Install Bazel
Get started with Bazel
Follow our tutorials: Build C++ Build Java Android iOS

Support

Bazel command lineRule referenceUse the query commandExtend BazelWrite testsRoadmapWho is using Bazel?

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Compare Build Tool Libraries with Highest Support
Compare Build Tool Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.