Add makefile and vscode tasks

This commit is contained in:
2026-01-07 07:37:59 +01:00
parent 997b165890
commit 950e488190
5 changed files with 122 additions and 4 deletions

4
.gitignore vendored
View File

@@ -1,3 +1 @@
luxtools-client
*.exe
.vscode/
dist/

45
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,45 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug server (default)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"cwd": "${workspaceFolder}",
"args": [],
"console": "integratedTerminal"
},
{
"name": "Debug server (port 9000)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"cwd": "${workspaceFolder}",
"args": ["-listen", "127.0.0.1:9000"],
"console": "integratedTerminal"
},
{
"name": "Debug install (dry-run)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"cwd": "${workspaceFolder}",
"args": ["install", "-dry-run"],
"console": "integratedTerminal"
},
{
"name": "Debug uninstall (dry-run)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"cwd": "${workspaceFolder}",
"args": ["uninstall", "-dry-run"],
"console": "integratedTerminal"
}
]
}

19
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,19 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "make",
"args": ["build"],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "shared"
}
}
]
}

39
Makefile Normal file
View File

@@ -0,0 +1,39 @@
.PHONY: help build build-linux build-windows build-all clean
APP_NAME := luxtools-client
DIST_DIR := dist
NATIVE_GOOS := $(shell go env GOOS)
NATIVE_GOARCH := $(shell go env GOARCH)
NATIVE_EXT := $(if $(filter windows,$(NATIVE_GOOS)),.exe,)
# Native (current platform)
NATIVE_EXE := $(APP_NAME)$(if $(filter windows,$(OS)),.exe,)
help:
@echo "Targets:"
@echo " make build Build for current platform -> $(DIST_DIR)/$(APP_NAME)$(NATIVE_EXT) ($(NATIVE_GOOS)/$(NATIVE_GOARCH))"
@echo " make build-linux Cross-compile -> $(DIST_DIR)/$(APP_NAME)-linux-amd64"
@echo " make build-windows Cross-compile -> $(DIST_DIR)/$(APP_NAME)-windows-amd64.exe"
@echo " make build-all Build linux + windows artifacts"
@echo " make clean Remove $(DIST_DIR)/"
$(DIST_DIR):
@mkdir -p $(DIST_DIR)
build: $(DIST_DIR)
@echo "Building $(APP_NAME) for current platform..."
go build -trimpath -o $(DIST_DIR)/$(APP_NAME)$(NATIVE_EXT) .
build-linux: $(DIST_DIR)
@echo "Cross-compiling $(APP_NAME) for linux/amd64..."
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o $(DIST_DIR)/$(APP_NAME)-linux-amd64 .
build-windows: $(DIST_DIR)
@echo "Cross-compiling $(APP_NAME) for windows/amd64..."
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o $(DIST_DIR)/$(APP_NAME)-windows-amd64.exe .
build-all: build-linux build-windows
clean:
@rm -rf $(DIST_DIR)

View File

@@ -19,7 +19,24 @@ This program runs on the users machine and listens on a loopback address only
Requires Go 1.22+.
```bash
go build -o luxtools-client .
make build
```
Output:
- `dist/luxtools-client` (or `dist/luxtools-client.exe` on Windows)
### Cross-compile
```bash
# Linux (amd64)
make build-linux
# Windows (amd64)
make build-windows
# Both
make build-all
```
## Run