forked from algorithm-archivists/algorithm-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcargo.py
41 lines (31 loc) · 987 Bytes
/
cargo.py
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
from SCons.Builder import Builder
from SCons.Script import Move
import SCons.Util
class ToolCargoWarning(SCons.Warnings.SConsWarning):
pass
class CargoNotFound(ToolCargoWarning):
pass
SCons.Warnings.enableWarningClass(ToolCargoWarning)
def _detect(env):
try:
return env['cargo']
except KeyError:
pass
cargo = env.WhereIs('cargo')
if cargo:
return cargo
SCons.Warnings.warn(CargoNotFound, 'Could not detect cargo')
def exists(env):
return env.Detect('cargo')
def generate(env):
env['CARGO'] = _detect(env)
env['CARGOFLAGS'] = []
env['MANIFEST'] = []
rust_cargo_builder = Builder(
action=['"$CARGO" build $CARGOFLAGS --bins --manifest-path $MANIFEST',
Move('$TARGET$PROGSUFFIX',
'$SOURCE_DIR/target/debug/main$PROGSUFFIX')
],
suffix='$PROGSUFFIX',
)
env.Append(BUILDERS={'cargo': rust_cargo_builder})