Skip to content

Commit

Permalink
build: add builds for windows, linux & darwin
Browse files Browse the repository at this point in the history
- 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'
  • Loading branch information
xNaCly committed Apr 17, 2023
1 parent 67a76e3 commit 4fd3636
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 11 deletions.
84 changes: 75 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,79 @@
ver := "0.1.0"
opt := ""
ver := 0.0.0-pre
build_at := $(shell date +"%Y-%m-%dT%H:%M:%S%z")
build_by := $(shell git config --global user.name)-$(shell git config --global user.email)
feat := 1
opt := -ldflags="-w -s -X main.VERSION=$(ver)+$(feat) -X main.BUILD_AT=$(build_at) -X main.BUILD_BY=$(build_by)"

dev: pre
mkdir -p ./out/dev
go build -o ./out/dev/
release: build_linux build_darwin build_windows

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

pre:
env = CGO_ENABLED=0 GOOS=linux GOARCH=386
$(env) go build -tags=bare -o ./out/linux/fleck-bare_$(ver)+$(feat)_linux-i386 $(opt)

env = CGO_ENABLED=0 GOOS=linux GOARCH=amd64
$(env) go build -o ./out/linux/fleck_$(ver)+$(feat)_linux-x86_64 $(opt)

env = CGO_ENABLED=0 GOOS=linux GOARCH=amd64
$(env) go build -tags=bare -o ./out/linux/fleck-bare_$(ver)+$(feat)_linux-x86_64 $(opt)

env = CGO_ENABLED=0 GOOS=linux GOARCH=arm
$(env) go build -o ./out/linux/fleck_$(ver)+$(feat)_linux-arm $(opt)

env = CGO_ENABLED=0 GOOS=linux GOARCH=arm
$(env) go build -tags=bare -o ./out/linux/fleck-bare_$(ver)+$(feat)_linux-arm $(opt)

env = CGO_ENABLED=0 GOOS=linux GOARCH=arm64
$(env) go build -o ./out/linux/fleck_$(ver)+$(feat)_linux-arm64 $(opt)

env = CGO_ENABLED=0 GOOS=linux GOARCH=arm64
$(env) go build -tags=bare -o ./out/linux/fleck-bare_$(ver)+$(feat)_linux-arm64 $(opt)

build_windows: pre
env = CGO_ENABLED=0 GOOS=windows GOARCH=386
$(env) go build -o ./out/windows/fleck_$(ver)+$(feat)_windows-i386.exe $(opt)

env = CGO_ENABLED=0 GOOS=windows GOARCH=386
$(env) go build -tags=bare -o ./out/windows/fleck-bare_$(ver)+$(feat)_windows-i386.exe $(opt)

env = CGO_ENABLED=0 GOOS=windows GOARCH=amd64
$(env) go build -o ./out/windows/fleck_$(ver)+$(feat)_windows-amd64.exe $(opt)

env = CGO_ENABLED=0 GOOS=windows GOARCH=amd64
$(env) go build -tags=bare -o ./out/windows/fleck-bare_$(ver)+$(feat)_windows-amd64.exe $(opt)

env = CGO_ENABLED=0 GOOS=windows GOARCH=arm
$(env) go build -o ./out/windows/fleck_$(ver)+$(feat)_windows-arm.exe $(opt)

env = CGO_ENABLED=0 GOOS=windows GOARCH=arm
$(env) go build -tags=bare -o ./out/windows/fleck-bare_$(ver)+$(feat)_windows-arm.exe $(opt)

env = CGO_ENABLED=0 GOOS=windows GOARCH=arm64
$(env) go build -o ./out/windows/fleck_$(ver)+$(feat)_windows-arm64.exe $(opt)

env = CGO_ENABLED=0 GOOS=windows GOARCH=arm64
$(env) go build -tags=bare -o ./out/windows/fleck-bare_$(ver)+$(feat)_windows-arm64.exe $(opt)

build_darwin: pre
env = CGO_ENABLED=0 GOOS=darwin GOARCH=amd64
$(env) go build -o ./out/darwin/fleck_$(ver)+$(feat)_darwin-amd64 $(opt)

env = CGO_ENABLED=0 GOOS=darwin GOARCH=amd64
$(env) go build -tags=bare -o ./out/darwin/fleck-bare_$(ver)+$(feat)_darwin-amd64 $(opt)

env = CGO_ENABLED=0 GOOS=darwin GOARCH=arm64
$(env) go build -o ./out/darwin/fleck_$(ver)+$(feat)_darwin-arm64 $(opt)

env = CGO_ENABLED=0 GOOS=darwin GOARCH=arm64
$(env) go build -tags=bare -o ./out/darwin/fleck-bare_$(ver)+$(feat)_darwin-arm64 $(opt)

pre: clean
mkdir -p ./out
mkdir -p ./out/darwin
mkdir -p ./out/linux
mkdir -p ./out/windows

clean:
rm -fr ./out
12 changes: 11 additions & 1 deletion fleck.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !bare

package main

import (
Expand All @@ -13,6 +15,11 @@ import (
"github.com/xnacly/fleck/scanner"
)

// supplied by the build process
var VERSION = ""
var BUILD_AT = ""
var BUILD_BY = ""

// alerts the user if a flag depends on a different flag to have an effect
func flagCombinationSensible() {
for _, f := range cli.OPTIONS {
Expand All @@ -31,6 +38,9 @@ func main() {
start := time.Now()

cli.ARGUMENTS = cli.ParseCli()
if cli.GetFlag(cli.ARGUMENTS, "version") {
cli.PrintVersion(VERSION, BUILD_AT, BUILD_BY)
}
if len(cli.ARGUMENTS.InputFile) == 0 {
cli.PrintShortHelp()
logger.LError("not enough arguments, specify an input file")
Expand Down Expand Up @@ -83,7 +93,7 @@ func main() {
generator.WriteTemplate(fileName, result, toc)
}

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

defer func() {
if cli.GetFlag(cli.ARGUMENTS, "preprocessor-enabled") {
Expand Down
6 changes: 5 additions & 1 deletion fleck_bare.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ import (
"github.com/xnacly/fleck/scanner"
)

var VERSION = ""
var BUILD_AT = ""
var BUILD_BY = ""

func main() {
start := time.Now()
log.Println("fleck - barebones")
log.Printf("fleck - bare (as in naked) bones\n[version=%s][buildAt=%s][buildBy=%s]\n\n", VERSION, BUILD_AT, BUILD_BY)
args := os.Args

if len(args) < 2 {
Expand Down

0 comments on commit 4fd3636

Please sign in to comment.