Skip to content

Commit

Permalink
Add and use python bootstrap toolchain (#18)
Browse files Browse the repository at this point in the history
Summary:
The toolchains currently have a cycle which causes them to hang, since the python toolchain depends on itself to initialise itself. This breaks that.

Pull Request resolved: #18

Reviewed By: ndmitchell

Differential Revision: D40020345

Pulled By: ndmitchell

fbshipit-source-id: f6f50791c8cb36bce73013cb81c43bd108f5f5e1
  • Loading branch information
arlyon authored and facebook-github-bot committed Oct 6, 2022
1 parent e1d6599 commit dc80c88
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions examples/prelude/.buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ name=BUILD
prelude = ./prelude
toolchains = ./toolchains
root = .
platform = no
buck = no
fbcode = no
fbsource = no
ovr_config = no
6 changes: 3 additions & 3 deletions examples/prelude/toolchain/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load(":cxx_hacks.bzl", "cxx_hacks")
load(":toolchain.bzl", "cxx_toolchain", "python_toolchain")
load(":toolchain.bzl", "cxx_toolchain", "python_toolchain", "python_bootstrap_toolchain")

# Required to support the $(cxx-header-tree) macro
cxx_hacks(
Expand All @@ -21,7 +21,7 @@ python_toolchain(
# the bootstrap toolchain is used
# to poentially initialize other
# toolchains
python_toolchain(
python_bootstrap_toolchain(
name="python_bootstrap",
visibility=["PUBLIC"],
)
)
16 changes: 16 additions & 0 deletions examples/prelude/toolchain/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ load(
"PythonPlatformInfo",
"PythonToolchainInfo",
)
load(
"@prelude//python_bootstrap:python_bootstrap.bzl",
"PythonBootstrapToolchainInfo",
)

DEFAULT_MAKE_COMP_DB = "prelude//cxx/tools:make_comp_db"
DEFAULT_MAKE_PEX_INPLACE = "prelude//python/tools:make_pex_inplace"
Expand Down Expand Up @@ -130,3 +134,15 @@ python_toolchain = rule(
},
is_toolchain_rule = True,
)

def _python_bootstrap_toolchain(_ctx):
return [
DefaultInfo(),
PythonBootstrapToolchainInfo(interpreter = "python"),
]

python_bootstrap_toolchain = rule(
impl = _python_bootstrap_toolchain,
attrs = {},
is_toolchain_rule = True,
)

0 comments on commit dc80c88

Please sign in to comment.