diff --git a/scripts/docker/Dockerfile.generic b/scripts/docker/Dockerfile.generic index 1865a51..68657e0 100644 --- a/scripts/docker/Dockerfile.generic +++ b/scripts/docker/Dockerfile.generic @@ -1,9 +1,9 @@ # Example usage: # Build: -# docker buildx build --platform linux/amd64 -f scripts/docker/Dockerfile.generic -t nntbn:generic . --load +# docker buildx build --platform linux/arm64 -f scripts/docker/Dockerfile.generic -t nntbn:generic . --load # Run: -# docker run --rm -it --platform linux/amd64 nntbn:generic /nn/build/tests/arch/generic/neuron -# docker run --rm -it --platform linux/amd64 nntbn:generic /nn/build/examples/arch/generic/dot_product +# docker run --rm -it --platform linux/arm64 nntbn:generic /nn/build/tests/arch/generic/neuron +# docker run --rm -it --platform linux/arm64 nntbn:generic /nn/build/examples/arch/generic/dot_product # Build FROM ubuntu:latest as build diff --git a/scripts/shell/build_artifact.sh b/scripts/shell/build_artifact.sh index f591167..9d922b1 100755 --- a/scripts/shell/build_artifact.sh +++ b/scripts/shell/build_artifact.sh @@ -7,7 +7,20 @@ ARCH="${ARCH-}" TECH="${TECH-}" ARTIFACT="${ARTIFACT-}" CC="${CC:-clang}" -CFLAGS+=(-Wall -fdiagnostics-color=always) +CFLAGS_ARRAY=(-Wall -fdiagnostics-color=always) + +# Check and add CFLAGS to CFLAGS_ARRAY +if [ -n "${CFLAGS-}" ]; then + IFS=' ' read -ra CFLAGS_PARTS <<< "$CFLAGS" + CFLAGS_ARRAY+=("${CFLAGS_PARTS[@]}") +fi + +# Check and add LDFLAGS to LDFLAGS_ARRAY +if [ -n "${LDFLAGS-}" ]; then + IFS=' ' read -ra LDFLAGS_ARRAY <<< "$LDFLAGS" +else + LDFLAGS_ARRAY=() +fi # If the ARCH environment variable is not set then if [ -z "$ARCH" ]; then @@ -21,13 +34,6 @@ if [ -z "$ARTIFACT" ] || [ "$ARTIFACT" = "examples/" ] || [ "$ARTIFACT" = "tests exit 1 fi -# If the DEFINES environment variable is set then -if declare -p DEFINES &>/dev/null; then - DEFINES_FLAGS=$(printf -- '-D%s ' "${DEFINES[@]}") -else - DEFINES_FLAGS="" -fi - # Ensure that the build directory exists mkdir -p "$(pwd)/build/$(dirname "$ARTIFACT")" @@ -46,12 +52,11 @@ for tech in "${TECHS[@]:-}"; do fi done -# set -x -$CC "${CFLAGS[@]}" \ - "$DEFINES_FLAGS" \ +#set -x +$CC "${CFLAGS_ARRAY[@]}" \ -Iinclude/ \ "${CC_PARTS[@]:-}" \ src/*.c \ "$(pwd)/$ARTIFACT"/main.c \ - -o "$(pwd)/build/$ARTIFACT" "${LDFLAGS[@]:-}" -# set +x + -o "$(pwd)/build/$ARTIFACT" "${LDFLAGS_ARRAY[@]}" +#set +x