Skip to content

Commit 4fd3636

Browse files
committed
build: add builds for windows, linux & darwin
- add bare and full featured builds for: - darwin/amd64 - darwin/arm64 - linux/i386 - linux/amd64 - linux/arm - linux/arm64 - windows/i386 - windows/amd64 - windows/arm - windows/arm64 - update build steps to remove out dir before rebuild - omit symbol table and debug information in final build - omit DWARF symbol table - replace the following variables in the source files with values: - VERSION: is replaced with the current version defined in the makefile, e.g.: 0.0.0-pre+1 - BUILD_AT: is replaced with the date the build occured - BUILD_BY: is replaced with the 'user.name' and the 'user.email', both values are aquired using the 'git config --global' command and therefore depend on the currently building machine and its git user. - the bare build now prints the above variables on start - the full featured build prints these if invoked with '--version'
1 parent 67a76e3 commit 4fd3636

File tree

3 files changed

+91
-11
lines changed

3 files changed

+91
-11
lines changed

Makefile

+75-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,79 @@
1-
ver := "0.1.0"
2-
opt := ""
1+
ver := 0.0.0-pre
2+
build_at := $(shell date +"%Y-%m-%dT%H:%M:%S%z")
3+
build_by := $(shell git config --global user.name)-$(shell git config --global user.email)
4+
feat := 1
5+
opt := -ldflags="-w -s -X main.VERSION=$(ver)+$(feat) -X main.BUILD_AT=$(build_at) -X main.BUILD_BY=$(build_by)"
36

4-
dev: pre
5-
mkdir -p ./out/dev
6-
go build -o ./out/dev/
7+
release: build_linux build_darwin build_windows
78

8-
release: pre
9-
mkdir -p ./out/release
10-
go build -o ./out/release/
9+
build_linux: pre
10+
env = CGO_ENABLED=0 GOOS=linux GOARCH=386
11+
$(env) go build -o ./out/linux/fleck_$(ver)+$(feat)_linux-i386 $(opt)
1112

