forked from viam-modules/viam-cartographer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (94 loc) · 4.13 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
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
BUILD_CHANNEL?=local
TOOL_BIN = bin/gotools/$(shell uname -s)-$(shell uname -m)
PATH_WITH_TOOLS="`pwd`/$(TOOL_BIN):${PATH}"
GIT_REVISION = $(shell git rev-parse HEAD | tr -d '\n')
TAG_VERSION?=$(shell git tag --points-at | sort -Vr | head -n1)
GO_BUILD_LDFLAGS = -ldflags "-X 'main.Version=${TAG_VERSION}' -X 'main.GitRevision=${GIT_REVISION}'"
set-pkg-config-openssl:
pkg-config openssl || export PKG_CONFIG_PATH=$$PKG_CONFIG_PATH:`find \`which brew > /dev/null && brew --prefix\` -name openssl.pc | head -n1 | xargs dirname`
bufinstall:
sudo apt-get install -y protobuf-compiler-grpc libgrpc-dev libgrpc++-dev || brew install grpc openssl --quiet
bufsetup: set-pkg-config-openssl
GOBIN=`pwd`/grpc/bin go install github.com/bufbuild/buf/cmd/[email protected]
ln -sf `which grpc_cpp_plugin` grpc/bin/protoc-gen-grpc-cpp
buf: bufsetup
PATH="${PATH}:`pwd`/grpc/bin" buf generate --template ./buf/buf.gen.yaml buf.build/viamrobotics/api
PATH="${PATH}:`pwd`/grpc/bin" buf generate --template ./buf/buf.grpc.gen.yaml buf.build/viamrobotics/api
PATH="${PATH}:`pwd`/grpc/bin" buf generate --template ./buf/buf.gen.yaml buf.build/googleapis/googleapis
clean:
rm -rf grpc
rm -rf bin
rm -rf viam-cartographer/build
rm -rf viam-cartographer/cartographer/build
clean-all:
git clean -fxd
ensure-submodule-initialized:
@if [ ! -d "viam-cartographer/cartographer/cartographer" ]; then \
echo "Submodule was not found. Initializing..."; \
git submodule update --init; \
else \
echo "Submodule found successfully"; \
fi
lint-setup-cpp:
ifeq ("Darwin", "$(shell uname -s)")
brew install clang-format
else
sudo apt-get install -y clang-format
endif
lint-setup-go:
GOBIN=`pwd`/$(TOOL_BIN) go install \
github.com/edaniels/golinters/cmd/combined \
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/rhysd/actionlint/cmd/actionlint
lint-setup: lint-setup-cpp lint-setup-go
lint-cpp:
find . -type f -not -path \
-and ! -path '*viam-cartographer/cartographer*' \
-and ! -path '*viam-cartographer/build*' \
-and ! -path '*api*' \
-and ! -path '*grpc*' \
-and \( -iname '*.h' -o -iname '*.cpp' -o -iname '*.cc' \) \
| xargs clang-format -i --style="{BasedOnStyle: Google, IndentWidth: 4}"
lint-go:
go vet -vettool=$(TOOL_BIN)/combined ./...
GOGC=50 $(TOOL_BIN)/golangci-lint run -v --fix --config=./etc/golangci.yaml
PATH=$(PATH_WITH_TOOLS) actionlint
lint: ensure-submodule-initialized lint-cpp lint-go
setup: ensure-submodule-initialized set-pkg-config-openssl
ifeq ("Darwin", "$(shell uname -s)")
cd viam-cartographer/scripts && ./setup_cartographer_macos.sh
else
cd viam-cartographer/scripts && ./setup_cartographer_linux.sh
endif
build: build-module
ifneq ($(wildcard viam-cartographer/cartographer/build/.),)
cd viam-cartographer && ./scripts/build_viam_cartographer.sh
else
cd viam-cartographer && ./scripts/build_cartographer.sh && ./scripts/build_viam_cartographer.sh
endif
build-module:
mkdir -p bin && go build $(GO_BUILD_LDFLAGS) -o bin/cartographer-module module/main.go
install-lua-files:
sudo mkdir -p /usr/local/share/cartographer/lua_files/
sudo cp viam-cartographer/lua_files/* /usr/local/share/cartographer/lua_files/
sudo cp viam-cartographer/cartographer/configuration_files/* /usr/local/share/cartographer/lua_files/
test-cpp:
cd viam-cartographer && ./scripts/test_cartographer.sh
test-go:
go test -race ./...
test: test-cpp test-go
install:
sudo rm -f /usr/local/bin/carto_grpc_server
sudo rm -f /usr/local/bin/cartographer-module
sudo cp viam-cartographer/build/carto_grpc_server /usr/local/bin/carto_grpc_server
sudo cp bin/cartographer-module /usr/local/bin/cartographer-module
appimage: build
cd etc/packaging/appimages && BUILD_CHANNEL=${BUILD_CHANNEL} appimage-builder --recipe cartographer-module-`uname -m`.yml
mkdir -p etc/packaging/appimages/deploy/
mv etc/packaging/appimages/*.AppImage* etc/packaging/appimages/deploy/
chmod 755 etc/packaging/appimages/deploy/*.AppImage
appimage-ci: build
cd etc/packaging/appimages && ./package_release_module.sh
mkdir -p etc/packaging/appimages/deploy/
mv etc/packaging/appimages/*.AppImage* etc/packaging/appimages/deploy/
chmod 755 etc/packaging/appimages/deploy/*.AppImage