Skip to content

Commit dc8afd8

Browse files
committed
Delete rust-toolchain setup
1 parent 07937bc commit dc8afd8

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

tests/lit/lit/formats/Cpp2RustTest.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import os
1212
import re
1313
import shutil
14-
import tomli
1514

1615

1716
MODELS = ("refcount", "unsafe")
@@ -42,12 +41,6 @@ def matches(match):
4241
if models is None or models.strip() == "":
4342
return True
4443
return model in re.split(r"\s*,\s*", models.strip())
45-
os.path.join(os.path.dirname(__file__), "../../../../build/tmp/cargo-target")
46-
)
47-
48-
49-
def cargo_env():
50-
return dict(os.environ, CARGO_TARGET_DIR=os.path.abspath(shared_target_dir()))
5144

5245
xfail_m = RE_XFAIL.search(text)
5346
xfail = xfail_m is not None and model in re.split(r"\s*,\s*", xfail_m.group(1))
@@ -199,18 +192,13 @@ def build_cpp(self):
199192

200193
def build_rust(self):
201194
exp = self.expectations
202-
rust_version = read_rust_version()
203195
self.pkg_name = "test_" + re.sub(r"[^a-zA-Z0-9_]", "_", self.tmp_dir.name)
204196

205-
(self.tmp_dir / "rust-toolchain.toml").write_text(
206-
f'[toolchain]\nchannel = "{rust_version}"\n'
207-
)
208197
(self.tmp_dir / "Cargo.toml").write_text(f"""
209198
[package]
210199
name = "{self.pkg_name}"
211200
version = "0.1.0"
212201
edition = "2021"
213-
rust-version = "{rust_version}"
214202
215203
[[bin]]
216204
name = "{self.pkg_name}"
@@ -221,7 +209,7 @@ def build_rust(self):
221209
libcc2rs = {{ path = "../../../libcc2rs" }}
222210
""")
223211

224-
cmd = ["cargo", "build", "--release", "--quiet"]
212+
cmd = ["cargo", "+" + read_rust_version(), "build", "--release", "--quiet"]
225213
_, err, returncode = lit.util.executeCommand(
226214
cmd, str(self.tmp_dir), env=cargo_env()
227215
)
@@ -332,8 +320,15 @@ def getTestsInDirectory(self, testSuite, path_in_suite, litConfig, localConfig):
332320

333321

334322
def read_rust_version():
335-
toolchain_path = Path(__file__).parent / "../../../../libcc2rs/rust-toolchain.toml"
336-
return tomli.loads(toolchain_path.read_text())["toolchain"]["channel"]
323+
toolchain_path = os.path.join(
324+
os.path.dirname(__file__), "../../../../cmake/rust-toolchain.cmake"
325+
)
326+
with open(toolchain_path, "r") as f:
327+
for line in f:
328+
m = re.match(r'set\(RUST_STABLE_VERSION\s+"([^"]+)', line)
329+
if m:
330+
return m.group(1)
331+
raise Exception("could not find rust version in " + toolchain_path)
337332

338333

339334
def shared_target_dir():

0 commit comments

Comments
 (0)