Add makefile and vscode tasks
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1 @@
|
|||||||
luxtools-client
|
dist/
|
||||||
*.exe
|
|
||||||
.vscode/
|
|
||||||
45
.vscode/launch.json
vendored
Normal file
45
.vscode/launch.json
vendored
Normal 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
19
.vscode/tasks.json
vendored
Normal 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
39
Makefile
Normal 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)
|
||||||
19
README.md
19
README.md
@@ -19,7 +19,24 @@ This program runs on the user’s machine and listens on a loopback address only
|
|||||||
Requires Go 1.22+.
|
Requires Go 1.22+.
|
||||||
|
|
||||||
```bash
|
```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
|
## Run
|
||||||
|
|||||||
Reference in New Issue
Block a user