This is liable to change in the future.A cgo_library() rule builds an object from the supplied set of Go/C source files and dependencies. The outputs are linked into go executable in the last step (compile). This rule borrows from cxx_binary since C/C++ sources are being compiled.
The name of the rule.
go.prefix + path relative to the buck root) #
Sets the full name of the package being compiled. This defaults to the path from the buck root. (e.g. given a ./.buckconfig, a rule in ./a/b/BUCK defaults to package "a/b")
The set of C, C++, Objective-C, Objective-C++, or assembly source files to be preprocessed, compiled, and assembled by this rule. We determine which stages to run on each input source based on its file extension. See the GCC documentation for more detail on how file extensions are interpreted. Each element can be either a string specifying a source file (e.g.
'foo/bar.c') or a tuple of a string specifying a source file and a list of compilation flags (e.g.
('foo/bar.c', ['-Wall', '-Werror'])). In the latter case the specified flags will be used in addition to the rule's other flags when preprocessing and compiling that file (if applicable).
The set of header files that are made available for inclusion to the source files in this target. These should be specified as either a list of header files or a dictionary of header names to header files. The header name can contain forward slashes (
/). The headers can be included with
#include <$HEADER_NAMESPACE/$HEADER_NAME>, where
$HEADER_NAMESPACEis the value of the target's
$HEADER_NAMEis the header name if specified, and the filename of the header file otherwise. See
header_namespacefor more information.
Flags to use when preprocessing any of the above sources (which require preprocessing).
Platform specific preprocessor flags. These should be specified as a list of pairs where the first element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform name is matched, and the second element is a list of flags to use when preprocessing the target's sources. See
preprocessor_flagsfor more information.
The set of additional compiler flags to pass to
go tool cgo.
Flags to use when compiling any of the above sources (which require compilation).
Platform specific compiler flags. These should be specified as a list of pairs where the first element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform name is matched, and the second element is a list of flags to use when compiling the target's sources. See
compiler_flagsfor more information.
Status: experimental/unstable. The set of header files that can be used for inclusion to the source files in the target and all targets that transitively depend on it. Buck doesn't add raw headers to the search path of a compiler/preprocessor automatically.
exported_preprocessor_flagscan be used to add such raw headers to the search path.
raw_headersare considered to be experimental for now and cannot be used together with
exported_headersin the same target. See
List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their
exported_depsattributes. For more information, see visibility.
# A rule that builds a Go native executable with linked cgo library based on # C/C++ util library. go_binary( name = "bin", srcs = ["main.go"], cgo_deps = [":lib"], ) cgo_library( name = "lib", srcs = ["cgo_source.go"], headers = ["util.h"], deps = [":util"], ) cxx_library( name = "util", srcs = ["util.c"], headers = ["util.h"], )