diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 deleted file mode 100644 index 8d3a4fd..0000000 --- a/Dockerfile.arm64 +++ /dev/null @@ -1,7 +0,0 @@ -FROM dockcross/linux-arm64-full - -ENV DEFAULT_DOCKCROSS_IMAGE=gitea.jde.nz/public/jcross-linux-arm64-full - -RUN apt-get update && apt-get install -y \ - ccache \ - mold diff --git a/Dockerfile.x86_64 b/Dockerfile.x86_64 deleted file mode 100644 index 4d90f82..0000000 --- a/Dockerfile.x86_64 +++ /dev/null @@ -1,50 +0,0 @@ -FROM dockcross/linux-x86_64-full - -ENV DEFAULT_DOCKCROSS_IMAGE=gitea.jde.nz/public/jcross-linux-x86_64-full - -RUN apt-get update && apt-get install -y \ - ccache \ - mold \ - libcpp-httplib-dev - - -######################################## -# nlohmann/json (compiled static .a) # -######################################## -ARG JSON_VERSION=3.11.3 -RUN git clone --depth 1 --branch v${JSON_VERSION} https://github.com/nlohmann/json.git /tmp/json && \ - cmake -S /tmp/json -B /tmp/json/build \ - -DJSON_BuildTests=OFF \ - -DJSON_MultipleHeaders=OFF \ - -DBUILD_SHARED_LIBS=OFF && \ - cmake --build /tmp/json/build --config Release && \ - cmake --install /tmp/json/build - -################################## -# libassert (build static .a) # -################################## -ARG LIBASSERT_VERSION=v2.1.5 -RUN git clone --depth 1 --branch ${LIBASSERT_VERSION} https://github.com/jeremy-rifkin/libassert.git /tmp/libassert && \ - cmake -S /tmp/libassert -B /tmp/libassert/build \ - -DLIBASSERT_BUILD_TESTS=OFF \ - -DLIBASSERT_BUILD_EXAMPLES=OFF \ - -DLIBASSERT_BUILD_STATIC=ON && \ - cmake --build /tmp/libassert/build --config Release && \ - cmake --install /tmp/libassert/build - -##################### -# zlib (static .a) # -##################### -ARG ZLIB_VERSION=1.3.1 -RUN wget -q https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz && \ - tar xzf zlib-${ZLIB_VERSION}.tar.gz && \ - cd zlib-${ZLIB_VERSION} && \ - ./configure --static && \ - make -j$(nproc) && \ - make install && \ - cd .. && rm -rf zlib-${ZLIB_VERSION}* - -############################## -# Reduce size of .a archives # -############################## -RUN strip --strip-unneeded /usr/local/lib/*.a diff --git a/build.sh b/build.sh deleted file mode 100755 index 6cde55d..0000000 --- a/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e - -docker build -f Dockerfile.arm64 -t gitea.jde.nz/public/jcross-linux-arm64-full:latest . -docker build -f Dockerfile.x86_64 -t gitea.jde.nz/public/jcross-linux-x86_64-full:latest . - diff --git a/install_host_headers.sh b/install_host.sh similarity index 52% rename from install_host_headers.sh rename to install_host.sh index 0019b4c..0479217 100755 --- a/install_host_headers.sh +++ b/install_host.sh @@ -1,6 +1,6 @@ #!/bin/bash -sudo apt install -y nlohmann-json3-dev wget curl cmake ninja-build +sudo apt install -y nlohmann-json3-dev wget curl cmake ninja-build mold if [ ! -f /usr/local/lib/libassert.a ]; then git clone https://github.com/jeremy-rifkin/libassert.git @@ -18,3 +18,19 @@ if [ ! -f /usr/local/include/httplib.h ]; then sudo wget -q https://raw.githubusercontent.com/yhirose/cpp-httplib/master/httplib.h \ -O /usr/local/include/httplib.h fi + + +# install zig +if [ ! -f ${HOME}/.local/bin/zig ]; then + mkdir -p temp + rm -rf ${HOME}/.zig + mkdir -p ${HOME}/.zig + wget https://ziglang.org/builds/zig-x86_64-linux-0.15.0-dev.643+dc6ffc28b.tar.xz -O temp/zig.tar.xz + tar -xf temp/zig.tar.xz -C temp + mv temp/zig-x86_64-linux-0.15.0-dev.643+dc6ffc28b/zig ${HOME}/.zig/zig + mv temp/zig-x86_64-linux-0.15.0-dev.643+dc6ffc28b/lib ${HOME}/.zig/ + ln -s ${HOME}/.zig/zig ${HOME}/.local/bin/zig + rm -rf temp + zig version +fi + diff --git a/install_toolchain.sh b/install_toolchain.sh deleted file mode 100755 index 58aeac5..0000000 --- a/install_toolchain.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -targets=( - "linux-x86_64-full" - "linux-arm64-full" -) - -for target in ${targets[@]}; do - docker pull gitea.jde.nz/public/jcross-$target -done - -BIN_DIR=${HOME}/.local/bin - -mkdir -p ${BIN_DIR} - -for target in ${targets[@]}; do - docker run gitea.jde.nz/public/jcross-$target > ${BIN_DIR}/dockcross-$target && chmod u+x ${BIN_DIR}/dockcross-$target - - echo "Installed ${BIN_DIR}/dockcross-$target" -done - - diff --git a/notes.txt b/notes.txt deleted file mode 100644 index d59b7f2..0000000 --- a/notes.txt +++ /dev/null @@ -1,7 +0,0 @@ -This dockerfile is designed to allow c++ programs to be statically built using dockcross, -natively for x86_64 and cross-compiling for arm64 linux architectures (for raspberry pi's and quest 3 headsets), and link statically to these libraries built in the docker container: -- nlohmann/json https://github.com/nlohmann/json -- libassert from https://github.com/jeremy-rifkin/libassert - -plus has the header for httplib ( https://github.com/yhirose/cpp-httplib ) in /usr/local/include. - diff --git a/publish.sh b/publish.sh deleted file mode 100755 index ba79b8c..0000000 --- a/publish.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -docker push gitea.jde.nz/public/jcross-linux-arm64-full:latest -docker push gitea.jde.nz/public/jcross-linux-x86_64-full:latest diff --git a/test/build.sh b/test/build.sh index 9b0a3a1..1c8304f 100755 --- a/test/build.sh +++ b/test/build.sh @@ -28,7 +28,6 @@ function build() { WORKDIR="$SCRIPT_DIR/build/${ARCH}" mkdir -p "$OUTDIR" mkdir -p "$WORKDIR" - mkdir -p "$WORKDIR/.ccache" echo "WORKDIR: $WORKDIR" echo "OUTDIR: $OUTDIR" @@ -40,14 +39,13 @@ function build() { *) echo "Unsupported architecture $ARCH"; exit 1;; esac - export CC="ccache gcc" - export CXX="ccache g++" + export CC="zig cc" + export CXX="zig c++" export LD="mold" - export CCACHE_DIR=${WORKDIR}/.ccache - cd $SCRIPT_DIR - $DOCKCROSS bash -c "cmake -B./build/${ARCH} . -GNinja" - $DOCKCROSS bash -c "ninja -j$(nproc) -C./build/${ARCH}" + cd $WORKDIR + cmake -B${WORKDIR} ${SCRIPT_DIR} + make -j$(nproc) -C${WORKDIR} cp "${WORKDIR}/$PROJECT" "${OUTDIR}/$PROJECT.$ARCH" # Run the executable if it exists