-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (52 loc) · 2.08 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
# Copyright 2019 Google LLC
#
# Modifications copyright (C) 2019 by Nam Vu
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SHELL := /bin/bash
MAKEFILE_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
SRC_DIR := $(MAKEFILE_DIR)/src
BAZEL := $(MAKEFILE_DIR)/thirdparty/install/bazel/bazel
SRCS := $(shell find $(SRC_DIR) -name *.cc -or -name *.h)
$(info Formatting [${SRCS}])
$(shell thirdparty/install/clang/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-format -i $(SRCS))
# Allowed CPU values: k8, armv7a, aarch64
CPU ?= k8
# Allowed COMPILATION_MODE values: opt, dbg
COMPILATION_MODE ?= opt
BAZEL_OUT_DIR := $(MAKEFILE_DIR)/bazel-out/$(CPU)-$(COMPILATION_MODE)/bin
BAZEL_BUILD_FLAGS := --crosstool_top=@crosstool//:toolchains \
--compilation_mode=$(COMPILATION_MODE) \
--verbose_failures \
--compiler=gcc \
--cpu=$(CPU) \
--sandbox_debug \
--linkopt=-L$(MAKEFILE_DIR)/thirdparty/libedgetpu/direct/$(CPU) \
--linkopt=-l:libedgetpu.so.1 \
--copt=-std=c++17
OUT_DIR := $(MAKEFILE_DIR)/out/$(CPU)
.PHONY: all \
main \
tests
all: tests main
main:
$(BAZEL) build $(BAZEL_BUILD_FLAGS) //src:restor
mkdir -p $(OUT_DIR)
cp -f $(MAKEFILE_DIR)/bazel-bin/src/restor $(OUT_DIR)
tests:
$(BAZEL) build $(BAZEL_BUILD_FLAGS) $(shell bazel query 'kind(cc_.*test, //src/...)')
mkdir -p $(OUT_DIR)/tests
rsync -am --include='*test' --include='*/' --exclude='*' $(MAKEFILE_DIR)/bazel-bin/src $(OUT_DIR)/tests
clean:
$(BAZEL) clean
rm -rf ./out