Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix bazel build bug #351

Merged
merged 1 commit into from
Dec 17, 2023
Merged

build: fix bazel build bug #351

merged 1 commit into from
Dec 17, 2023

Conversation

chloro-pn
Copy link
Collaborator

Why

ASYNC_SIMPLE_COPTS = select({
    # 这里需要显式指定@com_github_async_simple
    "@com_github_async_simple//bazel/config:msvc_compiler": [
        "/std:c++20",
        "/await:strict",
        "/EHa"
    ],
    "//conditions:default": [
        "-std=c++20",
        "-D_GLIBCXX_USE_CXX11_ABI=1",
        "-Wno-deprecated-register",
        "-Wno-mismatched-new-delete",
        "-fPIC",
        "-Wall",
        "-Werror",
        "-D__STDC_LIMIT_MACROS",
        "-g",
    ],
})

假设一项目依赖async_simple:

package(default_visibility = ["//visibility:public"])

load("@com_github_async_simple//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS")

cc_test(
  name = "test",
  srcs = glob(["test/*.cc", "test/*.h"]),
  includes = ["test"],
  copts = ASYNC_SIMPLE_COPTS,
  deps = [
    "@googletest//:gtest",
    "@googletest//:gtest_main",
    "@com_github_async_simple//:async_simple",
  ]
)

如果不在ASYNC_SIMPLE_COPTS的定义里显式指定Repository的话构建会失败:

ERROR: Analysis of target '//:test' failed; build aborted: no such package 'bazel/config': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.

bazel version: 6.0.0

What is changing

Example

Copy link
Collaborator

@ChuanqiXu9 ChuanqiXu9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@ChuanqiXu9 ChuanqiXu9 merged commit 2afd463 into alibaba:main Dec 17, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants