forked from ISDuBA/ISDuBA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
57 lines (45 loc) · 1.86 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
# This file is Free Software under the Apache-2.0 License
# without warranty, see README.md and LICENSES/Apache-2.0.txt for details.
#
# SPDX-License-Identifier: Apache-2.0
#
# SPDX-FileCopyrightText: 2024 German Federal Office for Information Security (BSI) <https://www.bsi.bund.de>
# Software-Engineering: 2024 Intevation GmbH <https://intevation.de>
.PHONY: all build_isdubad build_importer build_pkg test build_client
all: build_isdubad build_importer build_client test
# See comment here (2024-11-15)
# https://github.com/gocsaf/csaf/blob/3093f717817b9369d390e56d1012eaedcfa19e32/Makefile#L40-L49
GITDESC := $(shell git describe --tags --always)
GITDESCPATCH := $(shell echo '$(GITDESC)' | sed -E 's/v?[0-9]+\.[0-9]+\.([0-9]+)[-+]?.*/\1/')
SEMVERPATCH := $(shell echo $$(( $(GITDESCPATCH) + 1 )))
# Hint: The second regexp in the next line only matches
# if there is a hyphen (`-`) followed by a number,
# by which we assume that git describe has added a string after the tag
SEMVER := $(shell echo '$(GITDESC)' | sed -E -e 's/^v//' -e 's/([0-9]+\.[0-9]+\.)([0-9]+)(-[1-9].*)/\1$(SEMVERPATCH)\3/' )
testsemver:
@echo from \'$(GITDESC)\' transformed to \'$(SEMVER)\'
LDFLAGS=-ldflags "-X github.com/ISDuBA/ISDuBA/pkg/version.SemVersion=$(SEMVER)"
GO_FLAGS=$(LDFLAGS)
# Build for coverage profile generation
ifeq ($(BUILD_COVER), true)
GO_FLAGS += "-cover"
endif
build_importer: build_pkg
cd cmd/bulkimport && go build $(GO_FLAGS)
build_isdubad: build_pkg
cd cmd/isdubad && go build $(GO_FLAGS)
build_pkg:
cd pkg && go build $(GO_FLAGS) ./...
build_client:
cd client && npm install && npm run build
test:
go test ./...
DISTDIR := isduba-$(SEMVER)
dist: build_isdubad build_client
mkdir -p dist
cp cmd/isdubad/isdubad dist/
mkdir -p dist/web
cp -r web/* dist/web
mkdir -p dist/docs
cp -r docs/*.md dist/docs
cd dist/ ; tar -cvmlzf $(DISTDIR)-gnulinux-amd64.tar.gz *