Skip to content

Commit 5d13178

Browse files
committed
Migrate build_linux.sh to Make
1 parent 17c47b1 commit 5d13178

File tree

2 files changed

+43
-18
lines changed

2 files changed

+43
-18
lines changed

Cli/Makefile

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.DEFAULT_GOAL := debug
2+
3+
DOTNET = dotnet
4+
RUNTIME = linux-x64
5+
TARGET = netcoreapp2.2
6+
PACKER = ../Tools/linux-x64.warp-packer
7+
EXEC_NAME = AttackSurfaceAnalyzerCli
8+
PUBLISH_DIR = bin/Release/$(TARGET)/$(RUNTIME)/publish/
9+
NBGV_DIR = ../Tools
10+
VERSION := $(shell $(NBGV_DIR)/nbgv get-version -v AssemblyInformationalVersion)
11+
FULL_EXEC_PATH = bin/$(EXEC_NAME)-linux-$(VERSION)
12+
13+
prerequisites:
14+
$(info Checking for nbgv, installing if required.)
15+
@which $(NBGV_DIR)/nbgv || dotnet tool install --tool-path $(NBGV_DIR)/ nbgv
16+
17+
all: prerequisites debug
18+
debug: prerequisites clean restore build_debug
19+
release: prerequisites clean restore build_release
20+
21+
clean:
22+
$(info Cleaning...)
23+
dotnet clean
24+
25+
restore:
26+
$(info Restoring...)
27+
dotnet restore
28+
29+
build_debug:
30+
$(info Building debug...)
31+
dotnet build
32+
$(info Debug build completed.)
33+
34+
build_release:
35+
$(info Building release...)
36+
dotnet build
37+
$(info Detected version as $(VERSION))
38+
39+
$(DOTNET) publish -c Release -r $(RUNTIME) --self-contained true
40+
$(PACKER) --arch $(RUNTIME) --input_dir $(PUBLISH_DIR) --exec $(EXEC_NAME) --output $(FULL_EXEC_PATH)
41+
chmod +x $(FULL_EXEC_PATH)
42+
$(info Release build completed, result is located at $(FULL_EXEC_PATH))

Cli/build_linux.sh

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
11
#!/bin/bash
22

3-
RELEASE="Debug"
4-
while [ "$1" != "" ]; do
5-
case "$1" in
6-
-r | --release )
7-
shift
8-
RELEASE="$1"
9-
esac
10-
shift
11-
done
12-
13-
if [ "$RELEASE" == "Debug" ]; then
14-
dotnet build
15-
elif [ "$RELEASE" == "Release" ]; then
16-
VERSION=$(nbgv get-version -v AssemblyInformationalVersion)
17-
dotnet publish -c "$RELEASE" -r linux-x64 --self-contained true && ../Tools/linux-x64.warp-packer --arch linux-x64 --input_dir bin/Release/netcoreapp2.1/linux-x64/publish/ --exec AttackSurfaceAnalyzerCli --output bin/AttackSurfaceAnalyzerCli-linux-$VERSION.bin
18-
chmod +x AttackSurfaceAnalyzerCli
19-
echo "Build completed, result is located at bin/AttackSurfaceAnalyzerCli-linux-$VERSION.bin"
20-
fi
3+
make

0 commit comments

Comments
 (0)