https://github.com/comradeprogrammer/simplecpptest
https://github.com/comradeprogrammer/simplecpptest
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/comradeprogrammer/simplecpptest
- Owner: ComradeProgrammer
- Created: 2025-04-22T12:38:19.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-04-22T12:39:27.000Z (10 months ago)
- Last Synced: 2025-05-05T20:19:06.517Z (9 months ago)
- Language: Starlark
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Stage 3
In this stage we step it up and showcase how to integrate multiple ```cc_library``` targets from different packages.
Below, we see a similar configuration from Stage 2, except that this BUILD file is in a subdirectory called lib. In Bazel, subdirectories containing BUILD files are known as packages. The new property ```visibility``` will tell Bazel which package(s) can reference this target, in this case the ```//main``` package can use ```hello-time``` library.
```
cc_library(
name = "hello-time",
srcs = ["hello-time.cc"],
hdrs = ["hello-time.h"],
visibility = ["//main:__pkg__"],
)
```
To use our ```hello-time``` library, an extra dependency is added in the form of //path/to/package:target_name, in this case, it's ```//lib:hello-time```
```
cc_binary(
name = "hello-world",
srcs = ["hello-world.cc"],
deps = [
":hello-greet",
"//lib:hello-time",
],
)
```
To build this example, use
```
bazel build //main:hello-world
```
# simpleCppTest