2022-03-01 19:45:09 +00:00
|
|
|
PKG := git.blender.org/flamenco
|
2022-01-03 14:05:10 +00:00
|
|
|
VERSION := $(shell git describe --tags --dirty --always)
|
|
|
|
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
|
|
|
|
|
2022-01-06 16:46:43 +00:00
|
|
|
LDFLAGS := -X ${PKG}/internal/appinfo.ApplicationVersion=${VERSION}
|
2022-01-03 14:05:10 +00:00
|
|
|
BUILD_FLAGS = -ldflags="${LDFLAGS}"
|
|
|
|
|
2022-03-10 14:47:21 +00:00
|
|
|
# Package name of the generated Python code for the Flamenco API.
|
|
|
|
PY_API_PKG_NAME=flamenco.manager
|
|
|
|
|
2022-02-28 12:01:13 +00:00
|
|
|
# Prevent any dependency that requires a C compiler, i.e. only work with pure-Go libraries.
|
2022-02-24 10:37:02 +00:00
|
|
|
export CGO_ENABLED=0
|
|
|
|
|
2022-01-03 14:05:10 +00:00
|
|
|
all: application
|
|
|
|
|
2022-01-24 13:27:25 +00:00
|
|
|
# Install generators and build the software.
|
|
|
|
with-deps:
|
2022-02-18 16:54:43 +00:00
|
|
|
go get github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.9.0
|
|
|
|
go get github.com/golang/mock/mockgen@v1.6.0
|
2022-02-25 15:08:08 +00:00
|
|
|
$(MAKE) application
|
2022-01-24 13:27:25 +00:00
|
|
|
|
2022-03-03 10:51:15 +00:00
|
|
|
application: flamenco-manager flamenco-worker socketio-poc
|
2022-02-17 10:11:42 +00:00
|
|
|
|
2022-02-28 12:01:13 +00:00
|
|
|
flamenco-manager:
|
|
|
|
go build -v ${BUILD_FLAGS} ${PKG}/cmd/flamenco-manager
|
2022-02-17 10:11:42 +00:00
|
|
|
|
2022-02-28 12:01:13 +00:00
|
|
|
flamenco-worker:
|
|
|
|
go build -v ${BUILD_FLAGS} ${PKG}/cmd/flamenco-worker
|
2022-02-17 10:11:42 +00:00
|
|
|
|
|
|
|
socketio-poc:
|
2022-02-11 13:47:26 +00:00
|
|
|
go build -v ${BUILD_FLAGS} ${PKG}/cmd/socketio-poc
|
2022-01-03 14:05:10 +00:00
|
|
|
|
2022-03-10 14:47:21 +00:00
|
|
|
generate: generate-go generate-py
|
|
|
|
|
|
|
|
generate-go:
|
2022-02-25 15:08:08 +00:00
|
|
|
go generate ./pkg/api/...
|
2022-02-24 10:35:54 +00:00
|
|
|
go generate ./internal/...
|
2022-03-03 10:49:26 +00:00
|
|
|
# The generators always produce UNIX line-ends. This creates false file
|
|
|
|
# modifications with Git. Convert them to DOS line-ends to avoid this.
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
git status --porcelain | grep '^ M .*.gen.go' | cut -d' ' -f3 | xargs unix2dos --keepdate
|
|
|
|
endif
|
2022-01-28 14:31:39 +00:00
|
|
|
|
2022-03-10 14:47:21 +00:00
|
|
|
generate-py:
|
|
|
|
# The generator doesn't consistently overwrite existing files, nor does it
|
|
|
|
# remove no-longer-generated files.
|
|
|
|
rm -rf addon/flamenco/manager
|
|
|
|
|
|
|
|
java -jar addon/openapi-generator-cli.jar \
|
|
|
|
generate \
|
|
|
|
-i pkg/api/flamenco-manager.yaml \
|
|
|
|
-g python \
|
|
|
|
-o addon/ \
|
|
|
|
--package-name "${PY_API_PKG_NAME}" \
|
|
|
|
--http-user-agent "Flamenco/${VERSION} (Blender add-on)" \
|
|
|
|
-p generateSourceCodeOnly=true \
|
|
|
|
-p projectName=Flamenco \
|
|
|
|
-p packageVersion="${VERSION}"
|
|
|
|
|
|
|
|
# The generator outputs files so that we can write our own tests. We don't,
|
|
|
|
# though, so it's better to just remove those placeholders.
|
|
|
|
rm -rf addon/flamenco/manager/test
|
|
|
|
|
2022-01-03 14:05:10 +00:00
|
|
|
version:
|
|
|
|
@echo "OS : ${OS}"
|
|
|
|
@echo "Package: ${PKG}"
|
|
|
|
@echo "Version: ${VERSION}"
|
2022-02-24 10:35:54 +00:00
|
|
|
@echo
|
|
|
|
@env | grep GO
|
2022-01-03 14:05:10 +00:00
|
|
|
|
2022-01-06 16:46:43 +00:00
|
|
|
list-embedded:
|
|
|
|
@go list -f '{{printf "%10s" .Name}}: {{.EmbedFiles}}' ${PKG}/...
|
|
|
|
|
|
|
|
swagger-ui:
|
|
|
|
git clone --depth 1 https://github.com/swagger-api/swagger-ui.git tmp-swagger-ui
|
|
|
|
rm -rf pkg/api/static/swagger-ui
|
|
|
|
mv tmp-swagger-ui/dist pkg/api/static/swagger-ui
|
|
|
|
rm -rf tmp-swagger-ui
|
|
|
|
@echo
|
|
|
|
@echo 'Now update pkg/api/static/swagger-ui/index.html to have url: "/api/openapi3.json",'
|
2022-01-03 15:54:38 +00:00
|
|
|
|
2022-02-19 13:39:43 +00:00
|
|
|
test:
|
2022-02-01 16:16:16 +00:00
|
|
|
go test -p 1 -short ${PKG_LIST}
|
2022-01-03 14:05:10 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
@go clean -i -x
|
2022-02-28 12:01:13 +00:00
|
|
|
rm -f flamenco*-v* flamenco-manager flamenco-worker socketio-poc *.exe
|
2022-02-25 15:08:08 +00:00
|
|
|
rm -f pkg/api/*.gen.go internal/*/mocks/*.gen.go internal/*/*/mocks/*.gen.go
|
2022-02-24 10:35:54 +00:00
|
|
|
@$(MAKE) generate
|
2022-01-03 14:05:10 +00:00
|
|
|
|
2022-03-17 15:54:37 +00:00
|
|
|
package: flamenco-manager flamenco-worker
|
|
|
|
mkdir -p dist
|
|
|
|
rsync -a flamenco-manager flamenco-worker dist/
|
|
|
|
rsync -a addon/flamenco dist/ --exclude __pycache__ --exclude '*.pyc' --prune-empty-dirs --exclude .mypy_cache --exclude manager/docs --delete --delete-excluded
|
|
|
|
cd dist; zip -r -9 flamenco-${VERSION}-addon.zip flamenco
|
|
|
|
rm -rf dist/flamenco
|
|
|
|
|
|
|
|
|
2022-03-10 14:47:21 +00:00
|
|
|
.PHONY: application version flamenco-manager flamenco-worker socketio-poc generate generate-go generate-py with-deps swagger-ui list-embedded test clean
|