build: Support ccache.

This commit is contained in:
Zhiyi Zhang 2020-08-17 10:06:22 -05:00 committed by Andrew Eikum
parent 8828544db7
commit 24b944292e
3 changed files with 31 additions and 14 deletions

View file

@ -22,6 +22,11 @@ else
DEPLOY_DIR := $(_build_name) DEPLOY_DIR := $(_build_name)
endif endif
enable_ccache := 1
ifneq ($(enable_ccache),0)
CCACHE_FLAG := ENABLE_CCACHE=1
endif
ifneq ($(module),) ifneq ($(module),)
ifneq ($(findstring .,$(module)),) ifneq ($(findstring .,$(module)),)
MODULE_SFX := MODULE_SFX :=
@ -65,6 +70,7 @@ help:
@echo " remember to always set it!" @echo " remember to always set it!"
@echo " Current build name: $(_build_name)" @echo " Current build name: $(_build_name)"
@echo " unstripped - Set to non-empty to avoid stripping installed library files." @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 ""
@echo "Development targets:" @echo "Development targets:"
@echo " vagrant - Start Vagrant VM" @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' @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 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." echo "Proton built in VM. Use 'install' or 'deploy' targets to retrieve the build."
install: configure 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/ mkdir -p $(STEAM_DIR)/compatibilitytools.d/
cp -Rf --no-dereference --preserve=mode,links vagrant_share/compatibilitytools.d/$(_build_name) $(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" echo "Proton installed to your local Steam installation"
redist: configure redist: configure
mkdir -p vagrant_share/$(DEPLOY_DIR) 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)" echo "Proton build available at vagrant_share/$(DEPLOY_DIR)"
deploy: configure deploy: configure
mkdir -p vagrant_share/$(DEPLOY_DIR)-deploy 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" echo "Proton deployed to vagrant_share/$(DEPLOY_DIR)-deploy"
module: configure module: configure
mkdir -p vagrant_share/$(module)/lib/wine/ vagrant_share/$(module)/lib64/wine/ 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-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/ && \ 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 \ if [ -e $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module).so ]; then \
@ -136,34 +142,34 @@ module: configure
dxvk: configure dxvk: configure
mkdir -p vagrant_share/dxvk/lib/wine/dxvk/ mkdir -p vagrant_share/dxvk/lib/wine/dxvk/
mkdir -p vagrant_share/dxvk/lib64/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/lib/wine/dxvk/*.dll /vagrant/dxvk/lib/wine/dxvk/ && \
cp -f $(BUILD_DIR)/dist/dist/lib64/wine/dxvk/*.dll /vagrant/dxvk/lib64/wine/dxvk/' cp -f $(BUILD_DIR)/dist/dist/lib64/wine/dxvk/*.dll /vagrant/dxvk/lib64/wine/dxvk/'
d9vk: configure d9vk: configure
mkdir -p vagrant_share/d9vk/lib/wine/dxvk/ mkdir -p vagrant_share/d9vk/lib/wine/dxvk/
mkdir -p vagrant_share/d9vk/lib64/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/lib/wine/dxvk/*.dll /vagrant/d9vk/lib/wine/dxvk/ && \
cp -f $(BUILD_DIR)/dist/dist/lib64/wine/dxvk/*.dll /vagrant/d9vk/lib64/wine/dxvk/' cp -f $(BUILD_DIR)/dist/dist/lib64/wine/dxvk/*.dll /vagrant/d9vk/lib64/wine/dxvk/'
vkd3d-proton: configure vkd3d-proton: configure
mkdir -p vagrant_share/vkd3d-proton/lib/wine/vkd3d-proton/ mkdir -p vagrant_share/vkd3d-proton/lib/wine/vkd3d-proton/
mkdir -p vagrant_share/vkd3d-proton/lib64/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/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/' cp -f $(BUILD_DIR)/dist/dist/lib64/wine/vkd3d-proton/*.dll /vagrant/vkd3d-proton/lib64/wine/vkd3d-proton/'
lsteamclient: configure lsteamclient: configure
mkdir -p vagrant_share/lsteamclient/lib/wine mkdir -p vagrant_share/lsteamclient/lib/wine
mkdir -p vagrant_share/lsteamclient/lib64/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/lib/wine/lsteamclient.dll.so /vagrant/lsteamclient/lib/wine && \
cp -f $(BUILD_DIR)/dist/dist/lib64/wine/lsteamclient.dll.so /vagrant/lsteamclient/lib64/wine' cp -f $(BUILD_DIR)/dist/dist/lib64/wine/lsteamclient.dll.so /vagrant/lsteamclient/lib64/wine'
vrclient: configure vrclient: configure
mkdir -p vagrant_share/vrclient/lib/wine mkdir -p vagrant_share/vrclient/lib/wine
mkdir -p vagrant_share/vrclient/lib64/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/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' cp -f $(BUILD_DIR)/dist/dist/lib64/wine/vrclient_x64.dll.so /vagrant/vrclient/lib64/wine'

8
Vagrantfile vendored
View file

@ -76,7 +76,7 @@ Vagrant.configure(2) do |config|
#install host build-time dependencies #install host build-time dependencies
apt-get update 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 \ 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 g++ gcc-i686-linux-gnu g++-i686-linux-gnu binutils-i686-linux-gnu \
gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 \ 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 #ensure we use only the mingw-w64 that we built
apt-get remove -y '*mingw-w64*' 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 SHELL
end end
end end

View file

@ -38,17 +38,22 @@ endif
# If CC is coming from make's defaults or nowhere, use our own default. Otherwise respect environment. # If CC is coming from make's defaults or nowhere, use our own default. Otherwise respect environment.
ifneq ($(filter default undefined,$(origin CC)),) ifneq ($(filter default undefined,$(origin CC)),)
# CC = ccache gcc
CC = gcc CC = gcc
endif endif
ifneq ($(filter default undefined,$(origin CXX)),) ifneq ($(filter default undefined,$(origin CXX)),)
# CXX = ccache g++
CXX = g++ CXX = g++
endif endif
export CC export CC
export CXX 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 CC32 := gcc -m32 -mstackrealign
CXX32 := g++ -m32 -mstackrealign CXX32 := g++ -m32 -mstackrealign
PKG_CONFIG32 := i686-linux-gnu-pkg-config 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 \ DOCKER_SHELL_BASE = docker run --rm --init --privileged --cap-add=SYS_ADMIN --security-opt apparmor:unconfined \
-v $(HOME):$(HOME) -v /tmp:/tmp \ -v $(HOME):$(HOME) -v /tmp:/tmp \
-v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v /etc/shadow:/etc/shadow:ro \ -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) \ $(DOCKER_OPTS) \
$(SELECT_DOCKER_IMAGE) /sbin/docker-init -sg -- /bin/bash $(SELECT_DOCKER_IMAGE) /sbin/docker-init -sg -- /bin/bash