-
Notifications
You must be signed in to change notification settings - Fork 142
/
Makefile
85 lines (71 loc) · 1.85 KB
/
Makefile
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
prefix ?= usr/local
BINARY = $(prefix)/bin/ion
RELEASE = debug
TOOLCHAIN ?= 1.65.0
GIT_REVISION=git_revision.txt
SRC=Cargo.toml Cargo.lock $(shell find src members -type f -wholename '*src/*.rs')
VENDOR=.cargo/config vendor.tar.xz
DEBUG ?= 0
ifeq ($(DEBUG),0)
ARGS += --release
RELEASE = release
endif
VENDORED ?= 0
ifeq ($(VENDORED),1)
ARGSV += --frozen
endif
REDOX ?= 0
ifeq ($(REDOX),1)
undefine ARGSV
ARGS += --target x86_64-unknown-redox
TOOLCHAIN = nightly
endif
RUSTUP ?= 1
ifeq ($(RUSTUP),1)
TOOLCHAIN_ARG = +$(TOOLCHAIN)
endif
.PHONY: tests all clean distclean install uninstall manual
all: $(SRC) $(GIT_REVISION)
ifeq ($(REDOX),1)
mkdir -p .cargo
grep redox .cargo/config || cat redox_linker >> .cargo/config
endif
ifeq ($(VENDORED),1)
tar pxf vendor.tar.xz
endif
cargo $(TOOLCHAIN_ARG) build $(ARGS) $(ARGSV)
manual:
rm -rf manual/builtins
mkdir manual/builtins
cargo build --features man
echo -n "# Builtin commands" > manual/src/builtins.md
for man in manual/builtins/*; do \
echo "" >> manual/src/builtins.md; \
echo -n "## " >> manual/src/builtins.md; \
cat $$man >> manual/src/builtins.md; \
done
tests:
cargo $(TOOLCHAIN_ARG) test $(ARGSV)
TOOLCHAIN=$(TOOLCHAIN) bash tests/run_examples.sh
for crate in members/*; do \
cargo $(TOOLCHAIN_ARG) test $(ARGSV) --manifest-path $$crate/Cargo.toml || exit 1; \
done
test.%:
TOOLCHAIN=$(TOOLCHAIN) bash tests/run_examples.sh $@
vendor: $(VENDOR)
$(VENDOR):
rm -rf .cargo vendor vendor.tar.xz
mkdir -p .cargo
cargo vendor | head -n -1 > .cargo/config
echo 'directory = "vendor"' >> .cargo/config
tar pcfJ vendor.tar.xz vendor
rm -rf vendor
update-shells:
if ! grep ion /etc/shells >/dev/null; then \
echo $(BINARY) >> /etc/shells; \
else \
shell=$(shell grep ion /etc/shells); \
if [ $$shell != $(BINARY) ]; then \
sed -i -e "s#$$shell#$(BINARY)#g" /etc/shells; \
fi \
fi