1import os
2import toml
3
4rust_src = os.environ['RUSTC_SRC']
5orig_cargo = os.environ['ORIG_CARGO'] if 'ORIG_CARGO' in os.environ else None
6
7base = {
8 'package': {
9 'name': 'nixpkgs-sysroot-stub-crate',
10 'version': '0.0.0',
11 'authors': ['The Rust Project Developers'],
12 'edition': '2018',
13 },
14 'dependencies': {
15 'compiler_builtins': {
16 'version': '0.1.0',
17 'features': ['rustc-dep-of-std', 'mem'],
18 },
19 'core': {
20 'path': os.path.join(rust_src, 'core'),
21 },
22 'alloc': {
23 'path': os.path.join(rust_src, 'alloc'),
24 },
25 },
26 'patch': {
27 'crates-io': {
28 'rustc-std-workspace-core': {
29 'path': os.path.join(rust_src, 'rustc-std-workspace-core'),
30 },
31 'rustc-std-workspace-alloc': {
32 'path': os.path.join(rust_src, 'rustc-std-workspace-alloc'),
33 },
34 },
35 },
36}
37
38if orig_cargo is not None:
39 with open(orig_cargo, 'r') as f:
40 src = toml.loads(f.read())
41 if 'profile' in src:
42 base['profile'] = src['profile']
43
44out = toml.dumps(base)
45
46with open('Cargo.toml', 'x') as f:
47 f.write(out)