12-
pre:
13+
env = CGO_ENABLED=0 GOOS=linux GOARCH=386
14+
$(env) go build -tags=bare -o ./out/linux/fleck-bare_$(ver)+$(feat)_linux-i386 $(opt)
15+
16+
env = CGO_ENABLED=0 GOOS=linux GOARCH=amd64
17+
$(env) go build -o ./out/linux/fleck_$(ver)+$(feat)_linux-x86_64 $(opt)
18+
19+
env = CGO_ENABLED=0 GOOS=linux GOARCH=amd64
20+
$(env) go build -tags=bare -o ./out/linux/fleck-bare_$(ver)+$(feat)_linux-x86_64 $(opt)
21+
22+
env = CGO_ENABLED=0 GOOS=linux GOARCH=arm
23+
$(env) go build -o ./out/linux/fleck_$(ver)+$(feat)_linux-arm $(opt)
24+
25+
env = CGO_ENABLED=0 GOOS=linux GOARCH=arm
26+
$(env) go build -tags=bare -o ./out/linux/fleck-bare_$(ver)+$(feat)_linux-arm $(opt)
27+
28+
env = CGO_ENABLED=0 GOOS=linux GOARCH=arm64
29+
$(env) go build -o ./out/linux/fleck_$(ver)+$(feat)_linux-arm64 $(opt)
30+
31+
env = CGO_ENABLED=0 GOOS=linux GOARCH=arm64
32+
$(env) go build -tags=bare -o ./out/linux/fleck-bare_$(ver)+$(feat)_linux-arm64 $(opt)
33+
34+
build_windows: pre
35+
env = CGO_ENABLED=0 GOOS=windows GOARCH=386
36+
$(env) go build -o ./out/windows/fleck_$(ver)+$(feat)_windows-i386.exe $(opt)
37+
38+
env = CGO_ENABLED=0 GOOS=windows GOARCH=386
39+
$(env) go build -tags=bare -o ./out/windows/fleck-bare_$(ver)+$(feat)_windows-i386.exe $(opt)
40+
41+
env = CGO_ENABLED=0 GOOS=windows GOARCH=amd64
42+
$(env) go build -o ./out/windows/fleck_$(ver)+$(feat)_windows-amd64.exe $(opt)
43+
44+
env = CGO_ENABLED=0 GOOS=windows GOARCH=amd64
45+
$(env) go build -tags=bare -o ./out/windows/fleck-bare_$(ver)+$(feat)_windows-amd64.exe $(opt)
46+
47+
env = CGO_ENABLED=0 GOOS=windows GOARCH=arm
48+
$(env) go build -o ./out/windows/fleck_$(ver)+$(feat)_windows-arm.exe $(opt)
49+
50+
env = CGO_ENABLED=0 GOOS=windows GOARCH=arm
51+
$(env) go build -tags=bare -o ./out/windows/fleck-bare_$(ver)+$(feat)_windows-arm.exe $(opt)
52+
53+
env = CGO_ENABLED=0 GOOS=windows GOARCH=arm64
54+
$(env) go build -o ./out/windows/fleck_$(ver)+$(feat)_windows-arm64.exe $(opt)
55+
56+
env = CGO_ENABLED=0 GOOS=windows GOARCH=arm64
57+
$(env) go build -tags=bare -o ./out/windows/fleck-bare_$(ver)+$(feat)_windows-arm64.exe $(opt)
58+
59+
build_darwin: pre
60+
env = CGO_ENABLED=0 GOOS=darwin GOARCH=amd64
61+
$(env) go build -o ./out/darwin/fleck_$(ver)+$(feat)_darwin-amd64 $(opt)
62+
63+
env = CGO_ENABLED=0 GOOS=darwin GOARCH=amd64
64+
$(env) go build -tags=bare -o ./out/darwin/fleck-bare_$(ver)+$(feat)_darwin-amd64 $(opt)
65+
66+
env = CGO_ENABLED=0 GOOS=darwin GOARCH=arm64
67+
$(env) go build -o ./out/darwin/fleck_$(ver)+$(feat)_darwin-arm64 $(opt)
68+
69+
env = CGO_ENABLED=0 GOOS=darwin GOARCH=arm64
70+
$(env) go build -tags=bare -o ./out/darwin/fleck-bare_$(ver)+$(feat)_darwin-arm64 $(opt)
71+
72+
pre: clean
1373
mkdir -p ./out
74+
mkdir -p ./out/darwin
75+
mkdir -p ./out/linux
76+
mkdir -p ./out/windows
77+
78+
clean:
79+
rm -fr ./out

fleck.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !bare
2+
13
package main
24

35
import (
@@ -13,6 +15,11 @@ import (
1315
"github.com/xnacly/fleck/scanner"
1416
)
1517

18+
// supplied by the build process
19+
var VERSION = ""
20+
var BUILD_AT = ""
21+
var BUILD_BY = ""
22+
1623
// alerts the user if a flag depends on a different flag to have an effect
1724
func flagCombinationSensible() {
1825
for _, f := range cli.OPTIONS {
@@ -31,6 +38,9 @@ func main() {
3138
start := time.Now()
3239

3340
cli.ARGUMENTS = cli.ParseCli()
41+
if cli.GetFlag(cli.ARGUMENTS, "version") {
42+
cli.PrintVersion(VERSION, BUILD_AT, BUILD_BY)
43+
}
3444
if len(cli.ARGUMENTS.InputFile) == 0 {
3545
cli.PrintShortHelp()
3646
logger.LError("not enough arguments, specify an input file")
@@ -83,7 +93,7 @@ func main() {
8393
generator.WriteTemplate(fileName, result, toc)
8494
}
8595

86-
logger.LDebug("did everything, took: " + time.Since(start).String())
96+
logger.LInfo("did everything, took: " + time.Since(start).String())
8797

8898
defer func() {
8999
if cli.GetFlag(cli.ARGUMENTS, "preprocessor-enabled") {

fleck_bare.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ import (
1313
"github.com/xnacly/fleck/scanner"
1414
)
1515

16+
var VERSION = ""
17+
var BUILD_AT = ""
18+
var BUILD_BY = ""
19+
1620
func main() {
1721
start := time.Now()
18-
log.Println("fleck - barebones")
22+
log.Printf("fleck - bare (as in naked) bones\n[version=%s][buildAt=%s][buildBy=%s]\n\n", VERSION, BUILD_AT, BUILD_BY)
1923
args := os.Args
2024

2125
if len(args) < 2 {

0 commit comments

Comments
 (0)