-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdependencies.SConscript
More file actions
125 lines (94 loc) · 4 KB
/
dependencies.SConscript
File metadata and controls
125 lines (94 loc) · 4 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Dependencies
# Here, we handle individual dependencies as needed.
import os
Import("env")
# VERSIONS ------------------------------------------------
env['ESP_RUST_VERSION'] = '1.70.0.0'
env['RUST_VERSION'] = '1.70.0'
env['OPENCAN_VERSION'] = 'b014266'
# ---------------------------------------------------------
# venv & pip ----------------------------------------------
env['VENV_DIR'] = env.Dir('venv')
# Make the venv
env.Command(
env['VENV_DIR'],
[],
'python3 -m venv $TARGET'
)
# Add the venv/bin folder to PATH
env.PrependENVPath('PATH', env['VENV_DIR'].Dir('bin').abspath)
# Set VIRTUAL_ENV
env['ENV']['VIRTUAL_ENV'] = env['VENV_DIR'].abspath
# pip packages
REQUIREMENTS = env.File('$REPO_ROOT/requirements.txt')
[pip_deps_builder] = env.Command(
env['VENV_DIR'].File('.requirements-installed'),
REQUIREMENTS,
[
'$VENV_DIR/bin/pip3 install -r $SOURCE',
'touch $TARGET'
]
)
env.Alias('deps-pip', pip_deps_builder)
env['PIP_PACKAGES'] = pip_deps_builder
# ---------------------------------------------------------
# Rust ----------------------------------------------------
# We'll install into deps/rust/VERSION/ and make a symlink
# deps/rust/current that points to it. This is so we can keep
# multiple versions around in deps/ at once (in case you're switching
# branches etc) and not have them be redownloaded every 2 seconds.
RUST_HOME = env.Dir('rust/$RUST_VERSION')
RUST_TOOLS_PATH = RUST_HOME.Dir('bin')
RUST_CURRENT_PATH = env.Dir('rust/current')
env['CARGO'] = RUST_TOOLS_PATH.File('cargo')
env['ENV']['CARGO_HOME'] = RUST_HOME.abspath
env['ENV']['RUSTUP_HOME'] = RUST_HOME.abspath
# https://blog.rust-lang.org/inside-rust/2023/01/30/cargo-sparse-protocol.html
env['ENV']['CARGO_REGISTRIES_CRATES_IO_PROTOCOL'] = 'sparse'
rust_install_builder = env.Command(
env['CARGO'], # picking cargo as the target file
[],
'curl https://sh.rustup.rs -sSf | ' \
'sh -s -- -y --no-modify-path --default-toolchain $RUST_VERSION',
)
# make symlink
if os.path.realpath(RUST_CURRENT_PATH.abspath) != RUST_HOME.abspath:
env.Execute(f'mkdir -p {RUST_CURRENT_PATH.up().abspath}')
env.Execute(f'ln -sfn {RUST_HOME.abspath} {RUST_CURRENT_PATH.abspath}')
env.PrependENVPath('PATH', RUST_TOOLS_PATH.abspath)
env.Alias('deps-rust', rust_install_builder)
# ---------------------------------------------------------
# ESP Rust ------------------------------------------------
# Note that this will install in the rust/x.x.x path, not rust/, whatever
env['ESPUP'] = RUST_TOOLS_PATH.File('espup')
# espup
espup_install_builder = env.Command(
env['ESPUP'],
env['CARGO'],
'$CARGO install espup@0.8.0 --locked'
)
ESP_RUST_PATH = env.Dir(env['ENV']['RUSTUP_HOME']).Dir('toolchains/espr')
ESP_RUST_ENV_FILE = env.Dir(env['ENV']['RUSTUP_HOME']).File('esp-env.sh')
env['ESP_CARGO'] = ESP_RUST_PATH.File('bin/cargo')
esp_rust_install_builder = env.Command(
env['ESP_CARGO'],
env['ESPUP'],
f'$ESPUP install --name espr -t esp32s3 -f {ESP_RUST_ENV_FILE.abspath} -v $ESP_RUST_VERSION'
)
# Update these as needed from esp-env.sh
env.PrependENVPath('PATH', ESP_RUST_PATH.Dir('xtensa-esp32s3-elf/esp-2021r2-patch5-8_4_0/xtensa-esp32s3-elf/bin'))
env.PrependENVPath('PATH', ESP_RUST_PATH.Dir('riscv32-esp-elf/esp-2021r2-patch5-8_4_0/riscv32-esp-elf/bin'))
env['ENV']['LIBCLANG_PATH'] = ESP_RUST_PATH.Dir('xtensa-esp32-elf-clang/esp-16.0.0-20230516/esp-clang/lib').abspath
env.Alias('deps-esp-rust', esp_rust_install_builder)
# ---------------------------------------------------------
# OpenCAN -------------------------------------------------
env['OPENCAN_CLI'] = env.Dir(env['ENV']['CARGO_HOME']).File('bin/opencan-cli')
# Note that we have $CARGO_HOME set above. Cargo will install packages there.
[opencan_cli_builder] = env.Command(
env['OPENCAN_CLI'],
env['CARGO'],
'$CARGO install --locked ' \
'--git https://github.com/opencan/opencan --rev $OPENCAN_VERSION'
)
env.Alias('deps-opencan', opencan_cli_builder)
# ---------------------------------------------------------