gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

build.sh (1370B)


      1 #!/bin/sh
      2 
      3 set -e
      4 
      5 # Log and execute provided args.
      6 log_exec() { echo "$ ${*}"; "$@"; }
      7 
      8 # Grab environment variables and set defaults + requirements.
      9 GO_BUILDTAGS="${GO_BUILDTAGS-} netgo osusergo static_build kvformat"
     10 GO_LDFLAGS="${GO_LDFLAGS-} -s -w -extldflags '-static' -X 'main.Version=${VERSION:-$(git describe --tags --abbrev=0)}'"
     11 GO_GCFLAGS=${GO_GCFLAGS-}
     12 
     13 # Maintain old $DEBUG compat.
     14 [ ! -z "$DEBUG" ] && \
     15     GO_BUILDTAGS="${GO_BUILDTAGS} debugenv"
     16 
     17 # Available Go build tags, with explanation, followed by benefits of enabling it:
     18 # - kvformat:    enables prettier output of log fields                       (slightly better performance)
     19 # - notracing:   disables compiling-in otel tracing support                  (reduced binary size, better performance)
     20 # - noerrcaller: disables caller function prefix in errors                   (slightly better performance, at cost of err readability)
     21 # - debug:       enables /debug/pprof endpoint                               (adds debug, at performance cost)
     22 # - debugenv:    enables /debug/pprof endpoint if DEBUG=1 env during runtime (adds debug, at performance cost)
     23 log_exec env CGO_ENABLED=0 go build -trimpath -v \
     24                        -tags "${GO_BUILDTAGS}" \
     25                        -ldflags="${GO_LDFLAGS}" \
     26                        -gcflags="${GO_GCFLAGS}" \
     27                        ./cmd/gotosocial