mirror of
https://github.com/fatedier/frp.git
synced 2026-03-08 02:49:10 +08:00
build: add noweb tag to allow building without frontend assets (#5189)
This commit is contained in:
21
Makefile
21
Makefile
@@ -1,6 +1,7 @@
|
|||||||
export PATH := $(PATH):`go env GOPATH`/bin
|
export PATH := $(PATH):`go env GOPATH`/bin
|
||||||
export GO111MODULE=on
|
export GO111MODULE=on
|
||||||
LDFLAGS := -s -w
|
LDFLAGS := -s -w
|
||||||
|
NOWEB_TAG = $(shell [ ! -d web/frps/dist ] || [ ! -d web/frpc/dist ] && echo ',noweb')
|
||||||
|
|
||||||
.PHONY: web frps-web frpc-web frps frpc
|
.PHONY: web frps-web frpc-web frps frpc
|
||||||
|
|
||||||
@@ -28,23 +29,23 @@ fmt-more:
|
|||||||
gci:
|
gci:
|
||||||
gci write -s standard -s default -s "prefix(github.com/fatedier/frp/)" ./
|
gci write -s standard -s default -s "prefix(github.com/fatedier/frp/)" ./
|
||||||
|
|
||||||
vet: web
|
vet:
|
||||||
go vet ./...
|
go vet -tags "$(NOWEB_TAG)" ./...
|
||||||
|
|
||||||
frps:
|
frps:
|
||||||
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -tags frps -o bin/frps ./cmd/frps
|
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -tags "frps$(NOWEB_TAG)" -o bin/frps ./cmd/frps
|
||||||
|
|
||||||
frpc:
|
frpc:
|
||||||
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -tags frpc -o bin/frpc ./cmd/frpc
|
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -tags "frpc$(NOWEB_TAG)" -o bin/frpc ./cmd/frpc
|
||||||
|
|
||||||
test: gotest
|
test: gotest
|
||||||
|
|
||||||
gotest: web
|
gotest:
|
||||||
go test -v --cover ./assets/...
|
go test -tags "$(NOWEB_TAG)" -v --cover ./assets/...
|
||||||
go test -v --cover ./cmd/...
|
go test -tags "$(NOWEB_TAG)" -v --cover ./cmd/...
|
||||||
go test -v --cover ./client/...
|
go test -tags "$(NOWEB_TAG)" -v --cover ./client/...
|
||||||
go test -v --cover ./server/...
|
go test -tags "$(NOWEB_TAG)" -v --cover ./server/...
|
||||||
go test -v --cover ./pkg/...
|
go test -tags "$(NOWEB_TAG)" -v --cover ./pkg/...
|
||||||
|
|
||||||
e2e:
|
e2e:
|
||||||
./hack/run-e2e.sh
|
./hack/run-e2e.sh
|
||||||
|
|||||||
@@ -5,3 +5,4 @@
|
|||||||
## Improvements
|
## Improvements
|
||||||
|
|
||||||
* Kept proxy/visitor names as raw config names during completion; moved user-prefix handling to explicit wire-level naming logic.
|
* Kept proxy/visitor names as raw config names during completion; moved user-prefix handling to explicit wire-level naming logic.
|
||||||
|
* Added `noweb` build tag to allow compiling without frontend assets. `make build` now auto-detects missing `web/*/dist` directories and skips embedding, so a fresh clone can build without running `make web` first. The dashboard gracefully returns 404 when assets are not embedded.
|
||||||
|
|||||||
@@ -29,14 +29,23 @@ var (
|
|||||||
prefixPath string
|
prefixPath string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type emptyFS struct{}
|
||||||
|
|
||||||
|
func (emptyFS) Open(name string) (http.File, error) {
|
||||||
|
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
|
||||||
|
}
|
||||||
|
|
||||||
// if path is empty, load assets in memory
|
// if path is empty, load assets in memory
|
||||||
// or set FileSystem using disk files
|
// or set FileSystem using disk files
|
||||||
func Load(path string) {
|
func Load(path string) {
|
||||||
prefixPath = path
|
prefixPath = path
|
||||||
if prefixPath != "" {
|
switch {
|
||||||
|
case prefixPath != "":
|
||||||
FileSystem = http.Dir(prefixPath)
|
FileSystem = http.Dir(prefixPath)
|
||||||
} else {
|
case content != nil:
|
||||||
FileSystem = http.FS(content)
|
FileSystem = http.FS(content)
|
||||||
|
default:
|
||||||
|
FileSystem = emptyFS{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
var version = "0.67.0"
|
var version = "0.68.0"
|
||||||
|
|
||||||
func Full() string {
|
func Full() string {
|
||||||
return version
|
return version
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build !noweb
|
||||||
|
|
||||||
package frpc
|
package frpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
3
web/frpc/embed_stub.go
Normal file
3
web/frpc/embed_stub.go
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
//go:build noweb
|
||||||
|
|
||||||
|
package frpc
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build !noweb
|
||||||
|
|
||||||
package frps
|
package frps
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
3
web/frps/embed_stub.go
Normal file
3
web/frps/embed_stub.go
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
//go:build noweb
|
||||||
|
|
||||||
|
package frps
|
||||||
Reference in New Issue
Block a user