diff --git a/tools/Dockerfile.build b/tools/Dockerfile.build new file mode 100644 index 0000000..4510e38 --- /dev/null +++ b/tools/Dockerfile.build @@ -0,0 +1,36 @@ +FROM debian:buster-slim + +# Buster is archived — point sources at archive.debian.org +RUN sed -i 's|deb.debian.org|archive.debian.org|g; s|security.debian.org|archive.debian.org|g; /buster-updates/d' /etc/apt/sources.list && \ + apt-get update && apt-get install -y --no-install-recommends \ + curl ca-certificates pkg-config cmake git \ + gcc libc6-dev gcc-arm-linux-gnueabi binutils-arm-linux-gnueabi libc6-dev-armel-cross \ + python3 \ + xz-utils && \ + rm -rf /var/lib/apt/lists/* + +# Node.js 20 binary (supports glibc 2.28+, has import.meta.dirname) +RUN curl -fsSL https://nodejs.org/dist/v20.18.1/node-v20.18.1-linux-x64.tar.xz | \ + tar -xJ --strip-components=1 -C /usr/local && \ + npm install -g pnpm@9 + +# Rust with ARM soft-float target +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \ + sh -s -- -y --default-toolchain stable --profile minimal && \ + . /root/.cargo/env && \ + rustup target add armv7-unknown-linux-gnueabi + +# Create a fake WEBOS_NDK that wraps the standard cross-compiler +RUN mkdir -p /opt/webos-ndk/bin && \ + ln -s /usr/bin/arm-linux-gnueabi-gcc /opt/webos-ndk/bin/arm-webos-linux-gnueabi-gcc && \ + ln -s /usr/bin/arm-linux-gnueabi-ar /opt/webos-ndk/bin/arm-webos-linux-gnueabi-ar && \ + ln -s /usr/bin/arm-linux-gnueabi-strip /opt/webos-ndk/bin/arm-webos-linux-gnueabi-strip && \ + mkdir -p /opt/webos-ndk/arm-webos-linux-gnueabi/sysroot/usr/include && \ + cp -a /usr/arm-linux-gnueabi/include/* /opt/webos-ndk/arm-webos-linux-gnueabi/sysroot/usr/include/ && \ + mkdir -p /opt/webos-ndk/arm-webos-linux-gnueabi/sysroot/usr/lib && \ + cp -a /usr/arm-linux-gnueabi/lib/* /opt/webos-ndk/arm-webos-linux-gnueabi/sysroot/usr/lib/ + +ENV WEBOS_NDK=/opt/webos-ndk +ENV PATH="/root/.cargo/bin:${PATH}" + +WORKDIR /build diff --git a/tools/build-docker.sh b/tools/build-docker.sh new file mode 100755 index 0000000..73f9f34 --- /dev/null +++ b/tools/build-docker.sh @@ -0,0 +1,46 @@ +#!/bin/bash +set -e + +CC=/usr/bin/arm-linux-gnueabi-gcc +STUBDIR=/usr/arm-linux-gnueabi/lib + +echo "=== Creating webOS stub libraries ===" + +cat > /tmp/luna-stub.c << 'STUBEOF' +typedef int gint; +typedef unsigned int guint; +typedef void* gpointer; +int LSErrorInit(void *e) { return 1; } +void LSErrorFree(void *e) {} +int LSRegister(const char *n, void **h, void *e) { return 1; } +int LSUnregister(void *h, void *e) { return 1; } +int LSGmainContextAttach(void *h, void *c, void *e) { return 1; } +int LSCallOneReply(void *h, const char *u, const char *p, void *cb, void *ud, unsigned long *t, void *e) { return 1; } +int LSCallCancel(void *h, unsigned long t, void *e) { return 1; } +const char* LSMessageGetPayload(void *m) { return "{}"; } +STUBEOF +$CC -shared -o $STUBDIR/libluna-service2.so /tmp/luna-stub.c +echo " Created libluna-service2.so stub" + +cat > /tmp/glib-stub.c << 'STUBEOF' +void* g_main_context_new(void) { return (void*)0; } +int g_main_context_iteration(void *ctx, int may_block) { return 0; } +void g_main_context_unref(void *ctx) {} +STUBEOF +$CC -shared -o $STUBDIR/libglib-2.0.so /tmp/glib-stub.c +echo " Created libglib-2.0.so stub" + +echo "=== Installing npm deps ===" +pnpm install --frozen-lockfile 2>&1 | tail -5 || true + +echo "=== Preparing SDL-webOS runtime ===" +node tools/webos-runtime.mjs 2>&1 | tail -5 + +echo "=== Building for webOS ARM ===" +sh tools/build-webos.sh 2>&1 | tail -30 + +echo "=== Build result ===" +ls -la target/armv7-unknown-linux-gnueabi/release/luma +arm-linux-gnueabi-strip target/armv7-unknown-linux-gnueabi/release/luma +ls -la target/armv7-unknown-linux-gnueabi/release/luma +echo "=== Done ==="