@@ -111,6 +111,8 @@ WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack pub
111111BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
112112BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST ) )
113113
114+ GENERATED_GO_DEST := modules/charset/invisible_gen.go modules/charset/ambiguous_gen.go
115+
114116SVG_DEST_DIR := public/img/svg
115117
116118AIR_TMP_DIR := .air
@@ -130,9 +132,12 @@ GO_DIRS := cmd tests models modules routers build services tools
130132
131133GO_SOURCES := $(wildcard * .go)
132134GO_SOURCES += $(shell find $(GO_DIRS ) -type f -name "* .go" -not -path modules/options/bindata.go -not -path modules/public/bindata.go -not -path modules/templates/bindata.go)
135+ GO_SOURCES += $(GENERATED_GO_DEST )
136+ GO_SOURCES_NO_BINDATA := $(GO_SOURCES )
133137
134138ifeq ($(filter $(TAGS_SPLIT ) ,bindata) ,bindata)
135139 GO_SOURCES += $(BINDATA_DEST)
140+ GENERATED_GO_DEST += $(BINDATA_DEST)
136141endif
137142
138143# Force installation of playwright dependencies by setting this flag
@@ -259,7 +264,7 @@ clean:
259264fmt :
260265 @MISSPELL_PACKAGE=$(MISSPELL_PACKAGE ) GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE ) $(GO ) run build/code-batch-process.go gitea-fmt -w ' {file-list}'
261266 $(eval TEMPLATES := $(shell find templates -type f -name '* .tmpl') )
262- @# strip whitespace after '{{' and before `}}` unless there is only whitespace before it
267+ @# strip whitespace after '{{' and before `}}` unless there is only whitespace before it
263268 @$(SED_INPLACE ) -e ' s/{{[ ]\{1,\}/{{/g' -e ' /^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' $(TEMPLATES )
264269
265270.PHONY : vet
@@ -278,7 +283,9 @@ TAGS_PREREQ := $(TAGS_EVIDENCE)
278283endif
279284
280285.PHONY : generate-swagger
281- generate-swagger :
286+ generate-swagger : $(SWAGGER_SPEC )
287+
288+ $(SWAGGER_SPEC ) : $(GO_SOURCES_NO_BINDATA )
282289 $(GO ) run $(SWAGGER_PACKAGE ) generate spec -x " $( SWAGGER_EXCLUDE) " -o ' ./$(SWAGGER_SPEC)'
283290 $(SED_INPLACE ) ' $(SWAGGER_SPEC_S_TMPL)' ' ./$(SWAGGER_SPEC)'
284291 $(SED_INPLACE ) $(SWAGGER_NEWLINE_COMMAND ) ' ./$(SWAGGER_SPEC)'
@@ -398,7 +405,6 @@ unit-test-coverage:
398405tidy :
399406 $(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2) )
400407 $(GO ) mod tidy -compat=$(MIN_GO_VERSION )
401- @$(MAKE ) --no-print-directory assets/go-licenses.json
402408
403409.PHONY : vendor
404410vendor : tidy
@@ -702,16 +708,25 @@ install: $(wildcard *.go)
702708build : frontend backend
703709
704710.PHONY : frontend
705- frontend : $(WEBPACK_DEST )
711+ frontend : generate-frontend $(WEBPACK_DEST )
706712
707713.PHONY : backend
708- backend : go-check generate $(EXECUTABLE )
714+ backend : go-check generate-backend $(EXECUTABLE )
709715
716+ # We generate the backend before the frontend in case we in future we want to generate things in the frontend from generated files in backend
710717.PHONY : generate
711- generate : $(TAGS_PREREQ )
718+ generate : generate-backend generate-frontend
719+
720+ .PHONY : generate-backend
721+ generate-backend : $(TAGS_PREREQ ) generate-go
722+
723+ generate-go : $(TAGS_PREREQ )
712724 @echo " Running go generate..."
713725 @CC= GOOS= GOARCH= $(GO ) generate -tags ' $(TAGS)' $(GO_PACKAGES )
714726
727+ .PHONY : generate-frontend
728+ generate-frontend : $(TAGS_PREREQ ) go-licenses
729+
715730$(EXECUTABLE ) : $(GO_SOURCES ) $(TAGS_PREREQ )
716731 CGO_CFLAGS=" $( CGO_CFLAGS) " $(GO ) build $(GOFLAGS ) $(EXTRA_GOFLAGS ) -tags ' $(TAGS)' -ldflags ' -s -w $(LDFLAGS)' -o $@
717732
0 commit comments