Skip to content

Commit

Permalink
chore: Add '-trimpath' build option and refactor Makefile.inc
Browse files Browse the repository at this point in the history
- Add '-trimpath' option to build, so that the absolute full source
  paths are not included in the binary, which makes it more
  reproducible.  In addition, we can later make the log messages print
  the full file paths instead of the final file names.

- Refactor the Makefile.inc to clean up a bit.

- Update the .gitignore accordingly.
  • Loading branch information
liweitianux committed Aug 1, 2024
1 parent d92094f commit 3acfa9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.log
*.mmdb
/main
/mirrorselect
/mirrorselect-*-*
18 changes: 11 additions & 7 deletions Makefile.inc
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
MODULE= github.com/DragonFlyBSD/mirrorselect
PROG= mirrorselect
MODULE= github.com/DragonFlyBSD/$(PROG)

BUILD_ARGS+= -trimpath -ldflags "$(LDFLAGS)"

all:
CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o mirrorselect main.go
env CGO_ENABLED=0 \
go build $(BUILD_ARGS) -o $(PROG)

ci: all
CGO_ENABLED=0 GOOS=dragonfly GOARCH=amd64 \
go build -ldflags="$(LDFLAGS)" -o mirrorselect main.go
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 \
go build -ldflags="$(LDFLAGS)" -o mirrorselect main.go
env CGO_ENABLED=0 GOOS=dragonfly GOARCH=amd64 \
go build $(BUILD_ARGS) -o $(PROG)-dragonfly-amd64
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 \
go build $(BUILD_ARGS) -o $(PROG)-freebsd-amd64

clean:
rm -f mirrorselect
rm -f $(PROG) $(PROG)-*-*

test: dbip
go test -v ./common ./geoip ./monitor ./workerpool
Expand Down

0 comments on commit 3acfa9c

Please sign in to comment.