Comments (6)
Try this:
In your .buckconfig
file:
[gsoyka]
is_ci = false
In a BUCK
file somewhere:
build_go_binary = not read_config("gsoyka", "is_ci", false)
go_binary(
name = "hello",
srcs = glob(["*.go"]),
deps = [
"//go/hello/greeting:greeting",
],
) if build_go_binary else None
from buck2.
Thanks, that's helpful, and I think that can be made to work for my use case. If I have a rule defined, eg. my_rule()
, is it possible to generalize that logic to apply to all my_rule
instances within a project when the config value is set to true
?
from buck2.
You could make a macro. From a bzl file somewhere:
build_go_binary = not read_config("gsoyka", "is_ci", false)
def my_rule_macro(name, srcs, deps):
go_binary(
name = "hello",
srcs = glob(["*.go"]),
deps = [
"//go/hello/greeting:greeting",
],
) if build_go_binary else None
and have people call your macro instead of your rule.
from buck2.
That makes sense to me, when I tried the example I'm seeing the behavior I want, but am getting an error about a missing symbol. Is there something the macro can return that isn't None
that still does nothing?
from buck2.
Try:
if build_go_binary:
go_binary(…)
hard to say without seeing your error
from buck2.
Reading the docs, it seems like constraints added to our platform should work
Yeah, marking it target incompatible will cause it to be skipped without error when resolved in a pattern like //...
or //foo:
(but error when used explicitly like //foo:xyz
).
You could actually still use the config value to set things up if you wanted, somethign like this could work:
constraint_setting(
name = "none",
)
my_rule(
...
target_compatible_with = [] if read_config("foo", "is_ci", False) else [":none"]
)
from buck2.
Related Issues (20)
- Conflicting inputs on erlang build of Opentelemetry HOT 1
- error: Variable `typing` not found HOT 2
- Unable to `buck2 clean` a repo which uses `git_fetch()` on Windows
- `configured_alias` and configuration modifiers HOT 2
- review Go analysis.Pass.Module proposal
- Creating symbolic links to toolchains HOT 10
- Early-building some parts of graph HOT 7
- How to use "buck2 clean" or other commands to delete only the generated files (cache) without killing the daemon? HOT 2
- Question: how to pass dependencies that change state forward across a non-output-changing rule HOT 4
- buck2 : Is java supported as a part of buck2 HOT 2
- Share work across configurations by setting working directory for actions then canonicalizing that working directory in RE HOT 5
- How to use multiple execution platforms HOT 1
- Distributed project.ignore
- How to use c/aquery to find the dependents of an anon_target HOT 3
- Trouble linking Apple Frameworks HOT 1
- documentation mentions `frecli` which doesn't seem to be available publicly HOT 1
- Adding support for new languages HOT 5
- Java rules don't appear to be usable in OSS edition of buck2 HOT 2
- Builtin prelude support for running python in a venv?
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 buck2.