-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile.toml
86 lines (72 loc) · 2.02 KB
/
Makefile.toml
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
env_scripts = [
'''
#!@duckscript
if not is_empty "${CARGO_BUILD_TARGET}"
set_env CARGO_EXTRA_FLAGS "${CARGO_EXTRA_FLAGS} --target=${CARGO_BUILD_TARGET}"
end
'''
]
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
# override $CARGO with "cross"
CARGO = { value = "cross", condition = { env_true = ["USE_CROSS"] } }
[env.development]
OUTPUT_DIR_NAME = "debug"
CARGO_EXTRA_FLAGS = ""
[env.production]
OUTPUT_DIR_NAME = "release"
CARGO_EXTRA_FLAGS = "--release"
[config]
default_to_workspace = false
[tasks.run]
dependencies = ["build"]
script_runner = "@shell"
script = '''
"$CARGO" run --bin=proot-rs ${CARGO_EXTRA_FLAGS} -- ${@}
'''
[tasks.build]
clear = true
dependencies = ["build-loader", "copy-loader"]
script_runner = "@shell"
script = '''
"$CARGO" build --bin=proot-rs ${CARGO_EXTRA_FLAGS}
echo -e "proot-rs:\t$(realpath target/${CARGO_BUILD_TARGET}/${OUTPUT_DIR_NAME}/proot-rs)"
echo -e "loader-shim:\t$(realpath target/${CARGO_BUILD_TARGET}/${OUTPUT_DIR_NAME}/loader-shim)"
'''
[tasks.build-loader]
script_runner = "@shell"
script = '''
RUSTFLAGS="-C panic=abort -C link-self-contained=no" "$CARGO" build --bin=loader-shim --features="build-binary" ${CARGO_EXTRA_FLAGS}
'''
[tasks.copy-loader]
dependencies = ["build-loader"]
script_runner = "@shell"
script = '''
cp target/${CARGO_BUILD_TARGET}/${OUTPUT_DIR_NAME}/loader-shim proot-rs/src/kernel/execve/
'''
[tasks.test]
clear = true
dependencies = ["unit-test", "integration-test"]
[tasks.unit-test]
script_runner = "@shell"
script = '''
if [ -z "${PROOT_TEST_ROOTFS}" ]; then
export PROOT_TEST_ROOTFS="$(pwd)/rootfs"
fi
"$CARGO" test --package=proot-rs ${CARGO_EXTRA_FLAGS} ${@} -- --test-threads=1 --nocapture
'''
[tasks.integration-test]
dependencies = ["build"]
script_runner = "@shell"
script = '''
if [ -z "${PROOT_TEST_ROOTFS}" ]; then
export PROOT_TEST_ROOTFS="$(pwd)/rootfs"
fi
if [ -z "${PROOT_RS}" ]; then
export PROOT_RS="$(realpath target/${CARGO_BUILD_TARGET}/${OUTPUT_DIR_NAME}/proot-rs)"
fi
bats -r tests
'''
[tasks.default]
clear = true
dependencies = ["build"]