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

Do not compile native targets if they contain just header files #6692

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/python/pants/backend/native/tasks/native_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class NativeCompile(NativeTask, AbstractClass):
source_target_constraint = None
dependent_target_constraint = SubclassesOf(ExternalNativeLibrary, NativeLibrary)

HEADER_EXTENSIONS = ('.h', '.hpp')

# `NativeCompile` will use `workunit_label` as the name of the workunit when executing the
# compiler process. `workunit_label` must be set to a string.
@classproperty
Expand Down Expand Up @@ -209,7 +211,7 @@ def _compile(self, compile_request):
"""
sources = compile_request.sources

if len(sources) == 0:
if len(sources) == 0 and not any(s for s in sources if not s.endswith(self.HEADER_EXTENSIONS)):
# TODO: do we need this log message? Should we still have it for intentionally header-only
# libraries (that might be a confusing message to see)?
self.context.log.debug("no sources in request {}, skipping".format(compile_request))
Expand Down