Skip to content
Open
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,17 +1001,20 @@ def bootstrap_out(self):

>>> rb = RustBuild()
>>> rb.build_dir = "build"
>>> rb.bootstrap_binary() == os.path.join("build", "bootstrap")
>>> rb.bootstrap_out() == os.path.join("build", "bootstrap", rb.build)
True
"""
return os.path.join(self.bootstrap_cargo_target_dir(), self.build)

def bootstrap_cargo_target_dir(self):
return os.path.join(self.build_dir, "bootstrap")

def bootstrap_binary(self):
"""Return the path of the bootstrap binary

>>> rb = RustBuild()
>>> rb.build_dir = "build"
>>> rb.bootstrap_binary() == os.path.join("build", "bootstrap",
>>> rb.bootstrap_binary() == os.path.join("build", "bootstrap", rb.build,
... "debug", "bootstrap")
True
"""
Expand All @@ -1033,8 +1036,7 @@ def build_bootstrap(self):
print("::endgroup::")

def build_bootstrap_cmd(self, env):
"""For tests."""
build_dir = os.path.join(self.build_dir, "bootstrap")
build_dir = self.bootstrap_cargo_target_dir()
if self.clean and os.path.exists(build_dir):
shutil.rmtree(build_dir)
# `CARGO_BUILD_TARGET` breaks bootstrap build.
Expand Down Expand Up @@ -1120,10 +1122,14 @@ def build_bootstrap_cmd(self, env):
self.cargo(),
"build",
"--jobs=" + self.jobs,
"--target",
self.build,
"--manifest-path",
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml"),
"-Zroot-dir=" + self.rust_root,
"--bins",
]

# verbose cargo output is very noisy, so only enable it with -vv
args.extend("--verbose" for _ in range(self.verbose - 1))
if self.verbose < 0:
Expand Down
15 changes: 15 additions & 0 deletions src/bootstrap/bootstrap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,21 @@ def test_cargoflags(self):
args, _ = self.build_args(env={"CARGOFLAGS": "--timings"})
self.assertTrue("--timings" in args)

def test_build_bootstrap_uses_explicit_build_target(self):
args, _ = self.build_args(
configure_args=[
"--set",
"build.cargo=" + sys.executable,
"--set",
"build.rustc=" + sys.executable,
],
args=["--build", "host-tuple"],
)
expected_build = os.environ.get("BUILD_PLATFORM", "host-tuple")
self.assertEqual(args[1], "build")
self.assertTrue("--bins" in args)
self.assertEqual(args[args.index("--target") + 1], expected_build)

def test_warnings(self):
for toml_warnings in ["false", "true", None]:
configure_args = []
Expand Down
Loading