|
| 1 | +# LLM-FireSandbox Makefile |
| 2 | +# Build automation for host-agent, guest-runner, vsock-proxy and infra.operator |
| 3 | + |
| 4 | +.PHONY: all build clean test help |
| 5 | +.PHONY: build-host-agent build-guest-runner build-proxy build-cli |
| 6 | +.PHONY: build-guest-runner-amd64 build-guest-runner-arm64 |
| 7 | + |
| 8 | +# Directories |
| 9 | +BIN_DIR := bin |
| 10 | +ROOTFS_DIR := rootfs |
| 11 | + |
| 12 | +# Go build flags |
| 13 | +GO := go |
| 14 | +GOFLAGS := -ldflags="-s -w" |
| 15 | + |
| 16 | +# Architecture detection |
| 17 | +ARCH := $(shell uname -m) |
| 18 | +ifeq ($(ARCH),x86_64) |
| 19 | + GUEST_GOARCH := amd64 |
| 20 | +else ifeq ($(ARCH),aarch64) |
| 21 | + GUEST_GOARCH := arm64 |
| 22 | +else ifeq ($(ARCH),arm64) |
| 23 | + GUEST_GOARCH := arm64 |
| 24 | +else |
| 25 | + GUEST_GOARCH := amd64 |
| 26 | +endif |
| 27 | + |
| 28 | +# Default target |
| 29 | +all: build |
| 30 | + |
| 31 | +# Help |
| 32 | +help: |
| 33 | + @echo "LLM-FireSandbox Build System" |
| 34 | + @echo "" |
| 35 | + @echo "Usage: make [target]" |
| 36 | + @echo "" |
| 37 | + @echo "Targets:" |
| 38 | + @echo " all Build all components" |
| 39 | + @echo " build Build all components" |
| 40 | + @echo " build-host-agent Build host-agent for current OS" |
| 41 | + @echo " build-guest-runner Build guest-runner for detected guest arch ($(GUEST_GOARCH))" |
| 42 | + @echo " build-guest-runner-amd64 Build guest-runner for x86_64" |
| 43 | + @echo " build-guest-runner-arm64 Build guest-runner for ARM64" |
| 44 | + @echo " build-proxy Build vsock-proxy" |
| 45 | + @echo " build-cli Build infra.operator CLI" |
| 46 | + @echo " build-cli-linux Build infra.operator CLI for Linux" |
| 47 | + @echo " clean Remove built binaries" |
| 48 | + @echo " test Run tests" |
| 49 | + @echo " deps Download Go dependencies" |
| 50 | + @echo "" |
| 51 | + @echo "infra.operator CLI commands:" |
| 52 | + @echo " infra.operator rootfs create --lang python" |
| 53 | + @echo " infra.operator snapshot create --lang python" |
| 54 | + @echo " infra.operator run --lang python --code 'print(1)'" |
| 55 | + @echo " infra.operator api --port 8080" |
| 56 | + @echo " infra.operator benchmark --all" |
| 57 | + @echo "" |
| 58 | + @echo "Detected guest architecture: $(GUEST_GOARCH)" |
| 59 | + |
| 60 | +# Create directories |
| 61 | +$(BIN_DIR): |
| 62 | + mkdir -p $(BIN_DIR) |
| 63 | + |
| 64 | +$(ROOTFS_DIR): |
| 65 | + mkdir -p $(ROOTFS_DIR) |
| 66 | + |
| 67 | +# Build all |
| 68 | +build: $(BIN_DIR) $(ROOTFS_DIR) build-host-agent build-guest-runner build-proxy build-cli |
| 69 | + @echo "Build complete!" |
| 70 | + @echo "" |
| 71 | + @echo "Binaries:" |
| 72 | + @ls -la $(BIN_DIR)/ |
| 73 | + @echo "" |
| 74 | + @echo "Guest runner (for rootfs):" |
| 75 | + @ls -la $(ROOTFS_DIR)/guest-runner 2>/dev/null || echo " Not built yet" |
| 76 | + |
| 77 | +# Build infra.operator CLI |
| 78 | +build-cli: $(BIN_DIR) |
| 79 | + @echo "Building infra.operator CLI..." |
| 80 | + $(GO) build $(GOFLAGS) -o $(BIN_DIR)/infra.operator ./cmd/infra.operator |
| 81 | + @echo "Built: $(BIN_DIR)/infra.operator" |
| 82 | + |
| 83 | +# Build infra.operator for Linux (for deployment) |
| 84 | +build-cli-linux: $(BIN_DIR) |
| 85 | + @echo "Building infra.operator CLI for Linux/amd64..." |
| 86 | + GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) -o $(BIN_DIR)/infra.operator-linux-amd64 ./cmd/infra.operator |
| 87 | + @echo "Built: $(BIN_DIR)/infra.operator-linux-amd64" |
| 88 | + |
| 89 | +# Build host-agent (runs on host) |
| 90 | +build-host-agent: $(BIN_DIR) |
| 91 | + @echo "Building host-agent..." |
| 92 | + cd host-agent && $(GO) build $(GOFLAGS) -o ../$(BIN_DIR)/host-agent . |
| 93 | + @echo "Built: $(BIN_DIR)/host-agent" |
| 94 | + |
| 95 | +# Build guest-runner for detected architecture |
| 96 | +build-guest-runner: $(ROOTFS_DIR) |
| 97 | + @echo "Building guest-runner for Linux/$(GUEST_GOARCH)..." |
| 98 | + cd guest-runner && GOOS=linux GOARCH=$(GUEST_GOARCH) $(GO) build $(GOFLAGS) -o ../$(ROOTFS_DIR)/guest-runner . |
| 99 | + @echo "Built: $(ROOTFS_DIR)/guest-runner ($(GUEST_GOARCH))" |
| 100 | + |
| 101 | +# Build guest-runner for x86_64 |
| 102 | +build-guest-runner-amd64: $(ROOTFS_DIR) |
| 103 | + @echo "Building guest-runner for Linux/amd64..." |
| 104 | + cd guest-runner && GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) -o ../$(ROOTFS_DIR)/guest-runner-amd64 . |
| 105 | + @echo "Built: $(ROOTFS_DIR)/guest-runner-amd64" |
| 106 | + |
| 107 | +# Build guest-runner for ARM64 |
| 108 | +build-guest-runner-arm64: $(ROOTFS_DIR) |
| 109 | + @echo "Building guest-runner for Linux/arm64..." |
| 110 | + cd guest-runner && GOOS=linux GOARCH=arm64 $(GO) build $(GOFLAGS) -o ../$(ROOTFS_DIR)/guest-runner-arm64 . |
| 111 | + @echo "Built: $(ROOTFS_DIR)/guest-runner-arm64" |
| 112 | + |
| 113 | +# Build vsock-proxy |
| 114 | +build-proxy: $(BIN_DIR) |
| 115 | + @echo "Building vsock-proxy..." |
| 116 | + cd proxy && $(GO) build $(GOFLAGS) -o ../$(BIN_DIR)/vsock-proxy . |
| 117 | + @echo "Built: $(BIN_DIR)/vsock-proxy" |
| 118 | + |
| 119 | +# Download dependencies |
| 120 | +deps: |
| 121 | + @echo "Downloading dependencies..." |
| 122 | + cd host-agent && $(GO) mod download |
| 123 | + cd guest-runner && $(GO) mod download |
| 124 | + cd proxy && $(GO) mod download |
| 125 | + @echo "Dependencies downloaded" |
| 126 | + |
| 127 | +# Run tests |
| 128 | +test: |
| 129 | + @echo "Running tests..." |
| 130 | + cd host-agent && $(GO) test -v ./... |
| 131 | + cd guest-runner && $(GO) test -v ./... |
| 132 | + cd proxy && $(GO) test -v ./... |
| 133 | + |
| 134 | +# Clean |
| 135 | +clean: |
| 136 | + @echo "Cleaning..." |
| 137 | + rm -rf $(BIN_DIR) |
| 138 | + rm -f $(ROOTFS_DIR)/guest-runner |
| 139 | + rm -f $(ROOTFS_DIR)/guest-runner-amd64 |
| 140 | + rm -f $(ROOTFS_DIR)/guest-runner-arm64 |
| 141 | + @echo "Cleaned" |
| 142 | + |
| 143 | +# Tidy go modules |
| 144 | +tidy: |
| 145 | + cd host-agent && $(GO) mod tidy |
| 146 | + cd guest-runner && $(GO) mod tidy |
| 147 | + cd proxy && $(GO) mod tidy |
0 commit comments