aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/build-support/rust/sysroot/cargo.py
blob: 09f6fba6d1c81321b69d92a1fb4bd5c3a8272047 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import toml

rust_src = os.environ['RUSTC_SRC']
orig_cargo = os.environ['ORIG_CARGO'] if 'ORIG_CARGO' in os.environ else None

base = {
  'package': {
    'name': 'alloc',
    'version': '0.0.0',
    'authors': ['The Rust Project Developers'],
    'edition': '2018',
  },
  'dependencies': {
    'compiler_builtins': {
      'version': '0.1.0',
      'features': ['rustc-dep-of-std', 'mem'],
    },
    'core': {
      'path': os.path.join(rust_src, 'libcore'),
    },
  },
  'lib': {
    'name': 'alloc',
    'path': os.path.join(rust_src, 'liballoc/lib.rs'),
  },
  'patch': {
    'crates-io': {
      'rustc-std-workspace-core': {
        'path': os.path.join(rust_src, 'tools/rustc-std-workspace-core'),
      },
    },
  },
}

if orig_cargo is not None:
  with open(orig_cargo, 'r') as f:
    src = toml.loads(f.read())
    if 'profile' in src:
      base['profile'] = src['profile']

out = toml.dumps(base)

with open('Cargo.toml', 'x') as f:
  f.write(out)