use build constraints for embed, clean up makefile
internal-files/external-files and compile-debug are gone, the environment variables INTERNAL=on/off and DEBUG=on/off replace them.
This commit is contained in:
@@ -11,11 +11,27 @@ VERSION := $(shell echo $(VERSION) | sed 's/v//g')
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD || echo unknown)
|
||||
|
||||
UPDATER ?= off
|
||||
BUILDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT)
|
||||
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT)
|
||||
ifeq ($(UPDATER), on)
|
||||
BUILDFLAGS := $(BUILDFLAGS) -X main.updater=binary
|
||||
LDFLAGS := $(LDFLAGS) -X main.updater=binary
|
||||
else ifneq ($(UPDATER), off)
|
||||
BUILDFLAGS := $(BUILDFLAGS) -X main.updater=$(UPDATER)
|
||||
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
|
||||
endif
|
||||
|
||||
npm:
|
||||
@@ -29,33 +45,33 @@ npm:
|
||||
|
||||
configuration:
|
||||
$(info Fixing config-base)
|
||||
-mkdir -p data
|
||||
python3 scripts/enumerate_config.py -i config/config-base.json -o data/config-base.json
|
||||
-mkdir -p $(DATA)
|
||||
python3 scripts/enumerate_config.py -i config/config-base.json -o $(DATA)/config-base.json
|
||||
$(info Generating config-default.ini)
|
||||
python3 scripts/generate_ini.py -i config/config-base.json -o data/config-default.ini
|
||||
python3 scripts/generate_ini.py -i config/config-base.json -o $(DATA)/config-default.ini
|
||||
|
||||
email:
|
||||
$(info Generating email html)
|
||||
python3 scripts/compile_mjml.py -o data/
|
||||
python3 scripts/compile_mjml.py -o $(DATA)/
|
||||
|
||||
typescript:
|
||||
$(info compiling typescript)
|
||||
-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
|
||||
-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
|
||||
|
||||
ts-debug:
|
||||
$(info compiling typescript w/ sourcemaps)
|
||||
-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
|
||||
-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
|
||||
$(info copying typescript)
|
||||
cp -r ts data/web/js
|
||||
cp -r ts $(DATA)/web/js
|
||||
|
||||
swagger:
|
||||
$(GOBINARY) get github.com/swaggo/swag/cmd/swag
|
||||
@@ -66,47 +82,47 @@ compile:
|
||||
$(GOBINARY) mod download
|
||||
$(info Building)
|
||||
mkdir -p build
|
||||
cd build && CGO_ENABLED=0 $(GOBINARY) build -ldflags="-s -w $(BUILDFLAGS)" -o ./jfa-go ../*.go
|
||||
|
||||
compile-debug:
|
||||
$(info Downloading deps)
|
||||
$(GOBINARY) mod download
|
||||
$(info Building)
|
||||
mkdir -p build
|
||||
cd build && CGO_ENABLED=0 $(GOBINARY) build -ldflags "$(BUILDFLAGS)" -o ./jfa-go ../*.go
|
||||
# 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
|
||||
|
||||
compress:
|
||||
upx --lzma build/jfa-go
|
||||
|
||||
bundle-css:
|
||||
-mkdir -p data/web/css
|
||||
-mkdir -p $(DATA)/web/css
|
||||
$(info bundling css)
|
||||
$(ESBUILD) --bundle css/base.css --outfile=data/web/css/bundle.css --external:remixicon.css --minify
|
||||
$(ESBUILD) --bundle css/base.css --outfile=$(DATA)/web/css/bundle.css --external:remixicon.css --minify
|
||||
|
||||
copy:
|
||||
$(info copying fonts)
|
||||
cp -r node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 data/web/css/
|
||||
cp -r node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 $(DATA)/web/css/
|
||||
$(info copying html)
|
||||
cp -r html data/
|
||||
cp -r html $(DATA)/
|
||||
$(info copying static data)
|
||||
-mkdir -p data/web
|
||||
cp -r static/* data/web/
|
||||
-mkdir -p $(DATA)/web
|
||||
cp -r static/* $(DATA)/web/
|
||||
$(info copying language files)
|
||||
cp -r lang data/
|
||||
cp LICENSE data/
|
||||
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/
|
||||
# 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/
|
||||
|
||||
install:
|
||||
cp -r build $(DESTDIR)/jfa-go
|
||||
|
||||
all: configuration npm email typescript bundle-css swagger copy internal-files compile
|
||||
all-external: configuration npm email typescript bundle-css swagger copy external-files compile
|
||||
debug: configuration npm email ts-debug bundle-css swagger copy external-files compile-debug
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user