This commit is contained in:
Your Name 2025-05-26 21:52:09 +12:00
parent 6ed7e7004a
commit 7799e50188
8 changed files with 22 additions and 105 deletions

View File

@ -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

View File

@ -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

View File

@ -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 .

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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