-
Hello, In my bazel setup, I am building docker images that contain a binary produced by a
However, I would like the image rules to be able to choose whether they want a debug or release version of the binary and to have this work independently of any My thought is to define two custom rules that wrap
But I'm not quite sure how to go about doing that either. Any advice would be appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
You can do this with transitions, there is a bit of a guide on how to do this in https://bazel.build/extending/config. Here's an example you can copy doing this too https://github.com/apple/swift-syntax/blob/098b177830c0d2e614b3757241b2572d758f9143/utils/bazel/opt_wrapper.bzl |
Beta Was this translation helpful? Give feedback.
-
Isn't a really simple solution to have two different `cc_binary` targets,
with different `copts` attributes? So,
cc_binary(
name = "foo_opt",
copts = ["opt"],
srcs = ["src/main.cpp"],
deps = [
"//common:common",
],
visibility = ["//visibility:public"],
)
cc_binary(
name = "foo_dbg",
copts = ["dbg"],
srcs = ["src/main.cpp"],
deps = [
"//common:common",
],
visibility = ["//visibility:public"],
)
…On Tue, Nov 7, 2023 at 3:10 PM Fabian Meumertzheim ***@***.***> wrote:
If you want a quick start, you can also use with_cfg.bzl, which has an
example of an opt_filegroup:
https://github.com/fmeum/with_cfg.bzl/blob/main/examples/opt_filegroup/opt_filegroup.bzl
—
Reply to this email directly, view it on GitHub
<#20089 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7UYRYUY53UCU2WWNE2QNLYDK5WTAVCNFSM6AAAAAA7B3Y43SVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TKMBUGI2DC>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Ah I guess that's too simple, since the `copts` will not propagate down to
the dependencies.
…On Tue, Nov 7, 2023 at 3:34 PM Ted Pudlik ***@***.***> wrote:
Isn't a really simple solution to have two different `cc_binary` targets,
with different `copts` attributes? So,
cc_binary(
name = "foo_opt",
copts = ["opt"],
srcs = ["src/main.cpp"],
deps = [
"//common:common",
],
visibility = ["//visibility:public"],
)
cc_binary(
name = "foo_dbg",
copts = ["dbg"],
srcs = ["src/main.cpp"],
deps = [
"//common:common",
],
visibility = ["//visibility:public"],
)
On Tue, Nov 7, 2023 at 3:10 PM Fabian Meumertzheim <
***@***.***> wrote:
> If you want a quick start, you can also use with_cfg.bzl, which has an
> example of an opt_filegroup:
> https://github.com/fmeum/with_cfg.bzl/blob/main/examples/opt_filegroup/opt_filegroup.bzl
>
> —
> Reply to this email directly, view it on GitHub
> <#20089 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AA7UYRYUY53UCU2WWNE2QNLYDK5WTAVCNFSM6AAAAAA7B3Y43SVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TKMBUGI2DC>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
You can do this with transitions, there is a bit of a guide on how to do this in https://bazel.build/extending/config. Here's an example you can copy doing this too https://github.com/apple/swift-syntax/blob/098b177830c0d2e614b3757241b2572d758f9143/utils/bazel/opt_wrapper.bzl