bazel-contrib / bazel-contrib/rules_foreign_cc

bazel project will rebuild external repository ignoring cache actions

Open
#1,064 1 comment 0 reactions 0 assignees View on GitHub
Can Close?
Dominant language
Starlark
Stars
737
Forks
270
PR merge metrics
No merged PRs in 30d

Description

[**bazel let me to find helps here**](https://github.com/bazelbuild/bazel/issues/18768#issue-1774198373)

### Description of the bug:

In WSL, I imported a cmake project (poco) into a bazel project by **rules_foreign_cc**
Every time When I start a new shell and` bazel build`
it will rebuild from the beginning , wasting time.

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
After building, I will export LD_LIBRARY_PATH at current shell, run my binary.
And then, I change some codes , add some logs, and start building, it will rebuild **poco** again.
WORKSPACE :
```
workspace(name = "xxxx")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//bazel/external:repositories.bzl", "build_all_content")
BUILD_ALL_CONTENT = build_all_content()


http_archive(
name = "rules_foreign_cc",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.8.0.tar.gz",
sha256 = "6041f1374ff32ba711564374ad8e007aef77f71561a7ce784123b9b4b88614fc",
strip_prefix = "rules_foreign_cc-0.8.0",
build_file = "//bazel/external:foreign_cc.BUILD",
)
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

rules_foreign_cc_dependencies()



http_archive(
name = "com_github_poco",
url = "https://github.com/pocoproject/poco/archive/refs/tags/poco-1.12.4-release.tar.gz",
sha256 = "71ef96c35fced367d6da74da294510ad2c912563f12cd716ab02b6ed10a733ef",
strip_prefix = "poco-poco-1.12.4-release",
# build_file = "//bazel/external:Poco.BUILD",
build_file_content = BUILD_ALL_CONTENT,
)
```
foreign_cc.BUILD:
```
licenses(["notice"]) # Apache 2

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

load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

cmake(
name = "poco",
cache_entries = {
"CMAKE_C_FLAGS": "-fPIC",
"CMAKE_CXX_FLAGS" : "-std=c++0x",
"ENABLE_XML" : "ON",
"ENABLE_JSON" : "ON",
"ENABLE_NET" : "ON",
"ENABLE_NETSSL" : "OFF",
"ENABLE_CRYPTO" : "OFF",
"ENABLE_JWT" : "OFF",
"ENABLE_DATA" : "OFF",
"ENABLE_DATA_SQLITE" : "OFF",
"ENABLE_DATA_MYSQL" : "OFF",
"ENABLE_DATA_POSTGRESQL" : "OFF",
"ENABLE_DATA_ODBC" : "OFF",
"ENABLE_MONGODB" : "OFF",
"ENABLE_REDIS" : "OFF",
"ENABLE_PDF" : "OFF",
"ENABLE_UTIL" : "ON",
"ENABLE_ZIP" : "OFF",
"ENABLE_SEVENZIP" : "OFF",
"ENABLE_APACHECONNECTOR" : "OFF",
"ENABLE_CPPPARSER" : "OFF",
"ENABLE_ENCODINGS" : "OFF",
"ENABLE_ENCODINGS_COMPILER" : "OFF",
"ENABLE_PAGECOMPILER" : "OFF",
"ENABLE_PAGECOMPILER_FILE2PAGE" : "OFF",
"ENABLE_POCODOC" : "OFF",
"ENABLE_TESTS" : "OFF",
"ENABLE_LONG_RUNNING_TESTS" : "OFF",
"POCO_UNBUNDLED" : "OFF",
},
lib_source = "@com_github_poco//:all",
out_shared_libs = select({
"//conditions:default": ["libPocoFoundation.so", "libPocoNet.so", "libPocoJSON.so", "libPocoXML.so", "libPocoUtil.so",],
}),
)
```
build_all function:
```
def build_all_content(exclude = []):
return """filegroup(name = "all", srcs = glob(["**"], exclude={}), visibility = ["//visibility:public"])""".format(repr(exclude))
```
my main BUILD:
```
cc_binary(
name = "xxxx",
srcs = ["main.cc",],
deps = ["//src/xx:xxx",
"@rules_foreign_cc//:poco"],
visibility = ["//visibility:public"],
)

```

### Which operating system are you running Bazel on?

WSL(windows 10)

### What is the output of `bazel info release`?

none

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

sudo apt install bazel
version is 6.2.1

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?

```text
none
```

### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

_No response_

### Have you found anything relevant by searching the web?

None

### Any other information, logs, or outputs that you want to share?

None

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the report with `bazel build` using the shown WORKSPACE, foreign_cc.BUILD, and main BUILD files, then inspect the rules_foreign_cc cmake entry point and the external repository setup. Confirm whether a new shell or changes to the main project cause Poco to rebuild, and use the expected result—a cached Poco build that is not repeated unnecessarily—as the completion check.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.