scanfile/Makefile
2025-08-15 19:19:51 +02:00

76 lines
2.1 KiB
Makefile

# Build the application
all: deps build
deps: ## Install build dependencies
go mod tidy
test -d venv || python3 -m venv venv
. ./venv/bin/activate; pip install -r ./scanners/ole/requirements.txt; pip install -r ./scanners/capa/requirements.txt
build: ## Build and compile
echo "Building..."
tailwindcss -o server/web/assets/styles.css
templ generate
go build -o main.out server/main.go
run: ## Run the application
go run server/main.go
test: ## Run test
echo "Testing..."
go test ./server/internal/store -v
clean: ## Delete build artifacts
echo "Cleaning..."
rm -f main.out
rm -rf sessions/*
rm -rf storage/*
dev: ## Start templ-dev tailwind-dev and watch
make -j5 templ-dev tailwind-dev capa-dev ole-dev watch
templ-dev: ## Watch & Live rebuild of templ
templ generate --watch --proxy="http://localhost:8080" --open-browser=false
tailwind-dev: ##Live rebuild of tailwind
#tailwindcss -o server/web/assets/styles.css -i input.css --watch
npx @tailwindcss/cli -o server/web/assets/styles.css -i input.css --watch
ole-dev: ##Live rebouild of ole-scanner
. ./venv/bin/activate; \
cd ./scanners/ole; \
FILE_DIRECTORY="$(shell pwd)/storage/files" flask run -p5000
capa-dev: ##Live rebouild of ole-scanner
. ./venv/bin/activate; \
cd ./scanners/capa; \
FILE_DIRECTORY="$(shell pwd)/storage/files" flask run -p5001
# Live Reload
watch: ##Live reload with air
@if command -v air > /dev/null; then \
air; \
echo "Watching...";\
else \
read -p "Go's 'air' is not installed on your machine. Do you want to install it? [Y/n] " choice; \
if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \
go install github.com/air-verse/air@latest; \
air; \
echo "Watching...";\
else \
echo "You chose not to install air. Exiting..."; \
exit 1; \
fi; \
fi
help: ## Display this Help.
@awk 'BEGIN { \
FS = ":.*##"; \
printf "\nUsage:\n make <target>\n" \
} \
/^[a-zA-Z_-]+:.*?##/ { \
printf " %-20s %s\n", $$1, $$2 \
} \
' $(MAKEFILE_LIST)
.PHONY: all build run test clean help