diff --git a/.dockerignore b/.dockerignore index 2e2d1e3b..9cd4b0d7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,8 @@ # Ignore build and test binaries. bin/ testbin/ +rpms/ +crossbin/ # Daemon executables & libraries daemons/compute/server/nnf-dm @@ -9,3 +11,10 @@ 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 +*~ diff --git a/.gitignore b/.gitignore index 210c0858..e1a85a6c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ nnf-dm .version config/begin/* rpms/ +crossbin/ # Test binary, build with `go test -c` *.test diff --git a/Makefile b/Makefile index 5aeb82cb..2b9901ea 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/daemons/lib-copy-offload/Makefile b/daemons/lib-copy-offload/Makefile index 1a5157c9..de11a666 100644 --- a/daemons/lib-copy-offload/Makefile +++ b/daemons/lib-copy-offload/Makefile @@ -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 diff --git a/daemons/lib-copy-offload/test-tool/Dockerfile.xplatform b/daemons/lib-copy-offload/test-tool/Dockerfile.xplatform new file mode 100644 index 00000000..9b94869f --- /dev/null +++ b/daemons/lib-copy-offload/test-tool/Dockerfile.xplatform @@ -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 /