Skip to content

Commit

Permalink
python: Basic Starlark implementation of PyCcLinkParamsProvider
Browse files Browse the repository at this point in the history
Work towards #15897

PiperOrigin-RevId: 508420073
Change-Id: I0c681a0b70f0ea5111e3f8cca7b0c9cbe61e723a
  • Loading branch information
rickeylev authored and hvadehra committed Feb 14, 2023
1 parent 95bfb5a commit 3661fa6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main/starlark/builtins_bzl/common/python/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

load(":common/python/semantics.bzl", "TOOLS_REPO")

_CcInfo = _builtins.toplevel.CcInfo

DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python3"
DEFAULT_BOOTSTRAP_TEMPLATE = "@" + TOOLS_REPO + "//tools/python:python_bootstrap_template.txt"
_PYTHON_VERSION_VALUES = ["PY2", "PY3"]
Expand Down Expand Up @@ -140,7 +142,7 @@ def _PyInfo_init(
"has_py3_only_sources": has_py2_only_sources,
}

StarlarkPyInfo, _unused_raw_ctor = provider(
StarlarkPyInfo, _unused_raw_py_info_ctor = provider(
"Encapsulates information provided by the Python rules.",
init = _PyInfo_init,
fields = {
Expand All @@ -167,5 +169,21 @@ is recommended to use `default` order (the default).

PyInfo = _builtins.toplevel.PyInfo

def _PyCcLinkParamsProvider_init(cc_info):
return {
"cc_info": _CcInfo(linking_context = cc_info.linking_context),
}

# buildifier: disable=name-conventions
StarlarkPyCcLinkParamsProvider, _unused_raw_py_cc_link_params_provider_ctor = provider(
doc = ("Python-wrapper to forward CcInfo.linking_context. This is to " +
"allow Python targets to propagate C++ linking information, but " +
"without the Python target appearing to be a valid C++ rule dependency"),
init = _PyCcLinkParamsProvider_init,
fields = {
"cc_info": "A CcInfo instance; it has only linking_context set",
},
)

# TODO(b/203567235): Re-implement in Starlark
PyCcLinkParamsProvider = _builtins.toplevel.PyCcLinkParamsProvider # buildifier: disable=name-conventions

0 comments on commit 3661fa6

Please sign in to comment.