Conversation
caf4a64 to
b9635b9
Compare
- feat: detect and honor `compilation_mode` flag - feat: build with debug settings if `compilation_mode=dbg` - feat: ability to build a shared library - feat: build with `tool:coverage` if coverage is enabled and a test-only target is being built - docs: add doc which explains shared library feature - docs: add doc for built settings integration (more to come) Relates-To: #78 Relates-To: #85 Signed-off-by: Sam Gammon <sam@elide.ventures>
b613df4 to
31130c5
Compare
b9635b9 to
bb22f6d
Compare
|
Kudos, SonarCloud Quality Gate passed! |
| config_setting( | ||
| name = "coverage", | ||
| values = { | ||
| "collect_code_coverage": "true", | ||
| }, | ||
| ) |
There was a problem hiding this comment.
this may need to use ctx.configuration.coverage_enabled instead
There was a problem hiding this comment.
That would be better as it takes --instrumentation_filter into account.
| def _configure_native_test_flags(ctx, args): | ||
| """Configure native testing flags; only applies if we are building a test-only target. |
There was a problem hiding this comment.
laying groundwork for an upcoming native_image_test rule
| if ctx.attr.shared_library: | ||
| args.add("--shared") |
There was a problem hiding this comment.
note to self: add native_image_shared_library as alias which selects header outputs automatically in addition to binary shared lib
| # append extra arguments last | ||
| for arg in ctx.attr.extra_args: | ||
| args.add(arg) |
There was a problem hiding this comment.
fixes bug where extra args were not last
There was a problem hiding this comment.
Could be args.add_all, but doesn't matter too much
| "env": native_toolchain.env, | ||
| "execution_requirements": {k: "" for k in native_toolchain.execution_requirements}, | ||
| "progress_message": "Compiling native image %{label}", | ||
| "progress_message": "Native Image (__mode__) %{label}".replace("__mode__", _build_action_message(ctx)), |
There was a problem hiding this comment.
This will still end up creating a new retained string per target. Instead, you could have a dict of fixed strings per mode.








Summary
Begins integrating Bazel's built-in settings with Native Image options. First up is
compilation_mode, allowing-O2and-Obto be passed ("optimizations on", "build speed mode on", respectively).-Obis passed when-c fastbuildis set, and-O2is passed when-c optis set.The ability to build a shared library has also been added via the new
shared_libraryattribute. Docs have been added for both, but there is no way to reliably test these yet. Targeting #80 for release.Related issues:
Changelog
compilation_modeflagcompilation_mode=dbgtool:coverageif coverage is enabled and a test-only target is being built