docker: Build patched ninja that supports jobserver.

https://github.com/ninja-build/ninja/pull/1140

So that -jN actually uses N job slots even when using ninja.
Sadly this does not cover cargo, which is less of an issue.
This commit is contained in:
Arkadiusz Hiler 2023-07-31 21:12:30 +03:00
parent cdce0cd31a
commit 354a061c16
3 changed files with 2189 additions and 10 deletions

View File

@ -13,24 +13,28 @@ BINUTILS_VERSION = 2.40
GCC_VERSION = 10.3.0
MINGW_VERSION = 9.0.0
RUST_VERSION = 1.68.0
NINJA_VERSION = 1.11.1
SOURCES_URLBASE = https://repo.steampowered.com/proton-sdk
BINUTILS_URLBASE = $(SOURCES_URLBASE)
GCC_URLBASE = $(SOURCES_URLBASE)
MINGW_URLBASE = $(SOURCES_URLBASE)
RUST_URLBASE = $(SOURCES_URLBASE)
NINJA_URLBASE = $(SOURCES_URLBASE)
BINUTILS_SOURCE = binutils-$(BINUTILS_VERSION).tar.xz
GCC_SOURCE = gcc-$(GCC_VERSION).tar.xz
MINGW_SOURCE = mingw-w64-v$(MINGW_VERSION).tar.bz2
RUST_SOURCE_x86_64 = rust-$(RUST_VERSION)-x86_64-unknown-linux-gnu.tar.gz
RUST_SOURCE_i686 = rust-$(RUST_VERSION)-i686-unknown-linux-gnu.tar.gz
NINJA_SOURCE = ninja-build_$(NINJA_VERSION).orig.tar.gz
BINUTILS_SHA256 = 0f8a4c272d7f17f369ded10a4aca28b8e304828e95526da482b0ccc4dfc9d8e1
GCC_SHA256 = 64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344
MINGW_SHA256 = 1929b94b402f5ff4d7d37a9fe88daa9cc55515a6134805c104d1794ae22a4181
RUST_SHA256_x86_64 = 7be1acdac656d0b0b7e909e5c0d4ddf61c755c203ec26ebafbd306322335b361
RUST_SHA256_i686 = dc931adeb2943dcadfbd29546481f0296fcb97a511421053ecae6586a85869b1
NINJA_SHA256 = 31747ae633213f1eda3842686f83c2aa1412e0f5691d1c14dbbcc67fe7400cea
DOCKER = docker
@ -55,6 +59,10 @@ DOCKER = docker
-re 's!@RUST_SOURCE_i686@!$(RUST_SOURCE_i686)!g' \
-re 's!@RUST_SHA256_x86_64@!$(RUST_SHA256_x86_64)!g' \
-re 's!@RUST_SHA256_i686@!$(RUST_SHA256_i686)!g' \
-re 's!@NINJA_VERSION@!$(NINJA_VERSION)!g' \
-re 's!@NINJA_URLBASE@!$(NINJA_URLBASE)!g' \
-re 's!@NINJA_SOURCE@!$(NINJA_SOURCE)!g' \
-re 's!@NINJA_SHA256@!$(NINJA_SHA256)!g' \
-re 's!@J@!$(shell nproc)!g' \
$< >$@
@ -84,11 +92,10 @@ define create-build-base-rules
.PHONY: build-base-$(1)
all build-base: build-base-$(1)
build-base-$(1): build-base-$(1).Dockerfile
rm -rf build; mkdir -p build
$(DOCKER) build -f $$< \
--cache-from=$(PROTONSDK_URLBASE)/build-base-$(1) \
-t $(PROTONSDK_URLBASE)/build-base-$(1):latest \
build
context
pull::
-$(DOCKER) pull $(PROTONSDK_URLBASE)/build-base-$(1):latest
push::
@ -102,12 +109,11 @@ define create-binutils-rules
.PHONY: binutils-$(1)-$(2)
all binutils: binutils-$(1)-$(2)
binutils-$(1)-$(2): binutils-$(1)-$(2).Dockerfile | build-base
rm -rf build; mkdir -p build
$(DOCKER) build -f $$< \
--cache-from=$(PROTONSDK_URLBASE)/binutils-$(1)-$(2) \
-t $(PROTONSDK_URLBASE)/binutils-$(1)-$(2):$(BINUTILS_VERSION) \
-t $(PROTONSDK_URLBASE)/binutils-$(1)-$(2):latest \
build
context
pull::
-$(DOCKER) pull $(PROTONSDK_URLBASE)/binutils-$(1)-$(2):$(BINUTILS_VERSION)
push::
@ -130,12 +136,11 @@ define create-mingw-rules
all mingw: mingw-$(2)-$(1)
mingw-$(2)-$(1): ARCH_FLAGS = $(MINGW_ARCH_FLAGS_$(2)-$(1))
mingw-$(2)-$(1): mingw-$(2)-$(1).Dockerfile | binutils
rm -rf build; mkdir -p build
$(DOCKER) build -f $$< \
--cache-from=$(PROTONSDK_URLBASE)/mingw-$(2)-$(1) \
-t $(PROTONSDK_URLBASE)/mingw-$(2)-$(1):$(MINGW_VERSION) \
-t $(PROTONSDK_URLBASE)/mingw-$(2)-$(1):latest \
build
context
pull::
-$(DOCKER) pull $(PROTONSDK_URLBASE)/mingw-$(2)-$(1):$(MINGW_VERSION)
push::
@ -166,12 +171,11 @@ all gcc: gcc-$(1)-$(2)
gcc-$(1)-$(2): ARCH_FLAGS = $(GCC_ARCH_FLAGS_$(1))
gcc-$(1)-$(2): TARGET_FLAGS = $(GCC_TARGET_FLAGS_$(2))
gcc-$(1)-$(2): gcc-$(1)-$(2).Dockerfile | mingw
rm -rf build; mkdir -p build
$(DOCKER) build -f $$< \
--cache-from=$(PROTONSDK_URLBASE)/gcc-$(1)-$(2) \
-t $(PROTONSDK_URLBASE)/gcc-$(1)-$(2):$(GCC_VERSION) \
-t $(PROTONSDK_URLBASE)/gcc-$(1)-$(2):latest \
build
context
pull::
-$(DOCKER) pull $(PROTONSDK_URLBASE)/gcc-$(1)-$(2):$(GCC_VERSION)
push::
@ -189,12 +193,11 @@ define create-proton-rules
all: proton
proton: BASE_IMAGE = $(STEAMRT_URLBASE)/steamrt/sniper/sdk:$(STEAMRT_VERSION)
proton: proton.Dockerfile | gcc
rm -rf build; mkdir -p build
$(DOCKER) build -f $$< \
--cache-from=$(PROTONSDK_URLBASE) \
-t $(PROTONSDK_URLBASE):$(PROTONSDK_VERSION) \
-t $(PROTONSDK_URLBASE):latest \
build
context
pull::
-$(DOCKER) pull $(PROTONSDK_URLBASE):$(PROTONSDK_VERSION)
push::
@ -210,13 +213,16 @@ sources::
rm -f $(GCC_SOURCE)
rm -f $(RUST_SOURCE_x86_64)
rm -f $(RUST_SOURCE_i686)
rm -f $(NINJA_SOURCE)
wget $(BINUTILS_URLBASE)/$(BINUTILS_SOURCE)
wget $(MINGW_URLBASE)/$(MINGW_SOURCE)
wget $(GCC_URLBASE)/$(GCC_SOURCE)
wget $(RUST_URLBASE)/$(RUST_SOURCE_x86_64)
wget $(RUST_URLBASE)/$(RUST_SOURCE_i686)
wget $(NINJA_URLBASE)/$(NINJA_SOURCE)
echo $(BINUTILS_SHA256) $(BINUTILS_SOURCE) | sha256sum -c -
echo $(MINGW_SHA256) $(MINGW_SOURCE) | sha256sum -c -
echo $(GCC_SHA256) $(GCC_SOURCE) | sha256sum -c -
echo $(RUST_SHA256_x86_64) $(RUST_SOURCE_x86_64) | sha256sum -c -
echo $(RUST_SHA256_i686) $(RUST_SOURCE_i686) | sha256sum -c -
echo $(NINJA_SHA256) $(NINJA_SOURCE) | sha256sum -c -

File diff suppressed because it is too large Load Diff

View File

@ -69,6 +69,23 @@ RUN apt-get install -y \
&& rm -rf /opt/usr/share/doc /opt/usr/share/info /opt/usr/share/man \
&& rm -rf /var/lib/apt/lists/*
COPY ninja-jobserver-client.patch /tmp
RUN wget -q @NINJA_URLBASE@/@NINJA_SOURCE@ \
&& echo '@NINJA_SHA256@ @NINJA_SOURCE@' \
&& echo '@NINJA_SHA256@ @NINJA_SOURCE@' | sha256sum -c - \
&& tar xf @NINJA_SOURCE@ -C /tmp && rm @NINJA_SOURCE@ \
&& cd /tmp/ninja-@NINJA_VERSION@ \
&& patch -p1 < /tmp/ninja-jobserver-client.patch \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make \
&& cp ninja $(which ninja) \
&& cd / \
&& rm -rf /tmp/ninja-@NINJA_VERSION@ \
&& rm -rf /tmp/ninja-jobserver-client.patch
ENTRYPOINT ["/usr/bin/tini-static", "-s", "-g", "--"]
CMD ["/bin/bash"]