Skip to content

Commit 6a6d007

Browse files
committed
cgo cross compile, bugfix in fetch devplane proto, uncomment todos
1 parent 9fa4720 commit 6a6d007

4 files changed

Lines changed: 57 additions & 42 deletions

File tree

Makefile

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
.DEFAULT_GOAL := fast-build
22
VERSION := dev-$(shell git rev-parse HEAD | cut -c 1-8)
33

4+
# Cross-compilation via Docker (golang:1.24 native Linux container).
5+
# When arch=<GOOS>/<GOARCH> is provided, spin up a container that matches
6+
# the target platform so CGO uses the native Linux gcc/GNU ld toolchain
7+
_GOMODCACHE := $(shell go env GOMODCACHE)
8+
ifdef arch
9+
_CROSS_GOOS := $(word 1,$(subst /, ,$(arch)))
10+
_CROSS_GOARCH := $(word 2,$(subst /, ,$(arch)))
11+
_BUILD_PREFIX := docker run --rm \
12+
--platform $(_CROSS_GOOS)/$(_CROSS_GOARCH) \
13+
-v $(CURDIR):/app \
14+
-v $(_GOMODCACHE):/go/pkg/mod \
15+
-e CGO_ENABLED=1 \
16+
-e GOPRIVATE=github.com/brevdev/* \
17+
-e GONOSUMDB=github.com/brevdev/* \
18+
-w /app \
19+
golang:1.24
20+
else
21+
_BUILD_PREFIX := CGO_ENABLED=1
22+
endif
23+
424
.PHONY: fast-build
525
fast-build: ## go build -o brev
626
$(call print-target)
727
echo ${VERSION}
8-
CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
28+
CGO_ENABLED=1 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
929

1030
.PHONY: local
1131
local: ## build with env wrapper (use: make local env=dev0|dev1|dev2|stg arch=linux/amd64, or make local for defaults)
1232
$(call print-target)
1333
ifdef env
1434
@echo "Building with env=$(env) wrapper..."
1535
@echo ${VERSION}
16-
$(if $(arch),GOOS=$(word 1,$(subst /, ,$(arch))) GOARCH=$(word 2,$(subst /, ,$(arch))),) CGO_ENABLED=0 go build -o brev-local -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
36+
$(_BUILD_PREFIX) go build -o brev-local -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
1737
@echo '#!/bin/sh' > brev
1838
@echo '# Auto-generated wrapper with environment overrides' >> brev
1939
@echo 'export BREV_CONSOLE_URL="https://localhost.nvidia.com:3000"' >> brev
@@ -26,7 +46,7 @@ ifdef env
2646
@chmod +x brev
2747
else
2848
@echo "Building without environment overrides (using config.go defaults)..."
29-
$(if $(arch),GOOS=$(word 1,$(subst /, ,$(arch))) GOARCH=$(word 2,$(subst /, ,$(arch))),) CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
49+
$(_BUILD_PREFIX) go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
3050
endif
3151

3252
.PHONY: install-dev
@@ -305,8 +325,8 @@ develop-with-nix:
305325
update-devplane-deps: ## update devplane dependencies (use: make update-devplane-deps commit=<hash-or-tag>, defaults to latest)
306326
@COMMIT=$${commit:-latest}; \
307327
echo "Updating devplane dependencies to: $$COMMIT"; \
308-
go get -u github.com/brevdev/dev-plane@$$COMMIT; \
328+
GOPRIVATE=github.com/brevdev/* go get -u github.com/brevdev/dev-plane@$$COMMIT; \
309329
go get buf.build/gen/go/brevdev/devplane/grpc/go@$$COMMIT; \
310330
go get buf.build/gen/go/brevdev/devplane/protocolbuffers/go@$$COMMIT; \
311-
go mod tidy; \
331+
GOPRIVATE=github.com/brevdev/* go mod tidy; \
312332
echo "Successfully updated to $$COMMIT"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.0
44

55
require (
66
buf.build/gen/go/brevdev/devplane/connectrpc/go v1.19.1-20260228021043-887d38e1b474.2
7-
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305005117-3cacb6388cd4.1
7+
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305201249-af5106090c8a.1
88
connectrpc.com/connect v1.19.1
99
github.com/NVIDIA/go-nvml v0.13.0-1
1010
github.com/alessio/shellescape v1.4.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
buf.build/gen/go/brevdev/devplane/connectrpc/go v1.19.1-20260228021043-887d38e1b474.2 h1:Sq0kIa/xKzScbJcqB5EbPVhOL0QYHPr3araQaupL2lk=
22
buf.build/gen/go/brevdev/devplane/connectrpc/go v1.19.1-20260228021043-887d38e1b474.2/go.mod h1:Yh34p9aADmWsKv2umYlMpnCZuBmNBE9N+HImgRriJXM=
3-
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305005117-3cacb6388cd4.1 h1:3Y3FI5kbM4uacawy5dySjVTPSbu2BJMO42eQHf2wz+g=
4-
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305005117-3cacb6388cd4.1/go.mod h1:V/y7Wxg0QvU4XPVwqErF5NHLobUT1QEyfgrGuQIxdPo=
3+
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305201249-af5106090c8a.1 h1:d+kY4OSI/WV2eBuO5G7ezCQ8RiLtDOIrUbtmZOKi5Kw=
4+
buf.build/gen/go/brevdev/devplane/protocolbuffers/go v1.36.11-20260305201249-af5106090c8a.1/go.mod h1:V/y7Wxg0QvU4XPVwqErF5NHLobUT1QEyfgrGuQIxdPo=
55
buf.build/gen/go/brevdev/protoc-gen-gotag/protocolbuffers/go v1.36.11-20220906235457-8b4922735da5.1 h1:6amhprQmCKJ4wgJ6ngkh32d9V+dQcOLUZ/SfHdOnYgo=
66
buf.build/gen/go/brevdev/protoc-gen-gotag/protocolbuffers/go v1.36.11-20220906235457-8b4922735da5.1/go.mod h1:O+pnSHMru/naTMrm4tmpBoH3wz6PHa+R75HR7Mv8X2g=
77
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=

pkg/cmd/register/rpcclient.go

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ func toProtoNodeSpec(hw *HardwareProfile) *nodev1.NodeSpec {
7070
StorageBytes: st.StorageBytes,
7171
StorageType: st.StorageType,
7272
}
73-
// TODO(BRE2-801): uncomment when proto dep is updated
74-
// if st.Name != "" {
75-
// storageSpec.Device = &st.Name
76-
// }
73+
if st.Name != "" {
74+
storageSpec.Device = &st.Name
75+
}
7776
proto.Storage = append(proto.Storage, storageSpec)
7877
}
7978

@@ -87,46 +86,42 @@ func toProtoNodeSpec(hw *HardwareProfile) *nodev1.NodeSpec {
8786
proto.OsVersion = &hw.OSVersion
8887
}
8988

90-
// TODO(BRE2-801): uncomment when proto dep is updated
91-
// if hw.ProductName != "" {
92-
// proto.ProductName = &hw.ProductName
93-
// }
89+
if hw.ProductName != "" {
90+
proto.ProductName = &hw.ProductName
91+
}
9492

9593
for _, g := range hw.GPUs {
9694
pg := &nodev1.GPUSpec{
9795
Model: g.Model,
9896
Count: g.Count,
9997
MemoryBytes: g.MemoryBytes,
10098
}
101-
// TODO(BRE2-801): uncomment when proto dep is updated
102-
// if g.Architecture != "" {
103-
// pg.GpuArchitecture = &g.Architecture
104-
// }
99+
if g.Architecture != "" {
100+
pg.GpuArchitecture = &g.Architecture
101+
}
105102
proto.Gpus = append(proto.Gpus, pg)
106103
}
107104

108-
// TODO(BRE2-801): uncomment when proto dep is updated
109-
// InterconnectSpec uses oneof: NVLinkDetails or PCIeDetails
110-
// for _, ic := range hw.Interconnects {
111-
// spec := &nodev1.InterconnectSpec{Device: ic.Device}
112-
// switch ic.Type {
113-
// case "NVLink":
114-
// spec.Details = &nodev1.InterconnectSpec_Nvlink{
115-
// Nvlink: &nodev1.NVLinkDetails{
116-
// ActiveLinks: int32(ic.ActiveLinks),
117-
// Version: ic.Version,
118-
// },
119-
// }
120-
// case "PCIe":
121-
// spec.Details = &nodev1.InterconnectSpec_Pcie{
122-
// Pcie: &nodev1.PCIeDetails{
123-
// Generation: int32(ic.Generation),
124-
// Width: int32(ic.Width),
125-
// },
126-
// }
127-
// }
128-
// proto.Interconnects = append(proto.Interconnects, spec)
129-
// }
105+
for _, ic := range hw.Interconnects {
106+
spec := &nodev1.InterconnectSpec{Device: ic.Device}
107+
switch ic.Type {
108+
case "NVLink":
109+
spec.Details = &nodev1.InterconnectSpec_Nvlink{
110+
Nvlink: &nodev1.NVLinkDetails{
111+
ActiveLinks: int32(ic.ActiveLinks),
112+
Version: ic.Version,
113+
},
114+
}
115+
case "PCIe":
116+
spec.Details = &nodev1.InterconnectSpec_Pcie{
117+
Pcie: &nodev1.PCIeDetails{
118+
Generation: int32(ic.Generation),
119+
Width: int32(ic.Width),
120+
},
121+
}
122+
}
123+
proto.Interconnects = append(proto.Interconnects, spec)
124+
}
130125

131126
return proto
132127
}

0 commit comments

Comments
 (0)