-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: bazel settings integration #86
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may need to use ctx.configuration.coverage_enabled
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
laying groundwork for an upcoming native_image_test
rule
if ctx.attr.shared_library: | ||
args.add("--shared") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes bug where extra args were not last
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be args.add_all
, but doesn't matter too much
run_params = { | ||
"outputs": [binary], | ||
"executable": graal, | ||
"inputs": inputs, | ||
"mnemonic": "NativeImage", | ||
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-O2
and-Ob
to be passed ("optimizations on", "build speed mode on", respectively).-Ob
is passed when-c fastbuild
is set, and-O2
is passed when-c opt
is set.The ability to build a shared library has also been added via the new
shared_library
attribute. Docs have been added for both, but there is no way to reliably test these yet. Targeting #80 for release.Related issues:
Changelog
compilation_mode
flagcompilation_mode=dbg
tool:coverage
if coverage is enabled and a test-only target is being built