github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/Makefile (about) 1 # This trick allow us to source the environment variables defined in .env file in the Makefile 2 # (see include directive in GNU make for more details). 3 # It ignores errors in case the .env file does not exists. 4 # It may be necessary to skip variables that uses special makefile caracters, like $. 5 -include .env 6 7 OS := $(shell echo $(shell uname -s) | tr A-Z a-z) 8 ARCH := $(shell uname -m) 9 protopatch := patch/go.proto 10 protopatch-original := $(shell go list -m -f {{.Dir}} github.com/alta/protopatch)/$(protopatch) 11 toolsdir := bin 12 tool-pkgs := $(shell go list -e -f '{{join .Imports " "}}' tools.go) 13 tool-cmds := $(foreach tool,$(notdir ${tool-pkgs}),${toolsdir}/${tool}) $(foreach cmd,${tool-cmds},$(eval $(notdir ${cmd})Cmd := ${cmd})) 14 export PATH := $(shell pwd)/$(toolsdir):$(PATH) 15 16 # necessary when target is not tied to a specific file 17 .PHONY: download tools brew version-check install ui proto test qcm scm 18 19 download: 20 @echo "Download go.mod dependencies" 21 @go mod download 22 23 go.mod: tools.go 24 go mod tidy 25 touch go.mod 26 27 ${tool-cmds}: go.mod 28 go build -o $@ $(filter %/$(@F),${tool-pkgs}) 29 30 tools: ${tool-cmds} 31 32 brew: 33 ifeq (, $(shell which brew)) 34 $(error "No brew command in $(PATH)") 35 endif 36 @echo "Installing homebrew packages needed for development and deployment" 37 @brew install gh go protobuf node docker clang-format golangci-lint bufbuild/buf/buf grpcurl 38 39 version-check: 40 @go run cmd/vercheck/main.go 41 42 install: 43 @echo go install 44 @go install 45 ifeq ($(OS),linux) 46 @echo "Setting priviledged ports capabilities for quickfeed" 47 @sudo setcap 'cap_net_bind_service=+ep' `which quickfeed` 48 endif 49 50 ui: version-check 51 @echo "Running npm ci and webpack" 52 @cd public; npm ci; webpack 53 54 ui-update: version-check 55 @echo "Running npm install and webpack" 56 @cd public; npm i; webpack 57 58 $(protopatch): $(protopatch-original) 59 @echo "Copying $(protopatch-original) to $(protopatch)" 60 @cp -f $(protopatch-original) $(protopatch) 61 62 proto: $(protopatch) 63 buf generate --template buf.gen.ui.yaml --exclude-path patch 64 buf generate --template buf.gen.yaml 65 66 proto-swift: 67 buf generate --template buf.gen.swift.yaml --exclude-path patch 68 69 test: 70 @go clean -testcache 71 @go test ./... 72 73 webpack-dev-server: 74 @cd public && npx webpack-dev-server --config webpack.config.js --port 8082 --progress --mode development 75 76 # TODO Should check that webpack-dev-server is running. 77 selenium: 78 @cd public && npm run test:selenium 79 80 qcm: 81 @cd cmd/qcm; go install 82 83 scm: 84 @echo "Compiling the scm tool" 85 @cd cmd/scm; go install