refactor: separate local build and field dist targets
- Separate local binary build (make build) from field bundle dist (make dist) - make build now uses direct go build for local development only - make dist handles cross-platform field binaries with checksums and manifests - Remove LOCAL_BIN_DIR sync logic from field-binaries.sh - Update edge-local-dev-guide.md to reflect new build workflow
This commit is contained in:
parent
86311b2d54
commit
329576345d
3 changed files with 26 additions and 38 deletions
22
Makefile
22
Makefile
|
|
@ -1,19 +1,29 @@
|
|||
.PHONY: all build build-edge build-node tidy test test-e2e test-openai-ollama proto proto-dart portal-test portal-build-web clean
|
||||
.PHONY: all build build-edge build-node dist dist-edge dist-node tidy test test-e2e test-openai-ollama proto proto-dart portal-test portal-build-web clean
|
||||
|
||||
GOFLAGS ?= -trimpath
|
||||
BUILD_APPS ?= edge node
|
||||
LOCAL_BIN_DIR ?= bin
|
||||
BUILD_DIR ?= bin
|
||||
DIST_APPS ?= edge node
|
||||
|
||||
all: build
|
||||
|
||||
build:
|
||||
APPS="$(BUILD_APPS)" LOCAL_BIN_DIR="$(LOCAL_BIN_DIR)" GOFLAGS="$(GOFLAGS)" bin/build/field-binaries.sh
|
||||
go build $(GOFLAGS) -o $(BUILD_DIR)/iop-edge ./apps/edge/cmd/edge
|
||||
go build $(GOFLAGS) -o $(BUILD_DIR)/iop-node ./apps/node/cmd/node
|
||||
|
||||
build-edge:
|
||||
$(MAKE) build BUILD_APPS=edge
|
||||
go build $(GOFLAGS) -o $(BUILD_DIR)/iop-edge ./apps/edge/cmd/edge
|
||||
|
||||
build-node:
|
||||
$(MAKE) build BUILD_APPS=node
|
||||
go build $(GOFLAGS) -o $(BUILD_DIR)/iop-node ./apps/node/cmd/node
|
||||
|
||||
dist:
|
||||
APPS="$(DIST_APPS)" GOFLAGS="$(GOFLAGS)" bin/build/field-binaries.sh
|
||||
|
||||
dist-edge:
|
||||
$(MAKE) dist DIST_APPS=edge
|
||||
|
||||
dist-node:
|
||||
$(MAKE) dist DIST_APPS=node
|
||||
|
||||
tidy:
|
||||
go mod tidy
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|||
DIST_DIR="${DIST_DIR:-"$ROOT_DIR/dist/field"}"
|
||||
TARGETS="${TARGETS:-}"
|
||||
APPS="${APPS:-"edge node"}"
|
||||
LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-}"
|
||||
CGO_ENABLED="${CGO_ENABLED:-0}"
|
||||
GOFLAGS="${GOFLAGS:-"-trimpath"}"
|
||||
|
||||
|
|
@ -14,9 +13,9 @@ if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
|||
Build field-deployable IOP edge/node binaries.
|
||||
|
||||
Usage:
|
||||
make build
|
||||
make build-edge
|
||||
make build-node
|
||||
make dist
|
||||
make dist-edge
|
||||
make dist-node
|
||||
|
||||
This script is the build engine behind the Makefile targets.
|
||||
|
||||
|
|
@ -24,7 +23,6 @@ Environment:
|
|||
APPS="edge node" apps to build
|
||||
TARGETS="linux/amd64 linux/arm64" GOOS/GOARCH target list
|
||||
DIST_DIR=dist/field output directory
|
||||
LOCAL_BIN_DIR=bin copy host-target binaries for local use
|
||||
VERSION=<value> release version label
|
||||
COMMIT=<value> commit label
|
||||
BUILD_DATE=<value> build date label
|
||||
|
|
@ -46,11 +44,6 @@ LDFLAGS="${LDFLAGS:-"-s -w"}"
|
|||
if [[ -z "$TARGETS" ]]; then
|
||||
TARGETS="$(go env GOOS)/$(go env GOARCH)"
|
||||
fi
|
||||
HOST_TARGET="$(go env GOOS)/$(go env GOARCH)"
|
||||
|
||||
if [[ -n "$LOCAL_BIN_DIR" && "$LOCAL_BIN_DIR" != /* ]]; then
|
||||
LOCAL_BIN_DIR="$ROOT_DIR/$LOCAL_BIN_DIR"
|
||||
fi
|
||||
|
||||
checksum() {
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
|
|
@ -174,21 +167,6 @@ EOF
|
|||
chmod +x "$script"
|
||||
}
|
||||
|
||||
sync_local_bin() {
|
||||
local app="$1"
|
||||
local goos="$2"
|
||||
local goarch="$3"
|
||||
local output_dir="$DIST_DIR/$VERSION/$goos-$goarch"
|
||||
|
||||
if [[ -z "$LOCAL_BIN_DIR" || "$goos/$goarch" != "$HOST_TARGET" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
mkdir -p "$LOCAL_BIN_DIR"
|
||||
cp "$output_dir/iop-$app" "$LOCAL_BIN_DIR/iop-$app"
|
||||
chmod +x "$LOCAL_BIN_DIR/iop-$app"
|
||||
}
|
||||
|
||||
for target in $TARGETS; do
|
||||
IFS=/ read -r goos goarch extra <<< "$target"
|
||||
if [[ -z "${goos:-}" || -z "${goarch:-}" || -n "${extra:-}" ]]; then
|
||||
|
|
@ -200,7 +178,6 @@ for target in $TARGETS; do
|
|||
case "$app" in
|
||||
edge|node)
|
||||
build_one "$app" "$goos" "$goarch"
|
||||
sync_local_bin "$app" "$goos" "$goarch"
|
||||
;;
|
||||
*)
|
||||
echo "unsupported app '$app'; expected edge or node" >&2
|
||||
|
|
@ -234,6 +211,3 @@ for target in $TARGETS; do
|
|||
done
|
||||
|
||||
echo "field binaries written to $DIST_DIR/$VERSION"
|
||||
if [[ -n "$LOCAL_BIN_DIR" ]]; then
|
||||
echo "local host binaries synced to $LOCAL_BIN_DIR"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
## 1. 빌드
|
||||
|
||||
공식 빌드 진입점은 `make build` 하나로 둔다.
|
||||
이 명령은 Edge와 Node를 함께 빌드하고, 현재 host에서 바로 쓸 수 있는 바이너리를 `bin/`에 맞춰 둔다.
|
||||
이 명령은 Edge와 Node를 함께 빌드하고, 현재 host에서 바로 쓸 수 있는 바이너리만 `bin/`에 맞춰 둔다.
|
||||
|
||||
```bash
|
||||
make build
|
||||
|
|
@ -31,8 +31,12 @@ make build-node
|
|||
```text
|
||||
bin/iop-edge
|
||||
bin/iop-node
|
||||
dist/field/<version>/<goos>-<goarch>/iop-edge
|
||||
dist/field/<version>/<goos>-<goarch>/iop-node
|
||||
```
|
||||
|
||||
checksum, manifest, bootstrap script까지 포함한 field bundle이 필요할 때만 별도로 만든다.
|
||||
|
||||
```bash
|
||||
make dist
|
||||
```
|
||||
|
||||
## 2. Bundle 디렉터리 준비
|
||||
|
|
|
|||
Loading…
Reference in a new issue