Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: support variant configurations with tags? #96

Open
paulhankin opened this issue Oct 5, 2021 · 0 comments
Open

Feature Request: support variant configurations with tags? #96

paulhankin opened this issue Oct 5, 2021 · 0 comments

Comments

@paulhankin
Copy link
Contributor

(perhaps related to: #16)

If I write a test binary, I'd like all of its dependencies to be compiled with certain different compiler flags. (for example perhaps: -g, -O0 -Werror -DUNIT_TEST replacing -O3). One can define your own testing.Binary and testing.Library but if they depend on an existing library, that library will be compiled with different compiler flags.

It's currently possible to define a separate toolchain for testing (one per toolchain you wish to use). But not very convenient as apart from the work of defining the toolchain, you need to remember to use the testing toolchain to run your test.

I can imagine other variants: for example a code coverage build, or a profiling build.

It seems like these variants depend on the type of the top-level target, and are orthogonal to the cc-target. For example, a unit test binary is always a unit test, and should always be compiled with a testing toolchain.

The rest of this issue suggests one possible solution to the user-visible part of the API for this, but the design space is large.

I wonder if it's possible to have a target specify some tags. Those tags are propagated to all dependencies when building. The toolchains could behave differently based on the tags (eg: setting compiler flags differently), and rules could also depend on these tags (eg: including or excluding files based on tags -- a bit like go's build tags, although specified in the BUILD.go rather than in the source files). Toolchains could also specify tags, and tags could be specified on the command-line. There would probably have to be a doc specifying standard tags.

This could also give a basis for a simple API for rules to vary based on the build variant (again quite a lot like go build tags).

As an example, this would make a unit test with all files (including those in other.OtherLib) compiled with the same compiler flags.

var AbcTest = cc.Binary{
Out:  out("AbcTest"),
Srcs: ins("AbcTest.cc"),
Deps: []cc.Dep{testing.TestMain, math.LibAbc, other.OtherLibrary},
    Tags: tags("test"),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant