Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the copy-offload tester tool to be cross-compiled #249

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
# Ignore build and test binaries.
bin/
testbin/
rpms/
crossbin/

# Daemon executables & libraries
daemons/compute/server/nnf-dm
daemons/compute/client-c/client
daemons/compute/client-c/client.a
daemons/compute/server/server
daemons/compute/client-go/client-go
daemons/lib-copy-offload/**/*.[ao]
daemons/lib-copy-offload/**/tester
daemons/copy-offload-testing/certs

*.swp
*.swo
*~
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ nnf-dm
.version
config/begin/*
rpms/
crossbin/

# Test binary, build with `go test -c`
*.test
Expand Down
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ build-copy-offload-with: $(LOCALBIN)
build-copy-offload-with: fmt vet ## Build standalone copy-offload daemon
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o bin/nnf-copy-offload daemons/copy-offload/cmd/main.go

CROSS_PLATFORM ?= linux/amd64
.PHONY: build-copy-offload-tester-cross
build-copy-offload-tester-cross: $(CROSSBIN)
build-copy-offload-tester-cross: ## Build standalone tester binary for $CROSS_PLATFORM
${CONTAINER_TOOL} build --platform=$(CROSS_PLATFORM) --output=type=local,dest=$(CROSSBIN) --no-cache -f daemons/lib-copy-offload/test-tool/Dockerfile.xplatform .

.PHONY: build-copy-offload-docker-local
build-copy-offload-docker-local: GOARCH = $(shell go env GOARCH)
build-copy-offload-docker-local: build-copy-offload-docker-with
Expand Down Expand Up @@ -296,6 +302,17 @@ clean-rpmbin:
rm -rf $(RPMBIN); \
fi

## Location to place cross-compiled tools
CROSSBIN ?= $(shell pwd)/crossbin
$(CROSSBIN):
mkdir $(CROSSBIN)

.PHONY: clean-crossbin
clean-crossbin:
if [[ -d $(CROSSBIN) ]]; then \
rm -rf $(CROSSBIN); \
fi

## Tool Binaries
KUSTOMIZE_IMAGE_TAG ?= ./hack/make-kustomization2.sh
KUSTOMIZE ?= $(LOCALBIN)/kustomize
Expand Down
5 changes: 2 additions & 3 deletions daemons/lib-copy-offload/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

CC = /usr/bin/gcc
AR = /usr/bin/ar
CC ?= /usr/bin/gcc
AR ?= /usr/bin/ar
CFLAGS = -Wall -Werror -g -I/opt/homebrew/include -I/opt/homebrew/opt/curl/include
LDFLAGS = -lcurl -L/opt/homebrew/lib -L/opt/homebrew/opt/curl/lib
xLDFLAGS = -lcrypto -lcurl -L/opt/homebrew/lib -L/opt/homebrew/opt/curl/lib
ARFLAGS = rcs

all: libcopyoffload.a tester
Expand Down
28 changes: 28 additions & 0 deletions daemons/lib-copy-offload/test-tool/Dockerfile.xplatform
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 Hewlett Packard Enterprise Development LP
# Other additional copyright holders may be indicated within.
#
# The entirety of this work is licensed under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
#
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=$BUILDPLATFORM gcc:12.4.0-bookworm AS builder

WORKDIR /workspace

COPY daemons/lib-copy-offload daemons/lib-copy-offload/
COPY Makefile Makefile

RUN CC=gcc make -C ./daemons/lib-copy-offload tester

FROM scratch AS artifacts
COPY --from=builder /workspace/daemons/lib-copy-offload/tester /
Loading