Build with Magefile #104341
139
Makefile
139
Makefile
@ -23,10 +23,11 @@ ifeq (${GITHASH},dirty)
|
||||
GITHASH := $(shell git rev-parse --short=9 HEAD)
|
||||
endif
|
||||
|
||||
LDFLAGS := ${LDFLAGS} -X ${PKG}/internal/appinfo.ApplicationVersion=${VERSION} \
|
||||
-X ${PKG}/internal/appinfo.ApplicationGitHash=${GITHASH} \
|
||||
-X ${PKG}/internal/appinfo.ReleaseCycle=${RELEASE_CYCLE}
|
||||
BUILD_FLAGS = -ldflags="${LDFLAGS}"
|
||||
BUILDTOOL := mage
|
||||
ifeq ($(OS),Windows_NT)
|
||||
BUILDTOOL := $(BUILDTOOL).exe
|
||||
endif
|
||||
BUILDTOOL_PATH := ${PWD}/${BUILDTOOL}
|
||||
|
||||
# Package name of the generated Python/JavaScript code for the Flamenco API.
|
||||
PY_API_PKG_NAME=flamenco.manager
|
||||
@ -59,17 +60,20 @@ vet:
|
||||
|
||||
application: webapp flamenco-manager flamenco-worker
|
||||
|
||||
flamenco-manager:
|
||||
$(MAKE) webapp-static
|
||||
go build -v ${BUILD_FLAGS} ${PKG}/cmd/flamenco-manager
|
||||
flamenco-manager: buildtool
|
||||
"${BUILDTOOL_PATH}" flamencoManager
|
||||
|
||||
.PHONY: flamenco-manager-without-webapp
|
||||
flamenco-manager-without-webapp:
|
||||
go build -v ${BUILD_FLAGS} ${PKG}/cmd/flamenco-manager
|
||||
flamenco-manager-without-webapp: buildtool
|
||||
"${BUILDTOOL_PATH}" flamencoManagerWithoutWebapp
|
||||
|
||||
flamenco-worker:
|
||||
go build -v ${BUILD_FLAGS} ${PKG}/cmd/flamenco-worker
|
||||
flamenco-worker: buildtool
|
||||
"${BUILDTOOL_PATH}" flamencoWorker
|
||||
|
||||
# Builds the buildtool itself, for faster rebuilds of Skyfill.
|
||||
buildtool: ${BUILDTOOL}
|
||||
${BUILDTOOL}: mage.go $(wildcard magefiles/*.go) go.mod
|
||||
@echo "Building build tool $@"
|
||||
@go run mage.go -compile "${BUILDTOOL_PATH}"
|
||||
|
||||
# NOTE: these database migration commands are just for reference / debugging /
|
||||
# development purposes. Flamenco Manager and Worker each perform their own
|
||||
@ -85,118 +89,29 @@ db-migrate-down:
|
||||
goose -dir ./internal/manager/persistence/migrations/ sqlite3 flamenco-manager.sqlite down
|
||||
.PHONY: db-migrate-status db-migrate-up db-migrate-down
|
||||
|
||||
.PHONY: stresser
|
||||
stresser:
|
||||
go build -v ${BUILD_FLAGS} ${PKG}/cmd/stresser
|
||||
|
||||
.PHONY: job-creator
|
||||
job-creator:
|
||||
go build -v ${BUILD_FLAGS} ${PKG}/cmd/job-creator
|
||||
|
||||
flamenco-addon.zip: addon-packer
|
||||
./addon-packer -filename ./flamenco-addon.zip
|
||||
|
||||
addon-packer: cmd/addon-packer/addon-packer.go
|
||||
go build -v ${BUILD_FLAGS} ${PKG}/cmd/addon-packer
|
||||
|
||||
flamenco-manager_race:
|
||||
CGO_ENABLED=1 go build -race -o $@ -v ${BUILD_FLAGS} ${PKG}/cmd/flamenco-manager
|
||||
|
||||
flamenco-worker_race:
|
||||
CGO_ENABLED=1 go build -race -o $@ -v ${BUILD_FLAGS} ${PKG}/cmd/flamenco-worker
|
||||
|
||||
.PHONY: shaman-checkout-id-setter
|
||||
shaman-checkout-id-setter:
|
||||
go build -v ${BUILD_FLAGS} ${PKG}/cmd/shaman-checkout-id-setter
|
||||
|
||||
webapp:
|
||||
yarn --cwd web/app install
|
||||
|
||||
webapp-static: addon-packer
|
||||
$(MAKE) clean-webapp-static
|
||||
# When changing the base URL, also update the line
|
||||
# e.GET("/app/*", echo.WrapHandler(webAppHandler))
|
||||
# in `cmd/flamenco-manager/main.go`
|
||||
MSYS2_ARG_CONV_EXCL="*" yarn --cwd web/app build --outDir ../static --base=/app/ --logLevel warn
|
||||
# yarn --cwd web/app build --outDir ../static --base=/app/ --minify false
|
||||
./addon-packer -filename ${WEB_STATIC}/flamenco-addon.zip
|
||||
@echo "Web app has been installed into ${WEB_STATIC}"
|
||||
webapp-static: buildtool
|
||||
"${BUILDTOOL_PATH}" webappStatic
|
||||
|
||||
generate:
|
||||
$(MAKE) generate-go
|
||||
$(MAKE) generate-py
|
||||
$(MAKE) generate-js
|
||||
generate: buildtool
|
||||
"${BUILDTOOL_PATH}" generate
|
||||
|
||||
generate-go:
|
||||
go generate ./pkg/api/...
|
||||
go generate ./internal/...
|
||||
# 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
|
||||
generate-go: buildtool
|
||||
"${BUILDTOOL_PATH}" generateGo
|
||||
|
||||
generate-py:
|
||||
# The generator doesn't consistently overwrite existing files, nor does it
|
||||
# remove no-longer-generated files.
|
||||
rm -rf addon/flamenco/manager
|
||||
generate-py: buildtool
|
||||
"${BUILDTOOL_PATH}" generatePy
|
||||
|
||||
# See https://openapi-generator.tech/docs/generators/python for the options.
|
||||
java -jar addon/openapi-generator-cli.jar \
|
||||
generate \
|
||||
-i pkg/api/flamenco-openapi.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}" > .openapi-generator-py.log
|
||||
|
||||
# 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
|
||||
# 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 addon/flamenco/manager' | cut -d' ' -f3 | xargs unix2dos --keepdate
|
||||
endif
|
||||
|
||||
generate-js:
|
||||
# The generator doesn't consistently overwrite existing files, nor does it
|
||||
# remove no-longer-generated files.
|
||||
rm -rf web/app/src/manager-api
|
||||
rm -rf web/_tmp-manager-api-javascript
|
||||
|
||||
# See https://openapi-generator.tech/docs/generators/javascript for the options.
|
||||
# Version '0.0.0' is used as NPM doesn't like Git hashes as versions.
|
||||
#
|
||||
# -p modelPropertyNaming=original is needed because otherwise the generator will
|
||||
# use original naming internally, but generate docs with camelCase, and then
|
||||
# things don't work properly.
|
||||
java -jar addon/openapi-generator-cli.jar \
|
||||
generate \
|
||||
-i pkg/api/flamenco-openapi.yaml \
|
||||
-g javascript \
|
||||
-o web/_tmp-manager-api-javascript \
|
||||
--http-user-agent "Flamenco/${VERSION} / webbrowser" \
|
||||
-p projectName=flamenco-manager \
|
||||
-p projectVersion="0.0.0" \
|
||||
-p apiPackage="${JS_API_PKG_NAME}" \
|
||||
-p disallowAdditionalPropertiesIfNotPresent=false \
|
||||
-p usePromises=true \
|
||||
-p moduleName=flamencoManager > .openapi-generator-js.log
|
||||
|
||||
# Cherry-pick the generated sources, and remove everything else.
|
||||
# The only relevant bit is that the generated code depends on `superagent`,
|
||||
# which is listed in our `.
|
||||
mv web/_tmp-manager-api-javascript/src web/app/src/manager-api
|
||||
rm -rf web/_tmp-manager-api-javascript
|
||||
# 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 web/app/src/manager-api' | cut -d' ' -f3 | xargs unix2dos --keepdate
|
||||
endif
|
||||
generate-js: buildtool
|
||||
"${BUILDTOOL_PATH}" generateJS
|
||||
|
||||
.PHONY:
|
||||
update-version:
|
||||
@ -418,4 +333,4 @@ publish-release-packages:
|
||||
${RELEASE_PACKAGE_LINUX} ${RELEASE_PACKAGE_DARWIN} ${RELEASE_PACKAGE_DARWIN_ARM64} ${RELEASE_PACKAGE_WINDOWS} ${RELEASE_PACKAGE_SHAFILE} \
|
||||
${WEBSERVER_SSH}:${WEBSERVER_ROOT}/downloads/
|
||||
|
||||
.PHONY: application version flamenco-manager flamenco-worker flamenco-manager_race flamenco-worker_race webapp webapp-static generate generate-go generate-py with-deps swagger-ui list-embedded test clean clean-webapp-static
|
||||
.PHONY: application version flamenco-manager flamenco-worker flamenco-manager_race flamenco-worker_race webapp webapp-static generate generate-go generate-py with-deps swagger-ui list-embedded test clean clean-webapp-static flamenco-manager-without-webapp
|
||||
|
@ -55,10 +55,15 @@ func WebappStatic() error {
|
||||
return err
|
||||
}
|
||||
|
||||
env := map[string]string{
|
||||
"MSYS2_ARG_CONV_EXCL": "*",
|
||||
}
|
||||
|
||||
// When changing the base URL, also update the line
|
||||
// e.GET("/app/*", echo.WrapHandler(webAppHandler))
|
||||
// in `cmd/flamenco-manager/main.go`
|
||||
err := sh.Run("yarn",
|
||||
err := sh.RunWithV(env,
|
||||
"yarn",
|
||||
"--cwd", "web/app",
|
||||
"build",
|
||||
"--outDir", "../static",
|
||||
@ -87,7 +92,7 @@ func build(exePackage string) error {
|
||||
args := []string{"build", "-v"}
|
||||
args = append(args, flags...)
|
||||
args = append(args, exePackage)
|
||||
return sh.Run(mg.GoCmd(), args...)
|
||||
return sh.RunV(mg.GoCmd(), args...)
|
||||
}
|
||||
|
||||
func buildFlags() ([]string, error) {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
@ -41,7 +42,6 @@ func GeneratePy() error {
|
||||
sh.Rm("addon/flamenco/manager")
|
||||
|
||||
// See https://openapi-generator.tech/docs/generators/python for the options.
|
||||
|
||||
err := sh.Run("java",
|
||||
"-jar", "addon/openapi-generator-cli.jar",
|
||||
"generate",
|
||||
@ -49,10 +49,10 @@ func GeneratePy() error {
|
||||
"-g", "python",
|
||||
"-o", "addon/",
|
||||
"--package-name", "flamenco.manager",
|
||||
"--http-user-agent", fmt.Sprintf("Flamenco/%s / (Blender add-on)", version),
|
||||
"--http-user-agent", fmt.Sprintf("Flamenco/%s (Blender add-on)", version),
|
||||
"-p", "generateSourceCodeOnly=true",
|
||||
"-p", "projectName=Flamenco",
|
||||
"-p", fmt.Sprintf("packageVersion=\"%s\"", version))
|
||||
"-p", fmt.Sprintf("packageVersion=%s", version))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -64,16 +64,19 @@ func GeneratePy() error {
|
||||
// The generators always produce UNIX line-ends. This creates false file
|
||||
// modifications with Git. Convert them to DOS line-ends to avoid this.
|
||||
if runtime.GOOS == "windows" {
|
||||
// TODO: Go'ify this:
|
||||
// git status --porcelain | grep '^ M addon/flamenco/manager' | cut -d' ' -f3 | xargs unix2dos --keepdate
|
||||
unix2dosModifiedFiles("addon/flamenco/manager")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GenerateJS() error {
|
||||
sh.Rm("web/app/src/manager-api")
|
||||
sh.Rm("web/_tmp-manager-api-javascript")
|
||||
const (
|
||||
jsOutDir = "web/app/src/manager-api"
|
||||
jsTempDir = "web/_tmp-manager-api-javascript"
|
||||
)
|
||||
sh.Rm(jsOutDir)
|
||||
sh.Rm(jsTempDir)
|
||||
|
||||
// See https://openapi-generator.tech/docs/generators/javascript for the options.
|
||||
// Version '0.0.0' is used as NPM doesn't like Git hashes as versions.
|
||||
@ -81,12 +84,12 @@ func GenerateJS() error {
|
||||
// -p modelPropertyNaming=original is needed because otherwise the generator will
|
||||
// use original naming internally, but generate docs with camelCase, and then
|
||||
// things don't work properly.
|
||||
return sh.Run("java",
|
||||
err := sh.Run("java",
|
||||
"-jar", "addon/openapi-generator-cli.jar",
|
||||
"generate",
|
||||
"-i", "pkg/api/flamenco-openapi.yaml",
|
||||
"-g", "javascript",
|
||||
"-o", "web/_tmp-manager-api-javascript",
|
||||
"-o", jsTempDir,
|
||||
"--http-user-agent", fmt.Sprintf("Flamenco/%s / webbrowser", version),
|
||||
"-p", "projectName=flamenco-manager",
|
||||
"-p", "projectVersion=0.0.0",
|
||||
@ -94,6 +97,21 @@ func GenerateJS() error {
|
||||
"-p", "disallowAdditionalPropertiesIfNotPresent=false",
|
||||
"-p", "usePromises=true",
|
||||
"-p", "moduleName=flamencoManager")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Cherry-pick the generated sources, and remove everything else.
|
||||
if err := os.Rename(filepath.Join(jsTempDir, "src"), jsOutDir); err != nil {
|
||||
return err
|
||||
}
|
||||
sh.Rm(jsTempDir)
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
unix2dosModifiedFiles(jsOutDir)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// unix2dosModifiedFiles changes line ends in files Git considers modified that match the given pattern.
|
||||
|
@ -38,7 +38,7 @@ func (r *Runner) Run(cmd string, args ...string) {
|
||||
if err := r.ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
return sh.Run(cmd, args...)
|
||||
return sh.RunV(cmd, args...)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user