-
Notifications
You must be signed in to change notification settings - Fork 208
/
Makefile
77 lines (68 loc) · 2.6 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
#
# Copyright (c) 2021 Intel Corporation
#
# 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
#
# http://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.
#
HEADER_FILE_PATH ?= ../custom_node_interface.h
OPENCV_BUILD_FLAGS ?= ../../third_party/opencv/opencv_cmake_flags.txt
OPENCV_INSTALL_SCRIPT ?= ../../third_party/opencv/install_opencv.sh
BASE_OS ?= ubuntu22
BASE_OS_TAG_UBUNTU ?= 22.04
BASE_OS_TAG_REDHAT ?= 8.10
NODES ?= add_one east_ocr face_blur horizontal_ocr image_transformation model_zoo_intel_object_detection
NODE_TYPE ?= cpp
ifeq ($(findstring ubuntu,$(BASE_OS)),ubuntu)
BASE_OS_TAG=$(BASE_OS_TAG_UBUNTU)
ifeq ($(BASE_OS),ubuntu22)
BASE_OS_TAG=22.04
endif
ifeq ($(BASE_OS),ubuntu20)
BASE_OS_TAG=20.04
endif
BASE_IMAGE ?= ubuntu:$(BASE_OS_TAG)
DIST_OS=ubuntu
endif
ifeq ($(BASE_OS),redhat)
BASE_OS_TAG=$(BASE_OS_TAG_REDHAT)
DIST_OS=redhat
endif
BASE_IMAGE=$(DIST_OS):$(BASE_OS_TAG)
.PHONY: all
default: all
all:
ifeq ($(NO_DOCKER_CACHE),true)
$(eval NO_CACHE_OPTION:=--no-cache)
@echo "Docker image will be rebuilt from scratch"
endif
@cp $(HEADER_FILE_PATH) .
@cp $(OPENCV_BUILD_FLAGS) .
@cp $(OPENCV_INSTALL_SCRIPT) .
@cp -r ../queue.hpp ./queue.hpp
# Pass down --no-cache option to docker build for the first node, but not for the rest, the rest will re-build last layer anyway
first_iteration=true ; for NODE_NAME in $(NODES); do \
if [ "$$first_iteration" = true ]; then \
first_iteration=false ; \
docker_cache_param=$(NO_CACHE_OPTION) ; \
else \
docker_cache_param= ; \
fi ; \
echo $$docker_cache_param ; \
docker build $$docker_cache_param -f Dockerfile.$(DIST_OS) -t custom_node_build_image:latest --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} --build-arg no_proxy=${no_proxy} --build-arg BASE_IMAGE=$(BASE_IMAGE) --build-arg NODE_NAME=$$NODE_NAME --build-arg NODE_TYPE=$(NODE_TYPE) . || exit 1 ; \
mkdir -p ./lib/$(BASE_OS) ; \
docker cp $$(docker create --rm custom_node_build_image:latest):/custom_nodes/lib/libcustom_node_$$NODE_NAME.so ./lib/$(BASE_OS)/ || exit 1 ; \
echo "Built $$NODE_NAME" ; \
done || exit 1
@rm ./queue.hpp
@rm install_opencv.sh
@rm opencv_cmake_flags.txt
@rm custom_node_interface.h