2021-02-11 18:21:21 +00:00
|
|
|
GOESBUILD ?= off
|
|
|
|
ifeq ($(GOESBUILD), on)
|
|
|
|
ESBUILD := esbuild
|
|
|
|
else
|
|
|
|
ESBUILD := npx esbuild
|
|
|
|
endif
|
2021-02-01 20:55:17 +00:00
|
|
|
GOBINARY ?= go
|
2021-02-11 18:21:21 +00:00
|
|
|
|
2021-02-22 01:26:07 +00:00
|
|
|
VERSION ?= $(shell git describe --exact-match HEAD 2> /dev/null || echo vgit)
|
2021-02-22 01:23:42 +00:00
|
|
|
VERSION := $(shell echo $(VERSION) | sed 's/v//g')
|
|
|
|
COMMIT ?= $(shell git rev-parse --short HEAD || echo unknown)
|
|
|
|
|
2021-03-07 15:23:44 +00:00
|
|
|
UPDATER ?= off
|
2021-04-01 13:22:11 +00:00
|
|
|
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT)
|
2021-03-07 15:23:44 +00:00
|
|
|
ifeq ($(UPDATER), on)
|
2021-04-01 13:22:11 +00:00
|
|
|
LDFLAGS := $(LDFLAGS) -X main.updater=binary
|
2021-03-07 15:23:44 +00:00
|
|
|
else ifneq ($(UPDATER), off)
|
2021-04-01 13:22:11 +00:00
|
|
|
LDFLAGS := $(LDFLAGS) -X main.updater=$(UPDATER)
|
|
|
|
endif
|
|
|
|
|
|
|
|
DEBUG ?= off
|
|
|
|
ifeq ($(DEBUG), on)
|
|
|
|
LDFLAGS := -s -w $(LDFLAGS)
|
|
|
|
endif
|
|
|
|
|
|
|
|
INTERNAL ?= on
|
|
|
|
ifeq ($(INTERNAL), on)
|
|
|
|
# GOFILES := $(addprefix ../,$(filter-out external.go, $(wildcard *.go)))
|
|
|
|
TAGS :=
|
|
|
|
DATA := data
|
|
|
|
else
|
|
|
|
# GOFILES := $(addprefix ../,$(filter-out internal.go, $(wildcard *.go)))
|
|
|
|
DATA := build/data
|
|
|
|
TAGS := -tags external
|
2021-03-07 15:23:44 +00:00
|
|
|
endif
|
|
|
|
|
2021-01-05 18:16:23 +00:00
|
|
|
npm:
|
|
|
|
$(info installing npm dependencies)
|
|
|
|
npm install
|
2021-02-11 18:21:21 +00:00
|
|
|
@if [ "$(GOESBUILD)" = "off" ]; then\
|
|
|
|
npm install esbuild;\
|
|
|
|
else\
|
|
|
|
go get -u github.com/evanw/esbuild/cmd/esbuild;\
|
|
|
|
fi
|
2021-01-05 18:16:23 +00:00
|
|
|
|
2020-08-03 17:00:54 +00:00
|
|
|
configuration:
|
2020-09-21 21:03:20 +00:00
|
|
|
$(info Fixing config-base)
|
2021-04-01 13:22:11 +00:00
|
|
|
-mkdir -p $(DATA)
|
|
|
|
python3 scripts/enumerate_config.py -i config/config-base.json -o $(DATA)/config-base.json
|
2020-09-21 21:03:20 +00:00
|
|
|
$(info Generating config-default.ini)
|
2021-04-01 13:22:11 +00:00
|
|
|
python3 scripts/generate_ini.py -i config/config-base.json -o $(DATA)/config-default.ini
|
2020-08-03 17:00:54 +00:00
|
|
|
|
2020-10-17 23:57:53 +00:00
|
|
|
email:
|
2020-09-21 21:03:20 +00:00
|
|
|
$(info Generating email html)
|
2021-04-01 13:22:11 +00:00
|
|
|
python3 scripts/compile_mjml.py -o $(DATA)/
|
2020-08-03 17:00:54 +00:00
|
|
|
|
2021-01-05 18:40:19 +00:00
|
|
|
typescript:
|
2021-01-05 18:16:23 +00:00
|
|
|
$(info compiling typescript)
|
2021-04-01 13:22:11 +00:00
|
|
|
-mkdir -p $(DATA)/web/js
|
|
|
|
-$(ESBUILD) --bundle ts/admin.ts --outfile=./$(DATA)/web/js/admin.js --minify
|
|
|
|
-$(ESBUILD) --bundle ts/pwr.ts --outfile=./$(DATA)/web/js/pwr.js --minify
|
|
|
|
-$(ESBUILD) --bundle ts/form.ts --outfile=./$(DATA)/web/js/form.js --minify
|
|
|
|
-$(ESBUILD) --bundle ts/setup.ts --outfile=./$(DATA)/web/js/setup.js --minify
|
2020-09-21 21:03:20 +00:00
|
|
|
|
2020-09-23 19:14:16 +00:00
|
|
|
ts-debug:
|
2021-01-05 18:16:23 +00:00
|
|
|
$(info compiling typescript w/ sourcemaps)
|
2021-04-01 13:22:11 +00:00
|
|
|
-mkdir -p $(DATA)/web/js
|
|
|
|
-$(ESBUILD) --bundle ts/admin.ts --sourcemap --outfile=./$(DATA)/web/js/admin.js
|
|
|
|
-$(ESBUILD) --bundle ts/pwr.ts --sourcemap --outfile=./$(DATA)/web/js/pwr.js
|
|
|
|
-$(ESBUILD) --bundle ts/form.ts --sourcemap --outfile=./$(DATA)/web/js/form.js
|
|
|
|
-$(ESBUILD) --bundle ts/setup.ts --sourcemap --outfile=./$(DATA)/web/js/setup.js
|
|
|
|
-rm -r $(DATA)/web/js/ts
|
2021-01-05 18:16:23 +00:00
|
|
|
$(info copying typescript)
|
2021-04-01 13:22:11 +00:00
|
|
|
cp -r ts $(DATA)/web/js
|
2020-09-23 19:14:16 +00:00
|
|
|
|
2020-09-24 16:51:13 +00:00
|
|
|
swagger:
|
2021-02-01 20:55:17 +00:00
|
|
|
$(GOBINARY) get github.com/swaggo/swag/cmd/swag
|
2020-09-24 16:51:13 +00:00
|
|
|
swag init -g main.go
|
|
|
|
|
2020-08-03 17:00:54 +00:00
|
|
|
compile:
|
2021-02-05 13:01:45 +00:00
|
|
|
$(info Downloading deps)
|
|
|
|
$(GOBINARY) mod download
|
|
|
|
$(info Building)
|
|
|
|
mkdir -p build
|
2021-04-01 13:22:11 +00:00
|
|
|
# cd build && CGO_ENABLED=0 $(GOBINARY) build -ldflags="-s -w $(LDFLAGS)" -o ./jfa-go ../*.go
|
|
|
|
CGO_ENABLED=0 $(GOBINARY) build -ldflags="-s -w $(LDFLAGS)" $(TAGS) -o build/jfa-go
|
2020-09-02 19:06:02 +00:00
|
|
|
|
|
|
|
compress:
|
|
|
|
upx --lzma build/jfa-go
|
2020-08-03 17:00:54 +00:00
|
|
|
|
2021-01-23 18:53:14 +00:00
|
|
|
bundle-css:
|
2021-04-01 13:22:11 +00:00
|
|
|
-mkdir -p $(DATA)/web/css
|
2021-01-23 18:53:14 +00:00
|
|
|
$(info bundling css)
|
2021-04-01 13:22:11 +00:00
|
|
|
$(ESBUILD) --bundle css/base.css --outfile=$(DATA)/web/css/bundle.css --external:remixicon.css --minify
|
2021-01-23 18:53:14 +00:00
|
|
|
|
|
|
|
copy:
|
|
|
|
$(info copying fonts)
|
2021-04-01 13:22:11 +00:00
|
|
|
cp -r node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 $(DATA)/web/css/
|
2021-01-05 18:16:23 +00:00
|
|
|
$(info copying html)
|
2021-04-01 13:22:11 +00:00
|
|
|
cp -r html $(DATA)/
|
2021-01-05 18:16:23 +00:00
|
|
|
$(info copying static data)
|
2021-04-01 13:22:11 +00:00
|
|
|
-mkdir -p $(DATA)/web
|
|
|
|
cp -r static/* $(DATA)/web/
|
2021-01-05 18:16:23 +00:00
|
|
|
$(info copying language files)
|
2021-04-01 13:22:11 +00:00
|
|
|
cp -r lang $(DATA)/
|
|
|
|
cp LICENSE $(DATA)/
|
|
|
|
|
|
|
|
# internal-files:
|
|
|
|
# python3 scripts/embed.py internal
|
|
|
|
#
|
|
|
|
# external-files:
|
|
|
|
# python3 scripts/embed.py external
|
|
|
|
# -mkdir -p build
|
|
|
|
# $(info copying internal data into build/)
|
|
|
|
# cp -r data build/
|
2020-08-03 17:00:54 +00:00
|
|
|
|
2020-08-19 11:10:34 +00:00
|
|
|
install:
|
|
|
|
cp -r build $(DESTDIR)/jfa-go
|
|
|
|
|
2021-04-01 13:22:11 +00:00
|
|
|
clean:
|
|
|
|
-rm -r $(DATA)
|
|
|
|
-rm -r build
|
|
|
|
-rm mail/*.html
|
|
|
|
-rm embed.go
|
|
|
|
-rm docs/docs.go docs/swagger.json docs/swagger.yaml
|
|
|
|
go clean
|
|
|
|
|
|
|
|
all: configuration npm email typescript bundle-css swagger copy compile
|