규칙
- <ph type="x-smartling-placeholder"></ph> cc_binary
- <ph type="x-smartling-placeholder"></ph> cc_import
- <ph type="x-smartling-placeholder"></ph> cc_library
- <ph type="x-smartling-placeholder"></ph> cc_proto_library
- <ph type="x-smartling-placeholder"></ph> fdo_prefetch_hints
- <ph type="x-smartling-placeholder"></ph> fdo_profile
- <ph type="x-smartling-placeholder"></ph> propeller_optimize
- <ph type="x-smartling-placeholder"></ph> cc_test
- <ph type="x-smartling-placeholder"></ph> cc_toolchain
- <ph type="x-smartling-placeholder"></ph> cc_toolchain_suite
cc_binary
cc_binary(name, deps, srcs, data, additional_linker_inputs, args, compatible_with, copts, defines, deprecation, distribs, env, exec_compatible_with, exec_properties, features, includes, licenses, linkopts, linkshared, linkstatic, local_defines, malloc, nocopts, output_licenses, restricted_to, stamp, tags, target_compatible_with, testonly, toolchains, visibility, win_def_file)
암시적 출력 타겟
name.stripped(명시적으로 요청된 경우에만 빌드됨): A 제거됨 바이너리의 버전입니다strip -g는 바이너리에서 실행되어 디버그를 삭제합니다. 기호로 구분되지 않습니다. 명령줄에서--stripopt=-foo이 출력은 명시적으로 요청된 경우에만 빌드됩니다.name.dwp(명시적으로 요청된 경우에만 빌드됨): 분열이 사용 설정됨: 디버그 원격으로 배포된 바이너리를 디버깅하는 데 적합한 정보 패키지 파일입니다. 그 외: 빈 파일입니다.
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
deps
|
|
srcs
|
모든
모든 규칙의 이름이
허용되는
...그리고 이러한 파일을 생성하는 모든 규칙을 따릅니다. 각 확장 프로그램은 사용할 수 있습니다. |
additional_linker_inputs
|
예를 들어 컴파일된 Windows .res 파일을 여기에 제공하여 바이너리 타겟입니다. |
copts
|
이 속성의 각 문자열은 주어진 순서로
패키지가 feature를 선언하는 경우
|
defines
|
-D가 추가되고 이 타겟의 컴파일 명령줄에 추가됩니다.
여기에 종속된 모든 규칙에 적용됩니다. 이로 인해
광범위하고 강력한 효과를 낼 수 있습니다. 확실하지 않은 경우 정의 값을
대신 local_defines를 사용하세요.
|
includes
|
'Make 변수' 대체 적용
각 문자열 앞에 헤더는 src 또는 hdrs에 추가해야 합니다. 그렇지 않으면 종속된 규칙을 설정할 수 없습니다 (기본값). |
linkopts
|
LINKOPTS에 추가됩니다.
바이너리 타겟을 연결하는 것입니다.
이 목록에서 |
linkshared
|
linkshared=True를 포함하세요. 기본적으로
이 옵션은 사용 중지되어 있습니다.
이 플래그가 있으면
|
linkstatic
|
cc_binary 및
cc_test: 정적으로 바이너리를 연결합니다.
있습니다. cc_library.linkstatic의 경우 아래를 참고하세요.
기본적으로 이 옵션은
이 옵션을 사용 설정하고 바이너리 또는 테스트인 경우 이 옵션을 사용하면 빌드 도구에
실행 파일을 연결하는 방법에는 세 가지가 있습니다.
|
local_defines
|
-D이 추가되고 이 타겟의 컴파일 명령줄에 추가됩니다.
종속 항목은 받지 않습니다.
|
malloc
|
기본적으로 C++ 바이너리는 |
nocopts
|
COPTS
(규칙의 copts 속성에 명시적으로 지정된 값 포함)은
COPTS는 이 규칙을 컴파일하기 위한 것입니다.
이 속성은 거의 필요하지 않습니다.
|
stamp
|
스탬프 처리된 바이너리는 종속 항목이 변경되지 않는 한 다시 빌드되지 않습니다. |
win_def_file
|
이 속성은 Windows가 대상 플랫폼인 경우에만 사용해야 합니다. 내보내기 기호를 사용할 수 있습니다. |
cc_import
cc_import(name, data, hdrs, alwayslink, compatible_with, deprecation, distribs, features, interface_library, licenses, restricted_to, shared_library, static_library, system_provided, tags, target_compatible_with, testonly, visibility)
cc_import 규칙을 사용하면 사용자가 사전 컴파일된 C/C++ 라이브러리를 가져올 수 있습니다.
일반적인 사용 사례는 다음과 같습니다.
1. 정적 라이브러리 연결
cc_import( name = "mylib", hdrs = ["mylib.h"], static_library = "libmylib.a", # If alwayslink is turned on, # libmylib.a will be forcely linked into any binary that depends on it. # alwayslink = 1, )
cc_import( name = "mylib", hdrs = ["mylib.h"], shared_library = "libmylib.so", )
cc_import( name = "mylib", hdrs = ["mylib.h"], # mylib.lib is a import library for mylib.dll which will be passed to linker interface_library = "mylib.lib", # mylib.dll will be available for runtime shared_library = "mylib.dll", )
system_provided=True에 연결 (Windows)
cc_import( name = "mylib", hdrs = ["mylib.h"], # mylib.lib is an import library for mylib.dll which will be passed to linker interface_library = "mylib.lib", # mylib.dll is provided by system environment, for example it can be found in PATH. # This indicates that Bazel is not responsible for making mylib.dll available. system_provided = 1, )
에 연결 Unix의 경우:
cc_import( name = "mylib", hdrs = ["mylib.h"], static_library = "libmylib.a", shared_library = "libmylib.so", ) # first will link to libmylib.a cc_binary( name = "first", srcs = ["first.cc"], deps = [":mylib"], linkstatic = 1, # default value ) # second will link to libmylib.so cc_binary( name = "second", srcs = ["second.cc"], deps = [":mylib"], linkstatic = 0, )
cc_import( name = "mylib", hdrs = ["mylib.h"], static_library = "libmylib.lib", # A normal static library interface_library = "mylib.lib", # An import library for mylib.dll shared_library = "mylib.dll", ) # first will link to libmylib.lib cc_binary( name = "first", srcs = ["first.cc"], deps = [":mylib"], linkstatic = 1, # default value ) # second will link to mylib.dll through mylib.lib cc_binary( name = "second", srcs = ["second.cc"], deps = [":mylib"], linkstatic = 0, )
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
hdrs
|
|
alwayslink
|
항상 링크가 Windows의 VS 2017에서 작동하지 않는다면 알려진 문제, VS 2017을 최신 버전으로 업그레이드하세요. |
interface_library
|
허용되는 파일 형식은 다음과 같습니다.
|
shared_library
|
허용되는 파일 형식은 다음과 같습니다.
|
static_library
|
허용되는 파일 형식은 다음과 같습니다.
|
system_provided
|
interface_library를 지정해야 하며
shared_library는 비어 있어야 합니다.
|
cc_library
cc_library(name, deps, srcs, data, hdrs, additional_compiler_inputs, alwayslink, compatible_with, copts, defines, deprecation, distribs, exec_compatible_with, exec_properties, features, implementation_deps, include_prefix, includes, licenses, linkopts, linkstamp, linkstatic, local_defines, nocopts, restricted_to, strip_include_prefix, tags, target_compatible_with, testonly, textual_hdrs, toolchains, visibility, win_def_file)
헤더 포함 확인
빌드에 사용되는 모든 헤더 파일은 hdrs 또는
규칙 cc_*개 중 srcs개 이는 시행되는 조치입니다.
cc_library 규칙의 경우 hdrs의 헤더는 다음의 공개 인터페이스로 구성됩니다.
라이브러리에 추가되어야 하며 hdrs 및
라이브러리 자체의 srcs 및 hdrs의 파일에서
deps에 라이브러리를 나열하는 규칙 cc_*개 중 srcs개입니다.
srcs의 헤더는 hdrs에 있는 파일에서만 직접 포함되어야 합니다.
및 라이브러리 자체의 srcs입니다. 헤더를 삽입할지 여부를 결정할 때는
hdrs 또는 srcs 중 어느 쪽이든 이 라이브러리의 소비자를 원하는지 물어봐야 합니다.
직접 포함할 수 있습니다. 이 결정은 Ad Exchange의
프로그래밍 언어로 public 및 private 공개 상태
cc_binary 및 cc_test 규칙은 내보낸 인터페이스가 없으므로
또한 hdrs 속성이 없습니다. 바이너리 또는 테스트에 속하는 모든 헤더
srcs에 직접 나열되어야 합니다.
이러한 규칙을 설명하려면 다음 예를 참고하세요.
cc_binary(
name = "foo",
srcs = [
"foo.cc",
"foo.h",
],
deps = [":bar"],
)
cc_library(
name = "bar",
srcs = [
"bar.cc",
"bar-impl.h",
],
hdrs = ["bar.h"],
deps = [":baz"],
)
cc_library(
name = "baz",
srcs = [
"baz.cc",
"baz-impl.h",
],
hdrs = ["baz.h"],
)
이 예에서 허용되는 직접 포함은 아래 표에 나와 있습니다. 예:
foo.cc는 foo.h 및 bar.h를 직접 포함할 수 있지만
baz.h가 아닙니다.
| 파일 포함 | 허용되는 포함 |
|---|---|
| foo.h | bar.h |
| foo.cc | foo.h bar.h |
| bar.h | bar-impl.h baz.h |
| bar-impl.h | bar.h baz.h |
| bar.cc | bar.h bar-impl.h baz.h |
| baz.h | baz-impl.h |
| baz-impl.h | baz.h |
| baz.cc | baz.h baz-impl.h |
포함 확인 규칙은 직접
포함되지 않습니다. 위의 예에서 foo.cc는
bar.h를 포함하며, 여기에는 baz.h도 포함될 수 있고,
baz-impl.h를 포함할 수 있습니다. 기술적으로
.cc 파일의 컴파일에는 모든 헤더가 전이적으로 포함될 수 있음
파일(hdrs 또는 srcs)에
전이적 deps 클로저의 모든 cc_library 포함
이 경우 컴파일러는 baz.h 및 baz-impl.h를 읽을 수 있습니다.
foo.cc를 컴파일할 때. foo.cc는 컴파일되어서는 안 됨
#include "baz.h"를 포함해야 합니다. 이를 위해서는
허용되는 경우 baz를 deps에 추가해야 합니다.
/foo
안타깝게도 Bazel은 현재 직접과 임시를 구분할 수 없습니다.
포함하므로, 파일에
전이적으로만 포함될 수 있는 헤더입니다. 예를 들어
위의 예시에서 Bazel은 foo.cc를 직접 호출하지 않습니다.
baz.h 포함 이는 불법입니다. foo
baz에 직접 종속되지 않습니다. 현재 오류가 발생하지 않습니다.
향후 이러한 오류 검사가 추가될 수 있습니다.
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
deps
|
|
srcs
|
모든
모든 규칙의 이름이
허용되는
...그리고 이러한 파일을 생성하는 모든 규칙을 따릅니다. 각 확장 프로그램은 사용할 수 있습니다. |
hdrs
|
이 위치는 헤더 파일을 선언하는 데 적극 권장되는 위치입니다.
라이브러리에 대한 인터페이스를 설명합니다. 이 헤더는
이 규칙 또는 종속 규칙에 소스별로 포함할 수 있습니다.
이 라이브러리의 클라이언트에 의해 포함되지 않아야 하는 헤더는
|
additional_compiler_inputs
|
|
alwayslink
|
srcs: 바이너리에서 참조하는 기호가 일부 포함되어 있지 않은 경우에도 마찬가지입니다.
이는 코드가
바이너리(예: 코드가 콜백을 수신하도록 등록되는 경우)
제공할 수 있습니다
항상 링크가 Windows의 VS 2017에서 작동하지 않는다면 알려진 문제, VS 2017을 최신 버전으로 업그레이드하세요. |
copts
|
이 속성의 각 문자열은 주어진 순서로
패키지가 feature를 선언하는 경우
|
defines
|
-D가 추가되고 이 타겟의 컴파일 명령줄에 추가됩니다.
여기에 종속된 모든 규칙에 적용됩니다. 이로 인해
광범위하고 강력한 효과를 낼 수 있습니다. 확실하지 않은 경우 정의 값을
대신 local_defines를 사용하세요.
|
implementation_deps
|
deps - 이러한 라이브러리 (및 모든 라이브러리)의 헤더와 포함 경로
전이 deps)는 이 라이브러리의 컴파일에만 사용되며,
있습니다. implementation_deps로 지정된 라이브러리가 아직 연결되어 있음
바이너리 타겟을 생성합니다.
현재 사용은 cc_library로 제한되며 플래그로 보호됩니다.
|
include_prefix
|
설정하면 이 규칙의
|
includes
|
'Make 변수' 대체 적용
각 문자열 앞에 헤더는 src 또는 hdrs에 추가해야 합니다. 그렇지 않으면 종속된 규칙을 설정할 수 없습니다 (기본값). |
linkopts
|
LINKOPTS에 추가됩니다.
바이너리 타겟을 연결하는 것입니다.
이 목록에서 |
linkstamp
|
base 패키지.
|
linkstatic
|
cc_binary 및
cc_test: 정적으로 바이너리를 연결합니다.
있습니다. cc_library.linkstatic의 경우 아래를 참고하세요.
기본적으로 이 옵션은
이 옵션을 사용 설정하고 바이너리 또는 테스트인 경우 이 옵션을 사용하면 빌드 도구에
실행 파일을 연결하는 방법에는 세 가지가 있습니다.
|
local_defines
|
-D이 추가되고 이 타겟의 컴파일 명령줄에 추가됩니다.
종속 항목은 받지 않습니다.
|
nocopts
|
COPTS
(규칙의 copts 속성에 명시적으로 지정된 값 포함)은
COPTS는 이 규칙을 컴파일하기 위한 것입니다.
이 속성은 거의 필요하지 않습니다.
|
strip_include_prefix
|
설정하면 이 규칙의 상대 경로인 경우 패키지에 상대적인 경로로 간주됩니다. 절댓값인 경우 저장소 기준 경로로 이해됩니다.
|
textual_hdrs
|
자체적으로 컴파일할 수 없는 헤더 파일을 선언하는 위치입니다. 즉, 유효한 HTML 파일을 빌드하려면 항상 다른 소스 파일에 의해 있습니다. |
win_def_file
|
이 속성은 Windows가 대상 플랫폼인 경우에만 사용해야 합니다. 내보내기 기호를 사용할 수 있습니다. |
cc_proto_library
cc_proto_library(name, deps, data, compatible_with, deprecation, distribs, exec_compatible_with, exec_properties, features, licenses, restricted_to, tags, target_compatible_with, testonly, visibility)
cc_proto_library는 .proto 파일에서 C++ 코드를 생성합니다.
deps은(는) proto_library
규칙을 가리켜야 합니다.
예:
cc_library(
name = "lib",
deps = [":foo_cc_proto"],
)
cc_proto_library(
name = "foo_cc_proto",
deps = [":foo_proto"],
)
proto_library(
name = "foo_proto",
)
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
deps
|
proto_library 목록
C++ 코드를 생성할 수 있습니다.
|
fdo_prefetch_hints
fdo_prefetch_hints(name, compatible_with, deprecation, distribs, features, licenses, profile, restricted_to, tags, target_compatible_with, testonly, visibility)
작업공간에 있거나 지정된 위치에 있는 FDO 미리 가져오기 힌트 프로필을 나타냅니다. 절대 경로입니다. 예:
fdo_prefetch_hints(
name = "hints",
profile = "//path/to/hints:profile.afdo",
)
fdo_profile(
name = "hints_abs",
absolute_path_profile = "/absolute/path/profile.afdo",
)
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
profile
|
|
fdo_profile
fdo_profile(name, absolute_path_profile, compatible_with, deprecation, distribs, features, licenses, profile, proto_profile, restricted_to, tags, target_compatible_with, testonly, visibility)
작업공간 또는 지정된 절대 경로에 있는 FDO 프로필을 나타냅니다. 예:
fdo_profile(
name = "fdo",
profile = "//path/to/fdo:profile.zip",
)
fdo_profile(
name = "fdo_abs",
absolute_path_profile = "/absolute/path/profile.zip",
)
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
absolute_path_profile
|
|
profile
|
|
proto_profile
|
|
propeller_optimize
propeller_optimize(name, compatible_with, deprecation, distribs, features, ld_profile, licenses, restricted_to, tags, target_compatible_with, testonly, visibility)
작업공간의 프로펠러 최적화 프로필을 나타냅니다. 예:
propeller_optimize(
name = "layout",
cc_profile = "//path:cc_profile.txt",
ld_profile = "//path:ld_profile.txt"
)
propeller_optimize(
name = "layout_absolute",
absolute_cc_profile = "/absolute/cc_profile.txt",
absolute_ld_profile = "/absolute/ld_profile.txt"
)
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
ld_profile
|
|
cc_test
cc_test(name, deps, srcs, data, additional_linker_inputs, args, compatible_with, copts, defines, deprecation, distribs, env, env_inherit, exec_compatible_with, exec_properties, features, flaky, includes, licenses, linkopts, linkstatic, local, local_defines, malloc, nocopts, restricted_to, shard_count, size, stamp, tags, target_compatible_with, testonly, timeout, toolchains, visibility, win_def_file)
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
deps
|
|
srcs
|
모든
모든 규칙의 이름이
허용되는
...그리고 이러한 파일을 생성하는 모든 규칙을 따릅니다. 각 확장 프로그램은 사용할 수 있습니다. |
additional_linker_inputs
|
예를 들어 컴파일된 Windows .res 파일을 여기에 제공하여 바이너리 타겟입니다. |
copts
|
이 속성의 각 문자열은 주어진 순서로
패키지가 feature를 선언하는 경우
|
defines
|
-D가 추가되고 이 타겟의 컴파일 명령줄에 추가됩니다.
여기에 종속된 모든 규칙에 적용됩니다. 이로 인해
광범위하고 강력한 효과를 낼 수 있습니다. 확실하지 않은 경우 정의 값을
대신 local_defines를 사용하세요.
|
includes
|
'Make 변수' 대체 적용
각 문자열 앞에 헤더는 src 또는 hdrs에 추가해야 합니다. 그렇지 않으면 종속된 규칙을 설정할 수 없습니다 (기본값). |
linkopts
|
LINKOPTS에 추가됩니다.
바이너리 타겟을 연결하는 것입니다.
이 목록에서 |
linkstatic
|
cc_binary 및
cc_test: 정적으로 바이너리를 연결합니다.
있습니다. cc_library.linkstatic의 경우 아래를 참고하세요.
기본적으로 이 옵션은
이 옵션을 사용 설정하고 바이너리 또는 테스트인 경우 이 옵션을 사용하면 빌드 도구에
실행 파일을 연결하는 방법에는 세 가지가 있습니다.
|
local_defines
|
-D이 추가되고 이 타겟의 컴파일 명령줄에 추가됩니다.
종속 항목은 받지 않습니다.
|
malloc
|
기본적으로 C++ 바이너리는 |
nocopts
|
COPTS
(규칙의 copts 속성에 명시적으로 지정된 값 포함)은
COPTS는 이 규칙을 컴파일하기 위한 것입니다.
이 속성은 거의 필요하지 않습니다.
|
stamp
|
스탬프 처리된 바이너리는 종속 항목이 변경되지 않는 한 다시 빌드되지 않습니다. |
win_def_file
|
이 속성은 Windows가 대상 플랫폼인 경우에만 사용해야 합니다. 내보내기 기호를 사용할 수 있습니다. |
cc_toolchain
cc_toolchain(name, all_files, ar_files, as_files, compatible_with, compiler, compiler_files, compiler_files_without_includes, coverage_files, cpu, deprecation, distribs, dwp_files, dynamic_runtime_lib, exec_transition_for_inputs, features, libc_top, licenses, linker_files, module_map, objcopy_files, restricted_to, static_runtime_lib, strip_files, supports_header_parsing, supports_param_files, tags, target_compatible_with, testonly, toolchain_config, toolchain_identifier, visibility)
C++ 도구 모음을 나타냅니다.
이 규칙의 역할:
-
C++ 작업을 실행하는 데 필요한 모든 아티팩트 수집 이는
속성(예:
all_files,compiler_files,linker_files또는_files로 끝나는 기타 속성) 이는 모든 필수 파일을 글로빙하는 가장 일반적인 파일 그룹입니다. -
C++ 작업을 위한 올바른 명령줄 생성 이 작업은
CcToolchainConfigInfo제공업체 (아래 세부정보 참고)
toolchain_config 속성을 사용하여 C++ 도구 모음을 구성합니다.
참고 항목
<ph type="x-smartling-placeholder"></ph>
페이지
를 참조하세요.
도구 모음이 빌드 및 구성되지 않도록 하려면 tags = ["manual"] 사용
bazel build //... 호출 시 불필요하게
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
all_files
|
all_files를 상위 집합이라고 가정합니다.
아티팩트를 제공하는 다른 모든 속성입니다 (예: linkstamp 컴파일에는 두 가지 모두 컴파일이 필요함).
링크 파일도 포함되므로 all_files가 필요합니다.
|
ar_files
|
보관처리 작업에 필요한 모든 cc_Tools 아티팩트 컬렉션입니다. |
as_files
|
어셈블리 작업에 필요한 모든 cc_Tools 아티팩트 컬렉션입니다. |
compiler
|
toolchain_identifier 속성을 사용하세요. 곧 버벅거림이 될 거예요
이후
<ph type="x-smartling-placeholder"></ph>
Starlark로 CROSSTOOL 이전
에 게시되며 다음 기한까지 삭제됩니다.
#7075
설정되면 crosstool_config.툴체인 선택을 수행하는 데 사용됩니다. 소요 시간 --cpu Bazel 옵션보다 우선 적용 |
compiler_files
|
|
compiler_files_without_includes
|
|
coverage_files
|
|
cpu
|
설정되면 crosstool_config.Tools를 선택하는 데 사용됩니다. 소요 시간 --cpu Bazel 옵션보다 우선 적용 |
dwp_files
|
|
dynamic_runtime_lib
|
'static_link_cpp_runtimes' 기능이 사용 설정되었으며 동적으로 종속됩니다. |
exec_transition_for_inputs
|
|
libc_top
|
|
linker_files
|
|
module_map
|
|
objcopy_files
|
|
static_runtime_lib
|
'static_link_cpp_runtimes' 기능이 사용 설정되었으며 종속 항목을 정적으로 정의합니다 |
strip_files
|
|
supports_header_parsing
|
|
supports_param_files
|
|
toolchain_config
|
cc_toolchain_config_info를 제공하는 규칙의 라벨입니다.
|
toolchain_identifier
|
#5380 문제가 해결될 때까지
|
cc_toolchain_suite
cc_toolchain_suite(name, compatible_with, deprecation, distribs, features, licenses, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility)
C++ 도구 모음 모음을 나타냅니다.
이 규칙의 역할:
- 모든 관련 C++ 도구 모음 수집
-
--cpu및--compiler옵션에 따라 하나의 도구 모음 선택 Bazel로 전달됩니다
참고 항목 <ph type="x-smartling-placeholder"></ph> 페이지 를 참조하세요.
인수
| 속성 | |
|---|---|
name |
이 대상의 고유한 이름입니다. |
toolchains
|
cc_toolchain 라벨 "<cpu>" --cpu인 경우에만 사용됩니다.
Bazel로 전달되고 '<cpu>|<compiler>'가 사용됩니다. 는
--cpu 및 --compiler가 Bazel에 전달됩니다. 예:
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"piii|gcc": ":my_cc_toolchain_for_piii_using_gcc",
"piii": ":my_cc_toolchain_for_piii_using_default_compiler",
},
)
|