Skip to content

Commit

Permalink
Tweak Makefiles for consistency and new arm targets
Browse files Browse the repository at this point in the history
  • Loading branch information
rcowham committed Jun 10, 2024
1 parent e07f75f commit fdb2d9f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
9 changes: 7 additions & 2 deletions cmd/log2sql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/perforce/p4prometheus/version"
p4dlog "github.com/rcowham/go-libp4dlog"
"github.com/rcowham/go-libp4dlog/metrics"
metrics "github.com/rcowham/go-libp4dlog/metrics"
)

const statementsPerTransaction = 50 * 1000
Expand Down Expand Up @@ -610,7 +610,12 @@ func main() {
if writeMetrics {
wg.Add(1)
logger.Debugf("Main: creating metrics")
mp = metrics.NewP4DMetricsLogParser(mconfig, logger, true)
mver := &metrics.P4DMetricsVersion{
Revision: version.Revision,
GoVersion: version.GoVersion,
Version: version.Version,
}
mp = metrics.NewP4DMetricsLogParser(mconfig, mver, logger, true)
if *debug != 0 {
mp.SetDebugMode(*debug)
}
Expand Down
25 changes: 15 additions & 10 deletions cmd/p4dpending/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# Build file for p4dpending - useful debugging tool for the library

BINARY=p4dpending

Expand All @@ -19,15 +19,20 @@ LDFLAGS=-ldflags="-w -s -X ${MODULE}/version.Version=${VERSION} -X ${MODULE}/ver
build:
go build ${LOCAL_LDFLAGS}

# Builds distribution - uses xgo and the docker container for cross platform builds
# See: https://github.com/karalabe/xgo
# Note that this will download and build the latest version of package from github - it won't build the local go
# repo. So you need to have published everything (and ensure tags are as desired) before doing this.
test:
go test

# Builds distribution - for all supported platforms
dist:
~/go/bin/xgo --targets=linux/amd64,windows/amd64,darwin/amd64 ${LDFLAGS} github.com/rcowham/go-libp4dlog/cmd/p4dpending
rm -f p4dpending*amd64*.gz
-chmod +x p4dpending*amd64*
gzip p4dpending*amd64*
GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o bin/${BINARY}-darwin-amd64 main.go
GOOS=darwin GOARCH=arm64 go build ${LDFLAGS} -o bin/${BINARY}-darwin-arm64 main.go
GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o bin/${BINARY}-linux-amd64 main.go
GOOS=linux GOARCH=arm64 go build ${LDFLAGS} -o bin/${BINARY}-linux-arm64 main.go
GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o bin/${BINARY}-windows-amd64.exe main.go
GOOS=windows GOARCH=arm64 go build ${LDFLAGS} -o bin/${BINARY}-windows-arm64.exe main.go
rm -f bin/${BINARY}*-a*64*.gz
-chmod +x bin/${BINARY}*-a*64*
gzip bin/${BINARY}*a*64*

# Installs our project: copies binaries
install:
Expand All @@ -37,4 +42,4 @@ install:
clean:
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi

.PHONY: clean install
.PHONY: clean install test
13 changes: 9 additions & 4 deletions cmd/p4locks/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Makefile for p4locks - to show lock status in a log file.

BINARY=p4locks

# These are the values we want to pass for VERSION and BUILD
Expand All @@ -17,14 +19,17 @@ LDFLAGS=-ldflags="-w -s -X ${MODULE}/version.Version=${VERSION} -X ${MODULE}/ver
build:
go build ${LOCAL_LDFLAGS}

# Builds distributions
# Builds distribution for other platforms
dist:
GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o bin/${BINARY}-darwin-amd64 main.go
GOOS=darwin GOARCH=arm64 go build ${LDFLAGS} -o bin/${BINARY}-darwin-arm64 main.go
GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o bin/${BINARY}-linux-amd64 main.go
GOOS=linux GOARCH=arm64 go build ${LDFLAGS} -o bin/${BINARY}-linux-arm64 main.go
GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o bin/${BINARY}-windows-amd64.exe main.go
rm -f bin/${BINARY}*amd64*.gz
-chmod +x bin/${BINARY}*amd64*
gzip bin/${BINARY}*amd64*
GOOS=windows GOARCH=arm64 go build ${LDFLAGS} -o bin/${BINARY}-windows-arm64.exe main.go
rm -f bin/${BINARY}*-a*64*.gz
-chmod +x bin/${BINARY}*-a*64*
gzip bin/${BINARY}*a*64*

# Cleans our project: deletes binaries
clean:
Expand Down

0 comments on commit fdb2d9f

Please sign in to comment.