Skip to content

Commit

Permalink
chore: normalise Go binary builds (#3552)
Browse files Browse the repository at this point in the history
Previously there were N slightly different duplicates of the same
commands. This fixes that.
  • Loading branch information
alecthomas authored Nov 27, 2024
1 parent 94a2e75 commit 59f3dbc
Showing 1 changed file with 16 additions and 40 deletions.
56 changes: 16 additions & 40 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ build-without-frontend +tools: build-protos build-zips
for tool in $@; do
path="cmd/$tool"
test "$tool" = "ftl" && path="frontend/cli"
if [ "${FTL_DEBUG:-}" = "true" ]; then
go build -o "{{RELEASE}}/$tool" -tags release -gcflags=all="-N -l" -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./$path"
else
mk "{{RELEASE}}/$tool" : !(build|integration|infrastructure|node_modules|Procfile*|Dockerfile*) -- go build -o "{{RELEASE}}/$tool" -tags release -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./$path"
fi
just build-go-binary "./$path" "$tool"
done

# Build all backend binaries
Expand All @@ -102,47 +98,24 @@ build-jvm *args:
mvn -f jvm-runtime/ftl-runtime install {{args}}

# Builds all language plugins
build-language-plugins: build-go build-python build-java build-kotlin

# Build ftl-language-go
build-go: build-zips build-protos
#!/bin/bash
shopt -s extglob

if [ "${FTL_DEBUG:-}" = "true" ]; then
go build -o "{{RELEASE}}/ftl-language-go" -tags release -gcflags=all="-N -l" -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./go-runtime/cmd/ftl-language-go"
else
mk "{{RELEASE}}/ftl-language-go" : !(build|integration) -- go build -o "{{RELEASE}}/ftl-language-go" -tags release -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./go-runtime/cmd/ftl-language-go"
fi

# Build ftl-language-python
build-python: build-zips build-protos
#!/bin/bash
shopt -s extglob

if [ "${FTL_DEBUG:-}" = "true" ]; then
go build -o "{{RELEASE}}/ftl-language-python" -tags release -gcflags=all="-N -l" -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./python-runtime/cmd/ftl-language-python"
else
mk "{{RELEASE}}/ftl-language-python" : !(build|integration) -- go build -o "{{RELEASE}}/ftl-language-python" -tags release -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./python-runtime/cmd/ftl-language-python"
fi

build-kotlin *args: build-zips build-protos
build-language-plugins:
@just build-go-binary ./go-runtime/cmd/ftl-language-go
@just build-go-binary ./python-runtime/cmd/ftl-language-python
@just build-go-binary ./jvm-runtime/cmd/ftl-language-java
@just build-go-binary ./jvm-runtime/cmd/ftl-language-kotlin

# Build a Go binary with the correct flags and place it in the release dir
build-go-binary dir binary="": build-zips build-protos build-frontend
#!/bin/bash
set -euo pipefail
shopt -s extglob
if [ "${FTL_DEBUG:-}" = "true" ]; then
go build -o "{{RELEASE}}/ftl-language-kotlin" -tags release -gcflags=all="-N -l" -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./go-runtime/cmd/ftl-language-kotlin"
else
mk "{{RELEASE}}/ftl-language-kotlin" : !(build|integration) -- go build -o "{{RELEASE}}/ftl-language-kotlin" -tags release -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./jvm-runtime/cmd/ftl-language-kotlin"
fi

build-java *args: build-zips build-protos
#!/bin/bash
shopt -s extglob
binary="${2:-$(basename "$1")}"

if [ "${FTL_DEBUG:-}" = "true" ]; then
go build -o "{{RELEASE}}/ftl-language-java" -tags release -gcflags=all="-N -l" -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./jvm-runtime/cmd/ftl-language-java"
go build -o "{{RELEASE}}/${binary}" -tags release -gcflags=all="-N -l" -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "$1"
else
mk "{{RELEASE}}/ftl-language-java" : !(build|integration) -- go build -o "{{RELEASE}}/ftl-language-java" -tags release -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./jvm-runtime/cmd/ftl-language-java"
mk "{{RELEASE}}/${binary}" : !(build|integration|infrastructure|node_modules|Procfile*|Dockerfile*) -- go build -o "{{RELEASE}}/${binary}" -tags release -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "$1"
fi

export DATABASE_URL := "postgres://postgres:secret@localhost:15432/ftl?sslmode=disable"
Expand Down Expand Up @@ -303,9 +276,11 @@ debug *args:
dlv_pid=$!
wait "$dlv_pid"

# Bring up localstack
localstack:
docker compose up localstack -d --wait

# Bring down localstack
localstack-stop:
docker compose down localstack

Expand All @@ -321,5 +296,6 @@ build-docker name:
-t ftl0/ftl-{{name}}:latest \
-f Dockerfile.{{name}} .

# Run a Just command in the Helm charts directory
chart *args:
@cd charts && just {{args}}

0 comments on commit 59f3dbc

Please sign in to comment.