Skip to content

Commit 8bf46f8

Browse files
committed
Made the try example in rsomla1 to properly use lib as shared library. Added some docs
1 parent 1ef815f commit 8bf46f8

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,5 @@ common --experimental_google_legacy_api
143143
# common --repository_cache=f:/b/r
144144
# startup --output_user_root=f:/b/u
145145
try-import %workspace%/../top.bazelrc
146+
147+
common --experimental_cc_static_library

x/rsomla1/BUILD.bazel

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
1+
# Plain C/C++ library declaration
2+
cc_library(
3+
name = "lib_plain",
4+
srcs = ["lib.cc"],
5+
deps = ["@otel_sdk//:dll"],
6+
)
7+
8+
# Make shared library from it (.dll/.so/.dylib)
9+
cc_shared_library(
10+
name = "lib_dll_or_so",
11+
deps = [":lib_plain"],
12+
)
13+
14+
# Extract the .imp/.lo file.
15+
filegroup(
16+
name = "lib_imp_or_lo",
17+
srcs = [":lib_dll_or_so"],
18+
output_group = "interface_library"
19+
)
20+
21+
# Re-import back using the .imp/.lo + .dll/.so/.dylib
22+
cc_import(
23+
name = "lib",
24+
interface_library = ":lib_imp_or_lo",
25+
shared_library = ":lib_dll_or_so",
26+
)
27+
128
cc_test(
229
name = "try",
3-
srcs = ["try.cc", "lib.cc"],
4-
deps = ["@otel_sdk//:dll"],
30+
srcs = ["try.cc"],
31+
deps = [
32+
"@otel_sdk//:dll",
33+
":lib",
34+
],
535
)

x/rsomla1/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,21 @@ INFO: Elapsed time: 11.789s, Critical Path: 9.35s
6262
INFO: 5 processes: 1 internal, 4 local.
6363
INFO: Build completed successfully, 5 total actions
6464
```
65+
66+
# Added proper lib.dll (lib_dll_or_so.dll)
67+
68+
- Bin folder had this, note the `lib_or_so.dll` and `try.exe`
69+
70+
![bin_folder](bin_folder.png)
71+
72+
- Here is what `lib_dll_or_so.dll` ended up importing from `otel_sdk.dll`
73+
74+
![lib_dll_or_so](lib_dll_or_so.png)
75+
76+
- Here is what `try.exe` refernece from `lib_dll_or_so.dll` - e.g. `foo`
77+
78+
![try_importing_lib](try_importing_lib.png)
79+
80+
- And what `try.exe` references from `otel_sdk.dll`
81+
82+
![try_importing_otel_sdk](try_importing_otel_sdk.png)

0 commit comments

Comments
 (0)