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
|
|
|
|
2022-01-08 16:42:36 +00:00
|
|
|
CSSVERSION ?= v3
|
|
|
|
|
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
|
2022-01-08 16:42:36 +00:00
|
|
|
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.cssVersion=$(CSSVERSION)
|
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
|
|
|
|
|
2021-07-16 14:41:08 +00:00
|
|
|
|
|
|
|
|
2021-04-01 13:22:11 +00:00
|
|
|
INTERNAL ?= on
|
2021-07-16 14:41:08 +00:00
|
|
|
TRAY ?= off
|
|
|
|
E2EE ?= off
|
|
|
|
TAGS := -tags "
|
|
|
|
|
2021-04-01 13:22:11 +00:00
|
|
|
ifeq ($(INTERNAL), on)
|
|
|
|
DATA := data
|
|
|
|
else
|
|
|
|
DATA := build/data
|
2021-07-16 14:41:08 +00:00
|
|
|
TAGS := $(TAGS) external
|
2021-03-07 15:23:44 +00:00
|
|
|
endif
|
|
|
|
|
2021-07-16 14:41:08 +00:00
|
|
|
ifeq ($(TRAY), on)
|
2021-05-16 15:23:28 +00:00
|
|
|
TAGS := $(TAGS) tray
|
|
|
|
endif
|
|
|
|
|
2021-07-16 14:41:08 +00:00
|
|
|
ifeq ($(E2EE), on)
|
|
|
|
TAGS := $(TAGS) e2ee
|
|
|
|
endif
|
|
|
|
|
|
|
|
TAGS := $(TAGS)"
|
|
|
|
|
2021-05-16 15:23:28 +00:00
|
|
|
OS := $(shell go env GOOS)
|
|
|
|
ifeq ($(TRAY)$(OS), onwindows)
|
|
|
|
LDFLAGS := $(LDFLAGS) -H=windowsgui
|
|
|
|
endif
|
|
|
|
|
2021-04-01 13:33:57 +00:00
|
|
|
DEBUG ?= off
|
|
|
|
ifeq ($(DEBUG), on)
|
|
|
|
SOURCEMAP := --sourcemap
|
2023-06-11 14:11:00 +00:00
|
|
|
TYPECHECK := npx tsc -noEmit --project ts/tsconfig.json
|
2021-04-01 13:33:57 +00:00
|
|
|
# jank
|
2022-01-04 20:12:19 +00:00
|
|
|
COPYTS := rm -r $(DATA)/web/js/ts; cp -r tempts $(DATA)/web/js/ts
|
2021-06-13 15:31:40 +00:00
|
|
|
UNCSS := cp $(DATA)/web/css/bundle.css $(DATA)/bundle.css
|
2023-06-12 17:44:10 +00:00
|
|
|
# TAILWIND := --content ""
|
2021-04-01 13:33:57 +00:00
|
|
|
else
|
2021-05-16 14:00:13 +00:00
|
|
|
LDFLAGS := -s -w $(LDFLAGS)
|
2021-04-01 13:33:57 +00:00
|
|
|
SOURCEMAP :=
|
|
|
|
COPYTS :=
|
2021-05-03 17:32:56 +00:00
|
|
|
TYPECHECK :=
|
2021-12-31 15:09:33 +00:00
|
|
|
UNCSS := npx tailwindcss -i $(DATA)/web/css/bundle.css -o $(DATA)/bundle.css --content "html/crash.html"
|
|
|
|
# UNCSS := npx uncss $(DATA)/crash.html --csspath web/css --output $(DATA)/bundle.css
|
2021-12-30 23:52:53 +00:00
|
|
|
TAILWIND :=
|
2021-04-01 13:33:57 +00:00
|
|
|
endif
|
|
|
|
|
2021-05-23 21:26:56 +00:00
|
|
|
RACE ?= off
|
|
|
|
ifeq ($(RACE), on)
|
|
|
|
RACEDETECTOR := -race
|
|
|
|
else
|
|
|
|
RACEDETECTOR :=
|
|
|
|
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\
|
2023-02-02 09:41:14 +00:00
|
|
|
go install github.com/evanw/esbuild/cmd/esbuild@latest;\
|
2021-02-11 18:21:21 +00:00
|
|
|
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-05-03 17:32:56 +00:00
|
|
|
$(TYPECHECK)
|
2021-12-30 02:45:29 +00:00
|
|
|
$(adding dark variants to typescript)
|
2022-01-30 18:03:21 +00:00
|
|
|
rm -rf tempts
|
2021-12-30 02:45:29 +00:00
|
|
|
cp -r ts tempts
|
2022-01-04 20:12:19 +00:00
|
|
|
scripts/dark-variant.sh tempts
|
|
|
|
scripts/dark-variant.sh tempts/modules
|
2021-01-05 18:16:23 +00:00
|
|
|
$(info compiling typescript)
|
2022-01-30 18:03:21 +00:00
|
|
|
mkdir -p $(DATA)/web/js
|
2023-06-12 17:44:10 +00:00
|
|
|
$(ESBUILD) --target=es6 --bundle tempts/admin.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/admin.js --minify
|
2023-06-16 13:43:37 +00:00
|
|
|
$(ESBUILD) --target=es6 --bundle tempts/user.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/user.js --minify
|
2023-06-12 17:44:10 +00:00
|
|
|
$(ESBUILD) --target=es6 --bundle tempts/pwr.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/pwr.js --minify
|
|
|
|
$(ESBUILD) --target=es6 --bundle tempts/form.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/form.js --minify
|
|
|
|
$(ESBUILD) --target=es6 --bundle tempts/setup.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/setup.js --minify
|
|
|
|
$(ESBUILD) --target=es6 --bundle tempts/crash.ts --outfile=./$(DATA)/crash.js --minify
|
2021-04-01 13:33:57 +00:00
|
|
|
$(COPYTS)
|
2020-09-23 19:14:16 +00:00
|
|
|
|
2020-09-24 16:51:13 +00:00
|
|
|
swagger:
|
2022-03-22 15:15:57 +00:00
|
|
|
$(GOBINARY) install github.com/swaggo/swag/cmd/swag@latest
|
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-05-23 21:26:56 +00:00
|
|
|
$(GOBINARY) build $(RACEDETECTOR) -ldflags="$(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:
|
2022-01-30 18:03:21 +00:00
|
|
|
mkdir -p $(DATA)/web/css
|
2023-06-12 17:44:10 +00:00
|
|
|
$(info copying fonts)
|
|
|
|
cp -r node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 $(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-12-30 23:52:53 +00:00
|
|
|
npx tailwindcss -i $(DATA)/web/css/bundle.css -o $(DATA)/web/css/bundle.css $(TAILWIND)
|
|
|
|
# npx postcss -o $(DATA)/web/css/bundle.css $(DATA)/web/css/bundle.css
|
2021-06-11 22:14:16 +00:00
|
|
|
|
2022-01-26 14:26:10 +00:00
|
|
|
inline-css:
|
2021-06-11 20:56:53 +00:00
|
|
|
cp html/crash.html $(DATA)/crash.html
|
2021-06-13 15:31:40 +00:00
|
|
|
$(UNCSS)
|
2021-11-14 14:50:40 +00:00
|
|
|
node scripts/inline.js root $(DATA) $(DATA)/crash.html $(DATA)/crash.html
|
2021-06-11 22:39:38 +00:00
|
|
|
rm $(DATA)/bundle.css
|
2021-01-23 18:53:14 +00:00
|
|
|
|
2021-12-30 00:49:43 +00:00
|
|
|
variants-html:
|
|
|
|
$(info copying html)
|
|
|
|
cp -r html $(DATA)/
|
|
|
|
$(info adding dark variants to html)
|
2021-12-30 23:52:53 +00:00
|
|
|
node scripts/missing-colors.js html $(DATA)/html
|
2021-12-30 00:49:43 +00:00
|
|
|
|
2021-01-23 18:53:14 +00:00
|
|
|
copy:
|
2021-12-30 00:49:43 +00:00
|
|
|
$(info copying crash page)
|
2021-06-11 20:56:53 +00:00
|
|
|
mv $(DATA)/crash.html $(DATA)/html/
|
2021-01-05 18:16:23 +00:00
|
|
|
$(info copying static data)
|
2022-01-30 18:03:21 +00:00
|
|
|
mkdir -p $(DATA)/web
|
2021-04-01 13:22:11 +00:00
|
|
|
cp -r static/* $(DATA)/web/
|
2021-04-24 17:54:31 +00:00
|
|
|
$(info copying systemd service)
|
|
|
|
cp jfa-go.service $(DATA)/
|
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)/
|
2022-01-08 16:42:36 +00:00
|
|
|
mv $(DATA)/web/css/bundle.css $(DATA)/web/css/$(CSSVERSION)bundle.css
|
2021-04-01 13:22:11 +00:00
|
|
|
|
|
|
|
# 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 docs/docs.go docs/swagger.json docs/swagger.yaml
|
|
|
|
go clean
|
|
|
|
|
2023-06-21 10:05:38 +00:00
|
|
|
quick: configuration typescript variants-html bundle-css inline-css copy compile
|
|
|
|
|
2022-01-26 14:26:10 +00:00
|
|
|
all: configuration npm email typescript variants-html bundle-css inline-css swagger copy compile
|