-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
199 lines (160 loc) · 4.95 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# Copyright 2023 Robert Bosch GmbH
#
# SPDX-License-Identifier: Apache-2.0
###############
## DSE C Library
export DSE_CLIB_VERSION ?= 1.0.18
###############
## DSE Model C Library
export DSE_MODELC_VERSION ?= 2.1.1
###############
## Docker Images.
GCC_BUILDER_IMAGE ?= ghcr.io/boschglobal/dse-gcc-builder:main
TESTSCRIPT_IMAGE ?= ghcr.io/boschglobal/dse-testscript:latest
SIMER_IMAGE ?= ghcr.io/boschglobal/dse-simer:$(DSE_MODELC_VERSION)
###############
## Build parameters.
export NAMESPACE = dse
export MODULE = network
export EXTERNAL_BUILD_DIR ?= /tmp/$(NAMESPACE).$(MODULE)
export PACKAGE_ARCH ?= linux-amd64
export PACKAGE_ARCH_LIST ?= $(PACKAGE_ARCH)
export CMAKE_TOOLCHAIN_FILE ?= $(shell pwd -P)/extra/cmake/$(PACKAGE_ARCH).cmake
SUBDIRS = $(NAMESPACE)/$(MODULE)
export MODELC_SANDBOX_DIR ?= $(shell pwd -P)/$(NAMESPACE)/$(MODULE)/build/_deps/dse_modelc-src
###############
## Tools (Container Images).
TOOL_DIRS = network
###############
## Test Parameters.
export HOST_DOCKER_WORKSPACE ?= $(shell pwd -P)
export TESTSCRIPT_E2E_DIR ?= tests/testscript/e2e
TESTSCRIPT_E2E_FILES = $(wildcard $(TESTSCRIPT_E2E_DIR)/*.txtar)
NETWORK_IMAGE ?= $(NAMESPACE)-$(MODULE)
NETWORK_TAG ?= test
###############
## Package parameters.
export PACKAGE_VERSION ?= 0.0.2
DIST_DIR := $(shell pwd -P)/$(NAMESPACE)/$(MODULE)/build/_dist
OSS_DIR = $(NAMESPACE)/__oss__
PACKAGE_DOC_NAME = DSE Network Model
PACKAGE_NAME = Network
PACKAGE_NAME_LC = network
PACKAGE_PATH = $(NAMESPACE)/dist
ifneq ($(CI), true)
DOCKER_BUILDER_CMD := docker run -it --rm \
--env CMAKE_TOOLCHAIN_FILE=/tmp/repo/extra/cmake/$(PACKAGE_ARCH).cmake \
--env EXTERNAL_BUILD_DIR=$(EXTERNAL_BUILD_DIR) \
--env GDB_CMD="$(GDB_CMD)" \
--env PACKAGE_ARCH=$(PACKAGE_ARCH) \
--env PACKAGE_VERSION=$(PACKAGE_VERSION) \
--volume $$(pwd):/tmp/repo \
--volume $(EXTERNAL_BUILD_DIR):$(EXTERNAL_BUILD_DIR) \
--volume ~/.ccache:/root/.ccache \
--workdir /tmp/repo \
$(GCC_BUILDER_IMAGE)
endif
default: build
.PHONY: build
build:
@${DOCKER_BUILDER_CMD} $(MAKE) do-build
.PHONY: package
package:
@${DOCKER_BUILDER_CMD} $(MAKE) do-package
.PHONY: tools
tools:
for d in $(TOOL_DIRS) ;\
do \
mkdir -p extra/tools/$$d/build/stage ;\
cp -r licenses -t extra/tools/$$d/build/stage ;\
docker build -f extra/tools/$$d/build/package/Dockerfile \
--build-arg="CCACHE_SECONDARY_STORAGE=$(CCACHE_SECONDARY_STORAGE)" \
--tag $$d:test extra/tools/$$d ;\
done;
do-test_cmocka-build:
$(MAKE) -C tests/cmocka build
do-test_cmocka-run:
$(MAKE) -C tests/cmocka run
test_cmocka:
ifeq ($(PACKAGE_ARCH), linux-amd64)
@${DOCKER_BUILDER_CMD} $(MAKE) do-test_cmocka-build
@${DOCKER_BUILDER_CMD} $(MAKE) do-test_cmocka-run
endif
.PHONY: test_e2e
test_e2e: do-test_testscript-e2e
.PHONY: test
test: test_cmocka test_e2e
do-test_testscript-e2e:
# Test debug; add '-v' to Testscript command (e.g. $(TESTSCRIPT_IMAGE) -v \).
ifeq ($(PACKAGE_ARCH), linux-amd64)
@set -eu; for t in $(TESTSCRIPT_E2E_FILES) ;\
do \
echo "Running E2E Test: $$t" ;\
docker run -i --rm \
-e ENTRYDIR=$(HOST_DOCKER_WORKSPACE) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(HOST_DOCKER_WORKSPACE):/repo \
$(TESTSCRIPT_IMAGE) \
-e ENTRYDIR=$(HOST_DOCKER_WORKSPACE) \
-e NETWORK_IMAGE=$(NETWORK_IMAGE) \
-e NETWORK_TAG=$(NETWORK_TAG) \
-e SIMER=$(SIMER_IMAGE) \
$$t ;\
done;
endif
.PHONY: clean
clean:
@${DOCKER_BUILDER_CMD} $(MAKE) do-clean
for d in $(TOOL_DIRS) ;\
do \
rm -rf extra/tools/$$d/build/stage ;\
done;
docker images -qf dangling=true | xargs -r docker rmi
.PHONY: cleanall
cleanall:
@${DOCKER_BUILDER_CMD} $(MAKE) do-cleanall
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
docker images -qf dangling=true | xargs -r docker rmi
docker volume ls -qf dangling=true | xargs -r docker volume rm
.PHONY: oss
oss:
@${DOCKER_BUILDER_CMD} $(MAKE) do-oss
.PHONY: do-build
do-build:
@for d in $(SUBDIRS); do ($(MAKE) -C $$d build ); done
.PHONY: do-package
do-package:
@for d in $(SUBDIRS); do ($(MAKE) -C $$d package ); done
.PHONY: do-clean
do-clean:
@for d in $(SUBDIRS); do ($(MAKE) -C $$d clean ); done
$(MAKE) -C tests/cmocka clean
rm -rf $(OSS_DIR)
rm -rf doc_
rm -rvf *.zip
rm -rvf *.log
.PHONY: do-cleanall
do-cleanall: do-clean
@for d in $(SUBDIRS); do ($(MAKE) -C $$d cleanall ); done
$(MAKE) -C tests/cmocka cleanall
.PHONY: do-oss
do-oss:
$(MAKE) -C extra/external oss
.PHONY: generate
generate:
$(MAKE) -C doc generate
.PHONY: super-linter
super-linter:
docker run --rm --volume $$(pwd):/tmp/lint \
--env RUN_LOCAL=true \
--env DEFAULT_BRANCH=main \
--env IGNORE_GITIGNORED_FILES=true \
--env FILTER_REGEX_EXCLUDE="(doc/content/.*|dse/network/examples/stub/.*|extra/tools/network/vendor/.*)" \
--env VALIDATE_CPP=true \
--env VALIDATE_DOCKERFILE=true \
--env VALIDATE_MARKDOWN=true \
--env VALIDATE_PYTHON_PYLINT=true \
--env VALIDATE_PYTHON_FLAKE8=true \
--env VALIDATE_YAML=true \
ghcr.io/super-linter/super-linter:slim-v6
# --env VALIDATE_GO=true \