Skip to content

Commit

Permalink
feat: ftl-schema command (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas authored Sep 5, 2023
1 parent 7a66de4 commit 1b14365
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
78 changes: 78 additions & 0 deletions Bitfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
VERSION = %(git describe --tags --always --dirty)%
DEST = build
RELEASE = %{DEST}/release

GO_SOURCES = **/*.go


SCHEMA_IN = backend/schema/schema.go backend/schema/protobuf.go \
cmd/ftl/cmd_schema.go
SCHEMA_OUT = protos/xyz/block/ftl/v1/schema/schema.proto

PROTO_IN = **/*.proto **/buf.* protos/xyz/block/ftl/v1/schema/schema.proto
PROTO_OUT = protos/xyz/block/ftl/v1/ftlv1connect/ftl.connect.go \
protos/xyz/block/ftl/v1/schema/schema.pb.go \
protos/xyz/block/ftl/v1/console/console.pb.go \
protos/xyz/block/ftl/v1/schema/runtime.pb.go \
protos/xyz/block/ftl/v1/ftl.pb.go \
console/client/src/protos/xyz/block/ftl/v1/ftl_connect.ts \
console/client/src/protos/xyz/block/ftl/v1/schema/schema_pb.ts \
console/client/src/protos/xyz/block/ftl/v1/schema/runtime_pb.ts \
console/client/src/protos/xyz/block/ftl/v1/ftl_pb.ts \
console/client/src/protos/xyz/block/ftl/v1/console/console_pb.ts

COMMON_LOG_IN = backend/common/log/api.go
COMMON_LOG_OUT = backend/common/log/log_level_string.go

KT_RUNTIME_IN = kotlin-runtime/ftl-runtime/**/*.{kt,kts} kotlin-runtime/gradle/libs.versions.toml
KT_RUNTIME_OUT = kotlin-runtime/ftl-runtime/build/libs/ftl-runtime.jar

CLIENT_OUT = console/client/dist/index.html
CLIENT_IN = console/client/**/*

#virtual release:
# inputs: %{RELEASE}/ftl %{RELEASE}/ftl-controller %{RELEASE}/ftl-runner

%{RELEASE}:
build: install -m 0700 -d %{OUT}

# Build all binaries
implicit %{RELEASE}/%{1}: cmd/*
inputs: %{RELEASE} %{GO_SOURCES}
build: go build -o %{OUT} -tags release -ldflags "-X main.version=%{VERSION}" ./cmd/%{1}

#%{RELEASE}/ftl-controller: %{RELEASE} %{GO_SOURCES} #%{CLIENT_OUT}
# build: go build -o %{OUT} -tags release -ldflags "-X main.version=%{VERSION}" ./cmd/ftl-controller

%{SCHEMA_OUT}: %{SCHEMA_IN}
build: ftl-schema > %{OUT}

%{PROTO_OUT}: %{PROTO_IN}
build:
buf format -w
buf lint
(cd protos && buf generate)
(cd backend/common/3rdparty/protos && buf generate)
-clean

export GRADLE_OPTS = -Dorg.gradle.console=plain

%{KT_RUNTIME_OUT}: %{KT_RUNTIME_IN} %{PROTO_IN}
cd kotlin-runtime/ftl-runtime
build: gradle jar
+clean: gradle clean

build/template/ftl/jars:
build: install -m 0700 -d %{OUT}

build/template/ftl/jars/ftl-runtime.jar: %{KT_RUNTIME_OUT} build/template/ftl/jars
build: install -m 0600 %{KT_RUNTIME_OUT} %{OUT}

%{COMMON_LOG_OUT}: %{COMMON_LOG_IN}
build: go generate %{IN}

#%{CLIENT_OUT}: %{CLIENT_IN}
# cd console/client
# build:
# npm install
# npm run build
1 change: 1 addition & 0 deletions bin/.bit-0.0.1.pkg
1 change: 1 addition & 0 deletions bin/bit
11 changes: 11 additions & 0 deletions cmd/ftl-schema/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"fmt"

"github.com/TBD54566975/ftl/backend/schema"
)

func main() {
fmt.Println(schema.ProtobufSchema())
}
1 change: 1 addition & 0 deletions scripts/ftl-schema

0 comments on commit 1b14365

Please sign in to comment.