1
1
2
- .PHONY : all bazel build clean realclean package package_deb package_rpm
3
-
4
- build : bazel
5
- # go build -ldflags "-X github.com/netsec-ethz/bootstrapper/config.versionString="$(./.bazel-build-env | awk '{print $2}')
2
+ .PHONY : all bazel bootstrappper build go_build install_deps clean realclean package package_deb package_rpm
3
+
4
+ build : install_deps bazel
5
+
6
+ go_build :
7
+ @go build -o scion-bootstrapper -ldflags " -X github.com/netsec-ethz/bootstrapper/config.versionString=" $$(git describe --tags --dirty --always )
8
+
9
+ bootstrapper :
10
+ @if [ -n " $$ {OS}" ] ; then \
11
+ UNAME_OS=" $$ {OS}" ; \
12
+ else \
13
+ UNAME_OS=$$(uname --kernel-name ) ; \
14
+ fi ; \
15
+ if [ " $$ {UNAME_OS}" = " Linux" ] ; then \
16
+ make -s build; \
17
+ elif [ " $$ {UNAME_OS}" = " Windows_NT" ] ; then \
18
+ make.exe -s go_build; \
19
+ cp scion-bootstrapper scion-bootstrapper.exe; \
20
+ else \
21
+ make -s go_build; \
22
+ fi ;
23
+
24
+ install_deps :
25
+ @if [ -z " $$ {CC}" ] ; then \
26
+ if [ ! -x " $$ (command -v gcc)" ]; then \
27
+ echo " Cannot find gcc or CC; set the CC environment variable or make sure gcc is on your PATH." ; \
28
+ else \
29
+ exit 0; \
30
+ fi ; \
31
+ else \
32
+ exit 0; \
33
+ fi ; \
34
+ apt-get install build-essential 2> /dev/null; \
35
+ test $$? -eq 0 || echo " Install build tools?\nsudo apt-get install build-essential" && sudo apt-get install build-essential
6
36
7
37
bazel : go_deps.bzl
8
38
rm -f bin/*
39
+ @if [ -z " $$ {CC}" ] ; then \
40
+ if [ ! -x " $$ (command -v gcc)" ]; then \
41
+ echo " Cannot find gcc or CC; set the CC environment variable or make sure gcc is on your PATH." && exit 1; \
42
+ fi ; \
43
+ fi ;
9
44
./.bazel-build-env
10
45
bazel build //:bootstrapper
11
- cp ` bazel aquery ' outputs(".*bin/bootstrapper", //:bootstrapper)' --output=text 2> /dev/null | grep " Outputs" | sed -r ' s/\s*Outputs: \[(.*)\]/\1/' ` bin/
46
+ @cp ` bazel aquery ' outputs(".*bin/bootstrapper", //:bootstrapper)' --output=text 2> /dev/null | grep " Outputs" | sed -r ' s/\s*Outputs: \[(.*)\]/\1/' ` bin/
47
+ @ln -sf ./bin/bootstrapper ./scion-bootstrapper
12
48
13
- all : build test package
49
+ all : bootstrapper test package
14
50
15
51
clean :
16
52
bazel clean
17
- rm -f bin/*
53
+ rm -f ./ bin/*
18
54
19
55
realclean : clean
20
56
bazel clean --expunge
21
- rm ~ /.cache/ bazel
22
- rm -f go_deps.bzl
57
+ rm -f ./MODULE. bazel*
58
+ rm -f ./ go_deps.bzl
23
59
24
60
package : package_deb
25
61
26
62
package_deb : build
63
+ @if [ ! -x " $$ (command -v python3)" ]; then \
64
+ echo " Cannot find python3 on your PATH." ; \
65
+ apt-get install python3 & > /dev/null; \
66
+ test $$? -eq 0 || echo " Install python3?\nsudo apt-get install python3" && sudo apt-get install python3; \
67
+ fi ;
27
68
bazel build //:scion-bootstrapper-deb
28
69
cp bazel-bin/scion-bootstrapper_* _* .deb bin/
29
70
30
71
package_rpm : build
72
+ @if [ ! -x " $$ (command -v rpmbuild)" ]; then \
73
+ echo " Cannot find rpmbuild on your PATH." ; \
74
+ apt-get install rpm & > /dev/null; \
75
+ test $$? -eq 0 || echo " Install rpm toolchain?\nsudo apt-get install rpm" && sudo apt-get install rpm; \
76
+ fi ;
31
77
bazel build //:scion-bootstrapper-rpm
32
78
cp bazel-bin/scion-bootstrapper-* .* .rpm bin/
33
79
@@ -52,7 +98,16 @@ ifeq (,$(wildcard go_deps.bzl))
52
98
$(file > ./go_deps.bzl,$(go_deps_boilerplate))
53
99
endif
54
100
bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=go_deps.bzl%go_deps -prune
101
+ bazel clean --expunge
55
102
56
103
test : build
57
- bazel test --config=unit --test_output=errors ...
104
+ @if [ ! -x " $$ (command -v " scion-pki" )" ]; then \
105
+ echo " Cannot find scion-pki; make sure scion-pki is on your PATH otherwise the tests relying on it will fail." ; \
106
+ fi ;
107
+ bazel test --test_output=errors //hinting:go_default_test //fetcher:go_default_test //config:go_default_test
108
+ # Do not filter on unit tag for now, as doing so forces all loaded packages
109
+ # to satisfy their dependencies, which is not desirable for pkg_rpm
110
+ # which forces to have a full rpm toolchain loaded, even when the target
111
+ # is not executed. Explicitly list all test targets.
112
+ # bazel test --config=unit --test_output=errors ...
58
113
0 commit comments