Comments (7)
Hi @rnburn, you can have only one configure_make target, with different paths to select only headers or headers and libraries together.
Here is the example how I was able to select headers:
`
filegroup(
name = "httpd_dir",
srcs = [
":apache_httpd",
],
output_group = "gen_dir"
)
genrule(
name = "select_headers",
srcs = [":httpd_dir"],
cmd = "cp -r
outs = ["out_dir"]
)
genrule(
name = "list_headers",
srcs = [":select_headers"],
cmd = "ls $(location select_headers) > $(location list.txt)",
outs = ["list.txt"]
)
`
- I used list_headers only to make select_headers to be built and demonstrate it works, you do not need it in the real build.
- You can also have a custom rule for filtering and do everything with Starlark, because with genrule it is platform-bound.
- Unfortunately, it seems to not work just woth filegroup like: srcs = glob([":target/subdir"]) - probably, glob syntax will always look into the current directory where the BUILD file is and not at the target...
from rules_foreign_cc.
Thanks @irengrig. I'm still having some trouble getting this to work. Here's the setup I have to produce a cpython_header_only library to use with a C++ python module
configure_make(
name = "openssl",
configure_command = "config",
configure_options = [
"no-shared",
],
lib_source = "@com_github_openssl_openssl//:all",
static_libraries = [
"libcrypto.a",
"libssl.a",
],
)
configure_make(
name = "cpython",
configure_options = [
"--with-openssl=$EXT_BUILD_DEPS/openssl",
# Hack to work around https://github.com/bazelbuild/rules_foreign_cc/issues/239
"CFLAGS='-Dredacted=\"redacted\"'",
],
lib_source = "@com_github_python_cpython//:all",
out_include_dir = "include/python3.7m",
binaries = [
"python3",
],
visibility = [
"//visibility:public",
],
deps = [
":openssl",
],
)
filegroup(
name = "cpython_files",
srcs = [
":cpython",
],
visibility = [
"//visibility:public",
],
output_group = "gen_dir",
)
genrule(
name = "cpython_includes",
srcs = [
":cpython_files",
],
cmd = "cp -r $(location cpython_files)/include/python3.7m $(location include)",
outs = ["include"],
)
cc_library(
name = "cpython_header_only",
srcs = [
":cpython_includes",
],
copts = ["-isystem include"],
)
But I get the error
root@193498bdc412:/src# bazel build //...
ERROR: /src/3rd_party/BUILD:65:12: in srcs attribute of cc_library rule //3rd_party:cpython_header_only: '//3rd_party:cpython_includes' does not produce any cc_library srcs files (expected .cc, .cpp, .cxx, .c++, .C, .c, .h, .hh, .hpp, .ipp, .hxx, .inc, .inl, .H, .S, .s, .asm, .a, .lib, .pic.a, .lo, .lo.lib, .pic.lo, .so, .dylib, .dll, .o, .obj or .pic.o)
ERROR: Analysis of target '//3rd_party:cpython_header_only' failed; build aborted: Analysis of target '//3rd_party:cpython_header_only' failed; build aborted
INFO: Elapsed time: 0.638s
INFO: 0 processes.
Any ideas?
from rules_foreign_cc.
I was able to get things to work with this variant
cc_library(
name = "cpython_header_only",
hdrs = [
":cpython_includes",
],
copts = ["-isystem include"],
)
though not sure why that fixed the problem
from rules_foreign_cc.
Another curious error
If I use this version (which works better when the project is used externally bazelbuild/bazel#2670 )
cc_library(
name = "cpython_header_only",
hdrs = [
":cpython_includes",
],
includes = ["include"],
)
I get
ERROR: /src/src/lib/BUILD:9:1: undeclared inclusion(s) in rule '//src/lib:bridge_tracer_lib':
this rule is missing dependency declarations for the following files included by 'src/lib/python_object_wrapper.cpp':
'bazel-out/k8-fastbuild/genfiles/3rd_party/include/Python.h'
'bazel-out/k8-fastbuild/genfiles/3rd_party/include/patchlevel.h'
...
from rules_foreign_cc.
@irengrig - this approach doesn't quite work. It still links in dependencies. This is my setup for a cpython_header_only library.
But when I build I get
bazel build -s //:bridge_tracer.so
...
/usr/bin/gcc -shared -o bazel-out/k8-fastbuild/bin/bridge_tracer.so -Wl,-S '-fuse-ld=gold' -Wl,-no-as-needed -Wl,-z,relro,-z,now -B/usr/bin -pass-exit-codes -Wl,@bazel-out/k8-fastbuild/bin/bridge_tracer.so-2.params
And bazel-out/k8-fastbuild/bin/bridge_tracer.so-2.params
has the cpython dependencies linked in
cat bazel-out/k8-fastbuild/bin/bridge_tracer.so-2.params
...
-whole-archive
bazel-out/k8-fastbuild/genfiles/3rd_party/openssl/lib/libssl.a
-no-whole-archive
from rules_foreign_cc.
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_foreign_cc!
from rules_foreign_cc.
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"
from rules_foreign_cc.
Related Issues (20)
- cmake_options in Bzlmod example HOT 5
- Mirror all downloads to mirror.bazel.build
- ToolchainResolution on mac-aarch64 HOT 1
- Consider adding `toolchains` parameter to `configure_make_variant`
- Absolute paths in native_tool_toolchain result in "Can not copy" error
- Issue enabling `layering_check` HOT 2
- Meson lacks support for cross compilation HOT 4
- Enable changing cmake versions with bzlmod HOT 1
- Call to build toolchains (rules_foreign_cc_dependencies()) is not working
- Put toolchain default library flags in LDFLAGS broke many projects on Darwin
- using cmake to build abseil failed HOT 2
- RFC: Add support for `CPPFLAGS` and clean up `CxxFlagsInfo`
- Default rules_foreign_cc_dependencies call fails - `no such package '@@rules_foreign_cc//toolchains'` HOT 4
- meson_with_requirements causes build configuration explode
- Help with Openssl for Bazel HOT 1
- invalid registered toolchain '@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain': No repository visible as '@rules_foreign_cc' from main repository HOT 9
- cc_shared_library targets cannot be used as deps
- [Bazel CI] CcMesonMakeRule Fails with Linker Error, Build Fails HOT 3
- configure_make set linkopts with "$$EXT_BUILD_DEPS$$"" will let linker cannot find coresponding directory
- configure stage inconsistent with compiling stage when specify --sysroot for building BootstrapGNUMake HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_foreign_cc.