From 24b944292e6fbceeec18bf6b44542b6534c3fa37 Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Mon, 17 Aug 2020 10:06:22 -0500 Subject: [PATCH] build: Support ccache. --- Makefile | 26 ++++++++++++++++---------- Vagrantfile | 8 +++++++- build/makefile_base.mak | 11 ++++++++--- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index ba08e377..6af5e8fc 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,11 @@ else DEPLOY_DIR := $(_build_name) endif +enable_ccache := 1 +ifneq ($(enable_ccache),0) + CCACHE_FLAG := ENABLE_CCACHE=1 +endif + ifneq ($(module),) ifneq ($(findstring .,$(module)),) MODULE_SFX := @@ -65,6 +70,7 @@ help: @echo " remember to always set it!" @echo " Current build name: $(_build_name)" @echo " unstripped - Set to non-empty to avoid stripping installed library files." + @echo " enable_ccache - Enabled by default, set to 0 to disable ccache." @echo "" @echo "Development targets:" @echo " vagrant - Start Vagrant VM" @@ -103,28 +109,28 @@ configure: vagrant @vagrant ssh -c 'if [ ! -e $(BUILD_DIR)/Makefile ]; then mkdir -p $(BUILD_DIR); (cd $(BUILD_DIR) && $(CONFIGURE_CMD)); fi && make -C $(BUILD_DIR) downloads' proton: configure - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) dist' + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) dist' echo "Proton built in VM. Use 'install' or 'deploy' targets to retrieve the build." install: configure - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) STEAM_DIR=/vagrant/ install' + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) STEAM_DIR=/vagrant/ install' mkdir -p $(STEAM_DIR)/compatibilitytools.d/ cp -Rf --no-dereference --preserve=mode,links vagrant_share/compatibilitytools.d/$(_build_name) $(STEAM_DIR)/compatibilitytools.d/ echo "Proton installed to your local Steam installation" redist: configure mkdir -p vagrant_share/$(DEPLOY_DIR) - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) redist && cp $(BUILD_DIR)/redist/* /vagrant/$(DEPLOY_DIR)' + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) redist && cp $(BUILD_DIR)/redist/* /vagrant/$(DEPLOY_DIR)' echo "Proton build available at vagrant_share/$(DEPLOY_DIR)" deploy: configure mkdir -p vagrant_share/$(DEPLOY_DIR)-deploy - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) deploy && cp $(BUILD_DIR)/deploy/* /vagrant/$(DEPLOY_DIR)-deploy' + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) deploy && cp $(BUILD_DIR)/deploy/* /vagrant/$(DEPLOY_DIR)-deploy' echo "Proton deployed to vagrant_share/$(DEPLOY_DIR)-deploy" module: configure mkdir -p vagrant_share/$(module)/lib/wine/ vagrant_share/$(module)/lib64/wine/ - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) module=$(module) module && \ + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) module=$(module) module && \ cp -f $(BUILD_DIR)/obj-wine32/dlls/$(module)/$(module)$(MODULE_SFX)* /vagrant/$(module)/lib/wine/ && \ cp -f $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module)$(MODULE_SFX)* /vagrant/$(module)/lib64/wine/ && \ if [ -e $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module).so ]; then \ @@ -136,34 +142,34 @@ module: configure dxvk: configure mkdir -p vagrant_share/dxvk/lib/wine/dxvk/ mkdir -p vagrant_share/dxvk/lib64/wine/dxvk/ - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) dxvk && \ + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) dxvk && \ cp -f $(BUILD_DIR)/dist/dist/lib/wine/dxvk/*.dll /vagrant/dxvk/lib/wine/dxvk/ && \ cp -f $(BUILD_DIR)/dist/dist/lib64/wine/dxvk/*.dll /vagrant/dxvk/lib64/wine/dxvk/' d9vk: configure mkdir -p vagrant_share/d9vk/lib/wine/dxvk/ mkdir -p vagrant_share/d9vk/lib64/wine/dxvk/ - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) d9vk && \ + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) d9vk && \ cp -f $(BUILD_DIR)/dist/dist/lib/wine/dxvk/*.dll /vagrant/d9vk/lib/wine/dxvk/ && \ cp -f $(BUILD_DIR)/dist/dist/lib64/wine/dxvk/*.dll /vagrant/d9vk/lib64/wine/dxvk/' vkd3d-proton: configure mkdir -p vagrant_share/vkd3d-proton/lib/wine/vkd3d-proton/ mkdir -p vagrant_share/vkd3d-proton/lib64/wine/vkd3d-proton/ - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) vkd3d-proton && \ + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) vkd3d-proton && \ cp -f $(BUILD_DIR)/dist/dist/lib/wine/vkd3d-proton/*.dll /vagrant/vkd3d-proton/lib/wine/vkd3d-proton/ && \ cp -f $(BUILD_DIR)/dist/dist/lib64/wine/vkd3d-proton/*.dll /vagrant/vkd3d-proton/lib64/wine/vkd3d-proton/' lsteamclient: configure mkdir -p vagrant_share/lsteamclient/lib/wine mkdir -p vagrant_share/lsteamclient/lib64/wine - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) lsteamclient && \ + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) lsteamclient && \ cp -f $(BUILD_DIR)/dist/dist/lib/wine/lsteamclient.dll.so /vagrant/lsteamclient/lib/wine && \ cp -f $(BUILD_DIR)/dist/dist/lib64/wine/lsteamclient.dll.so /vagrant/lsteamclient/lib64/wine' vrclient: configure mkdir -p vagrant_share/vrclient/lib/wine mkdir -p vagrant_share/vrclient/lib64/wine - vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) vrclient && \ + vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) vrclient && \ cp -f $(BUILD_DIR)/dist/dist/lib/wine/vrclient.dll.so /vagrant/vrclient/lib/wine && \ cp -f $(BUILD_DIR)/dist/dist/lib64/wine/vrclient_x64.dll.so /vagrant/vrclient/lib64/wine' diff --git a/Vagrantfile b/Vagrantfile index e9dd2bfe..2e127e74 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -76,7 +76,7 @@ Vagrant.configure(2) do |config| #install host build-time dependencies apt-get update - apt-get install -y texinfo gpgv2 gnupg2 git docker-ce docker-ce-cli containerd.io \ + apt-get install -y ccache texinfo gpgv2 gnupg2 git docker-ce docker-ce-cli containerd.io \ fontforge-nox python-debian python-pip meson libmpc-dev libmpc-dev:i386 \ gcc g++ gcc-i686-linux-gnu g++-i686-linux-gnu binutils-i686-linux-gnu \ gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 \ @@ -106,6 +106,12 @@ Vagrant.configure(2) do |config| #ensure we use only the mingw-w64 that we built apt-get remove -y '*mingw-w64*' + + #setup ccache + ln -s $(which ccache) /usr/lib/ccache/x86_64-w64-mingw32-gcc + ln -s $(which ccache) /usr/lib/ccache/x86_64-w64-mingw32-g++ + ln -s $(which ccache) /usr/lib/ccache/i686-w64-mingw32-gcc + ln -s $(which ccache) /usr/lib/ccache/i686-w64-mingw32-g++ SHELL end end diff --git a/build/makefile_base.mak b/build/makefile_base.mak index 3116297b..d2ecece0 100644 --- a/build/makefile_base.mak +++ b/build/makefile_base.mak @@ -38,17 +38,22 @@ endif # If CC is coming from make's defaults or nowhere, use our own default. Otherwise respect environment. ifneq ($(filter default undefined,$(origin CC)),) -# CC = ccache gcc CC = gcc endif ifneq ($(filter default undefined,$(origin CXX)),) -# CXX = ccache g++ CXX = g++ endif export CC export CXX +ifeq ($(ENABLE_CCACHE),1) + export PATH := /usr/lib/ccache:$(PATH) +else + export CCACHE_DISABLE = 1 + DOCKER_CCACHE_FLAG = -e CCACHE_DISABLE=1 +endif + CC32 := gcc -m32 -mstackrealign CXX32 := g++ -m32 -mstackrealign PKG_CONFIG32 := i686-linux-gnu-pkg-config @@ -61,7 +66,7 @@ cc-option = $(shell if test -z "`echo 'void*p=1;' | \ DOCKER_SHELL_BASE = docker run --rm --init --privileged --cap-add=SYS_ADMIN --security-opt apparmor:unconfined \ -v $(HOME):$(HOME) -v /tmp:/tmp \ -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v /etc/shadow:/etc/shadow:ro \ - -w $(CURDIR) -e HOME=$(HOME) -e PATH=$(PATH) -u $(shell id -u):$(shell id -g) -h $(shell hostname) \ + -w $(CURDIR) -e HOME=$(HOME) -e PATH=$(PATH) $(DOCKER_CCACHE_FLAG) -u $(shell id -u):$(shell id -g) -h $(shell hostname) \ $(DOCKER_OPTS) \ $(SELECT_DOCKER_IMAGE) /sbin/docker-init -sg -- /bin/bash