From 97ca513f9b512ff5204709fe7d6376ea94dae3f1 Mon Sep 17 00:00:00 2001 From: Fadi Abbud Date: Mon, 17 Jan 2022 17:11:15 +0100 Subject: [PATCH 1/5] Add Makefile for building go components * Makefile with the following targets ** build for (linux system) ** build_win (windows system) ** build_tag (build from the last tag) ** clean for (removing the binaries) * Adjust README file --- Makefile | 39 +++++++++++++++++++++++++++++++++++++++ README.md | 10 ++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..914fc65 --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +# Simple Make file to build csaf_distribution components + +SHELL=/bin/bash +BUILD = go build +buildMsg = "Building binaries..." + +.PHONY: build build_win build_tag clean + +all: + @echo choose a target from: build build_win build_tag clean + +# Build all the binaries and place them in the current directory level. +build: + @echo $(buildMsg) + @$(BUILD) -o ./ -v ./cmd/... + +# Build the binaries for windows and place them in the current directory level. +build_win: + @echo $(buildMsg) + @env GOOS=windows $(BUILD) -o ./ -v ./cmd/... + +# Build the binaries from the latest github tag. +TAG = $(shell git tag --sort=-version:refname | head -n 1) +build_tag: +ifeq ($(TAG),) + @echo "No Tag found" +else + @git checkout -q tags/${TAG}; + @echo $(buildMsg) + @$(BUILD) -o ./ -v ./cmd/...; + @env GOOS=windows $(BUILD) -o ./ -v ./cmd/... + @git checkout -q main +endif + +# Remove binary files +clean: + @rm -f csaf_checker csaf_provider csaf_uploader csaf_checker.exe csaf_provider.exe csaf_uploader.exe + + diff --git a/README.md b/README.md index f058e58..e1815ec 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,12 @@ - Clone the repository `git clone https://github.com/csaf-poc/csaf_distribution.git ` - Build Go components - ``` bash - cd csaf_distribution - go build -v ./cmd/... -``` + Makefile supplies the following builds: + - For Linux Systems :`make build` + - For Windows platform: `make build_win` + - Build from the last tag: `make build_tag` + +These places the binares in the current directory. - [Install](http://nginx.org/en/docs/install.html) **nginx** - To configure nginx see [docs/provider-setup.md](docs/provider-setup.md) From d37706e1e2262f7847318877cb229172935da4fd Mon Sep 17 00:00:00 2001 From: Fadi Abbud Date: Tue, 18 Jan 2022 09:48:06 +0100 Subject: [PATCH 2/5] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1815ec..24e730c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ - For Windows platform: `make build_win` - Build from the last tag: `make build_tag` -These places the binares in the current directory. +These places the binaries in the current directory. - [Install](http://nginx.org/en/docs/install.html) **nginx** - To configure nginx see [docs/provider-setup.md](docs/provider-setup.md) From 84c3a108d068a8823d1526698e023dbcac596c1b Mon Sep 17 00:00:00 2001 From: Fadi Abbud Date: Tue, 18 Jan 2022 16:16:33 +0100 Subject: [PATCH 3/5] Add some detail --- Makefile | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 914fc65..867d0a5 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ build: @echo $(buildMsg) @$(BUILD) -o ./ -v ./cmd/... -# Build the binaries for windows and place them in the current directory level. +# Build the binaries for windows (cross build) and place them in the current directory level. build_win: @echo $(buildMsg) @env GOOS=windows $(BUILD) -o ./ -v ./cmd/... diff --git a/README.md b/README.md index 24e730c..6928a5a 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ - Build Go components Makefile supplies the following builds: - - For Linux Systems :`make build` - - For Windows platform: `make build_win` + - For Linux System (default build):`make build` + - For Windows System (cross build): `make build_win` - Build from the last tag: `make build_tag` These places the binaries in the current directory. From ec6cabb9ac70bf5d5891a66138bff30dd83c9f99 Mon Sep 17 00:00:00 2001 From: Fadi Abbud Date: Mon, 31 Jan 2022 13:09:47 +0100 Subject: [PATCH 4/5] Add one target to Makefile * "build_linux": building for GNU/linux * "build": Building for both linux and windows (cross build) * Place the generate binaries under "binaries/" directory * Improve echo messages --- Makefile | 29 +++++++++++++++++------------ README.md | 9 +++++---- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 867d0a5..02e3b20 100644 --- a/Makefile +++ b/Makefile @@ -2,22 +2,27 @@ SHELL=/bin/bash BUILD = go build -buildMsg = "Building binaries..." +MAKDIR = mkdir -p binaries .PHONY: build build_win build_tag clean all: - @echo choose a target from: build build_win build_tag clean + @echo choose a target from: build build_linux build_win build_tag clean -# Build all the binaries and place them in the current directory level. -build: - @echo $(buildMsg) - @$(BUILD) -o ./ -v ./cmd/... +# Build the binaries for GNU/linux and place them under binaries/ directory. +build_linux: + @$(MKDIR) + @echo "Bulding binaries for GNU/Linux ..." + @$(BUILD) -o ./binaries/ -v ./cmd/... -# Build the binaries for windows (cross build) and place them in the current directory level. +# Build the binaries for windows (cross build) and place them under binaries/ directory. build_win: - @echo $(buildMsg) - @env GOOS=windows $(BUILD) -o ./ -v ./cmd/... + @$(MKDIR) + @echo "Bulding binaries for windows (cross build) ..." + @env GOOS=windows $(BUILD) -o ./binaries/ -v ./cmd/... + +# Build the binaries for both GNU/linux and Windows and place them under binaries/ directory. +build: build_linux build_win # Build the binaries from the latest github tag. TAG = $(shell git tag --sort=-version:refname | head -n 1) @@ -27,13 +32,13 @@ ifeq ($(TAG),) else @git checkout -q tags/${TAG}; @echo $(buildMsg) - @$(BUILD) -o ./ -v ./cmd/...; + @$(BUILD) -o ./binaries/ -v ./cmd/...; @env GOOS=windows $(BUILD) -o ./ -v ./cmd/... @git checkout -q main endif -# Remove binary files +# Remove binaries directory clean: - @rm -f csaf_checker csaf_provider csaf_uploader csaf_checker.exe csaf_provider.exe csaf_uploader.exe + @rm -rf binaries/ diff --git a/README.md b/README.md index 6928a5a..ec23906 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,12 @@ - Build Go components Makefile supplies the following builds: - - For Linux System (default build):`make build` - - For Windows System (cross build): `make build_win` - - Build from the last tag: `make build_tag` + - Build For Linux System:`make build_linux` + - Build For Windows System (cross build): `make build_win` + - Build For both linux and windows: `make build` + - Build from the last github-tag: `make build_tag` -These places the binaries in the current directory. +These places the binaries under `binaries/` directory. - [Install](http://nginx.org/en/docs/install.html) **nginx** - To configure nginx see [docs/provider-setup.md](docs/provider-setup.md) From 9680a220be29565572ff79c3e9d05f46392c8b25 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Wed, 2 Feb 2022 11:20:51 +0100 Subject: [PATCH 5/5] Rename binaries folder to bin. --- Makefile | 8 ++++---- README.md | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 02e3b20..9669417 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SHELL=/bin/bash BUILD = go build -MAKDIR = mkdir -p binaries +MKDIR = mkdir -p bin .PHONY: build build_win build_tag clean @@ -13,13 +13,13 @@ all: build_linux: @$(MKDIR) @echo "Bulding binaries for GNU/Linux ..." - @$(BUILD) -o ./binaries/ -v ./cmd/... + @$(BUILD) -o ./bin/ -v ./cmd/... # Build the binaries for windows (cross build) and place them under binaries/ directory. build_win: @$(MKDIR) @echo "Bulding binaries for windows (cross build) ..." - @env GOOS=windows $(BUILD) -o ./binaries/ -v ./cmd/... + @env GOARCH=amd64 GOOS=windows $(BUILD) -o ./bin/ -v ./cmd/... # Build the binaries for both GNU/linux and Windows and place them under binaries/ directory. build: build_linux build_win @@ -39,6 +39,6 @@ endif # Remove binaries directory clean: - @rm -rf binaries/ + @rm -rf bin/ diff --git a/README.md b/README.md index ec23906..1497e5f 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,13 @@ - Clone the repository `git clone https://github.com/csaf-poc/csaf_distribution.git ` - Build Go components - Makefile supplies the following builds: - - Build For Linux System:`make build_linux` + Makefile supplies the following targets: + - Build For GNU/Linux System: `make build_linux` - Build For Windows System (cross build): `make build_win` - Build For both linux and windows: `make build` - Build from the last github-tag: `make build_tag` -These places the binaries under `binaries/` directory. +These places the binaries under `bin/` directory. - [Install](http://nginx.org/en/docs/install.html) **nginx** - To configure nginx see [docs/provider-setup.md](docs/provider-setup.md)