Makefile: Remove Vagrant build path

This commit is contained in:
Andrew Eikum 2021-12-22 10:36:28 -06:00 committed by Arkadiusz Hiler
parent 3bffbe24b3
commit 9d742a5332
5 changed files with 100 additions and 406 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
/.vagrant/
/vagrant_share/
/build/

163
Makefile
View File

@ -13,8 +13,10 @@ endif
# remove special chars
override _build_name := $(shell echo $(_build_name) | tr -dc '[:alnum:] ._-')
BUILD_ROOT := build
# make doesn't handle spaces well... replace them with underscores in paths
BUILD_DIR := "build-$(shell echo $(_build_name) | sed -e 's/ /_/g')"
BUILD_DIR := $(BUILD_ROOT)/build-$(shell echo $(_build_name) | sed -e 's/ /_/g')
STEAM_DIR := $(HOME)/.steam/root
ifeq ($(build_name),)
@ -23,11 +25,6 @@ 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 :=
@ -41,7 +38,7 @@ ifneq ($(unstripped),)
DEPLOY_DIR := $(DEPLOY_DIR)_unstripped
endif
CONFIGURE_CMD := ../proton/configure.sh \
CONFIGURE_CMD := ../../configure.sh \
--build-name="$(_build_name)"
ifneq ($(protonsdk_version),)
@ -50,10 +47,15 @@ else
protonsdk_version := $(shell grep '^arg_protonsdk_image=' configure.sh|xargs echo|cut -d: -f2)
endif
enable_ccache := 1
ifneq ($(enable_ccache),0)
CCACHE_FLAG := ENABLE_CCACHE=1
CONFIGURE_CMD += --enable-ccache
endif
all: help
.PHONY: help vagrant clean configure proton install deploy module protonsdk
.PHONY: help clean configure proton install deploy module protonsdk
help:
@echo "Proton Makefile instructions"
@ -61,8 +63,8 @@ help:
@echo "\"Quick start\" Makefile targets:"
@echo " install - Install Proton into current user's Steam installation"
@echo " redist - Build a package suitable for manual installation or distribution"
@echo " to other users in vagrant_share/ named after the nearest git tag"
@echo " deploy - Build Steam deployment files into a directory in vagrant_share/ named"
@echo " to other users in $(BUILD_ROOT)/ named after the nearest git tag"
@echo " deploy - Build Steam deployment files into a directory in $(BUILD_ROOT)/ named"
@echo " after the nearest git tag"
@echo " clean - Delete the Proton build directory"
@echo ""
@ -78,50 +80,36 @@ help:
@echo " use protonsdk_version=local to build it locally."
@echo ""
@echo "Development targets:"
@echo " vagrant - Start Vagrant VM"
@echo " configure - Configure Proton build directory"
@echo " proton - Build Proton"
@echo ""
@echo " The following targets are development targets only useful after building Proton."
@echo " module - Rebuild a single Wine module and copy into vagrant_share/."
@echo " module - Rebuild a single Wine module and copy into $(BUILD_ROOT)/<module>/."
@echo " Specify module variable: make module=kernel32 module"
@echo " dxvk - Rebuild DXVK and copy it into vagrant_share/."
@echo " lsteamclient - Rebuild the Steam client wrapper and copy it into vagrant_share/."
@echo " dxvk - Rebuild DXVK and copy it into $(BUILD_ROOT)/."
@echo " lsteamclient - Rebuild the Steam client wrapper and copy it into $(BUILD_ROOT)/."
@echo ""
@echo "Examples:"
@echo " make install - Build Proton and install into this user's Steam installation,"
@echo " with the current Proton branch name as the tool's name."
@echo ""
@echo " make redist - Build a Proton redistribution package in a tagged directory"
@echo " in vagrant_share/."
@echo " in $(BUILD_ROOT)/."
@echo ""
@echo " make build_name=mytest install - Build Proton with the tool name \"mytest\" and"
@echo " install into this user's Steam installation."
@echo ""
@echo " make build_name=mytest module=dsound module - Build only the dsound module"
@echo " in the \"mytest\" build directory and place it into vagrant_share/dsound/."
@echo ""
@echo "Running out of disk space in the VM? See resize-vagrant-disk.sh"
@echo " in the \"mytest\" build directory and place it into $(BUILD_ROOT)/dsound/."
VAGRANT_SHELL := vagrant ssh
clean:
rm -rf $(BUILD_DIR)
vagrant: private SHELL := $(SHELL)
vagrant:
vagrant up
vagrant rsync debian10
clean: private SHELL := $(VAGRANT_SHELL)
clean: vagrant
rm -rf $(BUILD_DIR)/
protonsdk: private SHELL := $(VAGRANT_SHELL)
protonsdk: vagrant
protonsdk:
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C proton/docker $(UNSTRIPPED) $(CCACHE_FLAG) PROTONSDK_VERSION=$(protonsdk_version) proton
configure: private SHELL := $(VAGRANT_SHELL)
configure: vagrant
if [ ! -e $(BUILD_DIR)/Makefile ]; \
then mkdir -p $(BUILD_DIR); \
configure: | $(BUILD_DIR)
if [ ! -e $(BUILD_DIR)/Makefile ]; then \
(cd $(BUILD_DIR) && $(CONFIGURE_CMD)); \
fi
@ -129,109 +117,96 @@ ifeq ($(protonsdk_version),local)
configure: protonsdk
endif
downloads: private SHELL := $(VAGRANT_SHELL)
downloads: configure
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR) downloads
proton: private SHELL := $(VAGRANT_SHELL)
proton: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) dist && \
echo "Proton built in VM. Use 'install' or 'deploy' targets to retrieve the build."
install-internal: | vagrant_share/compatibilitytools.d/$(_build_name)
install-internal: private SHELL := $(VAGRANT_SHELL)
install-internal: | $(BUILD_ROOT)/compatibilitytools.d/$(_build_name)
install-internal: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) STEAM_DIR=/vagrant/ install
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) install
install: install-internal
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 $(BUILD_ROOT)/compatibilitytools.d/$(_build_name) $(STEAM_DIR)/compatibilitytools.d/
echo "Proton installed to your local Steam installation"
redist: | vagrant_share/$(DEPLOY_DIR)
redist: private SHELL := $(VAGRANT_SHELL)
redist: | $(BUILD_ROOT)/$(DEPLOY_DIR)
redist: downloads
rm -rf /vagrant/$(DEPLOY_DIR)/* && \
rm -rf $(BUILD_ROOT)/$(DEPLOY_DIR)/* && \
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) redist && \
cp -Rf $(BUILD_DIR)/redist/* /vagrant/$(DEPLOY_DIR) && \
echo "Proton build available at vagrant_share/$(DEPLOY_DIR)"
cp -Rf $(BUILD_DIR)/redist/* $(BUILD_ROOT)/$(DEPLOY_DIR) && \
echo "Proton build available at $(BUILD_ROOT)/$(DEPLOY_DIR)"
deploy: | vagrant_share/$(DEPLOY_DIR)-deploy
deploy: private SHELL := $(VAGRANT_SHELL)
deploy: | $(BUILD_ROOT)/$(DEPLOY_DIR)-deploy
deploy: downloads
rm -rf /vagrant/$(DEPLOY_DIR)-deploy/* && \
rm -rf $(BUILD_ROOT)/$(DEPLOY_DIR)-deploy/* && \
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) deploy && \
cp -Rf $(BUILD_DIR)/deploy/* /vagrant/$(DEPLOY_DIR)-deploy && \
echo "Proton deployed to vagrant_share/$(DEPLOY_DIR)-deploy"
cp -Rf $(BUILD_DIR)/deploy/* $(BUILD_ROOT)/$(DEPLOY_DIR)-deploy && \
echo "Proton deployed to $(BUILD_ROOT)/$(DEPLOY_DIR)-deploy"
module: | vagrant_share/$(module)/lib/wine/i386-windows
module: | vagrant_share/$(module)/lib/wine/i386-unix
module: | vagrant_share/$(module)/lib64/wine/x86_64-windows
module: | vagrant_share/$(module)/lib64/wine/x86_64-unix
module: private SHELL := $(VAGRANT_SHELL)
module: | $(BUILD_ROOT)/$(module)/lib/wine/i386-windows
module: | $(BUILD_ROOT)/$(module)/lib/wine/i386-unix
module: | $(BUILD_ROOT)/$(module)/lib64/wine/x86_64-windows
module: | $(BUILD_ROOT)/$(module)/lib64/wine/x86_64-unix
module: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) module=$(module) module && \
cp -f $(BUILD_DIR)/obj-wine32/dlls/$(module)/$(module)$(MODULE_SFX)* /vagrant/$(module)/lib/wine/i386-windows/ && \
cp -f $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module)$(MODULE_SFX)* /vagrant/$(module)/lib64/wine/x86_64-windows/ && \
cp -f $(BUILD_DIR)/obj-wine32/dlls/$(module)/$(module)$(MODULE_SFX)* $(BUILD_ROOT)/$(module)/lib/wine/i386-windows/ && \
cp -f $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module)$(MODULE_SFX)* $(BUILD_ROOT)/$(module)/lib64/wine/x86_64-windows/ && \
if [ -e $(BUILD_DIR)/obj-wine32/dlls/$(module)/$(module).so ]; then \
cp -f $(BUILD_DIR)/obj-wine32/dlls/$(module)/$(module).so /vagrant/$(module)/lib/wine/i386-unix/ && \
cp -f $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module).so /vagrant/$(module)/lib64/wine/x86_64-unix/; \
cp -f $(BUILD_DIR)/obj-wine32/dlls/$(module)/$(module).so $(BUILD_ROOT)/$(module)/lib/wine/i386-unix/ && \
cp -f $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module).so $(BUILD_ROOT)/$(module)/lib64/wine/x86_64-unix/; \
fi
dxvk: | vagrant_share/dxvk/lib/wine/dxvk
dxvk: | vagrant_share/dxvk/lib64/wine/dxvk
dxvk: private SHELL := $(VAGRANT_SHELL)
dxvk: | $(BUILD_ROOT)/dxvk/lib/wine/dxvk
dxvk: | $(BUILD_ROOT)/dxvk/lib64/wine/dxvk
dxvk: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -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/
cp -f $(BUILD_DIR)/dist/dist/lib/wine/dxvk/*.dll $(BUILD_ROOT)/dxvk/lib/wine/dxvk/ && \
cp -f $(BUILD_DIR)/dist/dist/lib64/wine/dxvk/*.dll $(BUILD_ROOT)/dxvk/lib64/wine/dxvk/
dxvk-nvapi: | vagrant_share/dxvk-nvapi/lib/wine/nvapi
dxvk-nvapi: | vagrant_share/dxvk-nvapi/lib64/wine/nvapi
dxvk-nvapi: private SHELL := $(VAGRANT_SHELL)
dxvk-nvapi: | $(BUILD_ROOT)/dxvk-nvapi/lib/wine/nvapi
dxvk-nvapi: | $(BUILD_ROOT)/dxvk-nvapi/lib64/wine/nvapi
dxvk-nvapi: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) dxvk-nvapi && \
cp -f $(BUILD_DIR)/dist/files/lib/wine/nvapi/*.dll /vagrant/dxvk-nvapi/lib/wine/nvapi/ && \
cp -f $(BUILD_DIR)/dist/files/lib64/wine/nvapi/*.dll /vagrant/dxvk-nvapi/lib64/wine/nvapi/
cp -f $(BUILD_DIR)/dist/files/lib/wine/nvapi/*.dll $(BUILD_ROOT)/dxvk-nvapi/lib/wine/nvapi/ && \
cp -f $(BUILD_DIR)/dist/files/lib64/wine/nvapi/*.dll $(BUILD_ROOT)/dxvk-nvapi/lib64/wine/nvapi/
vkd3d-proton: | vagrant_share/vkd3d-proton/lib/wine/vkd3d-proton
vkd3d-proton: | vagrant_share/vkd3d-proton/lib64/wine/vkd3d-proton
vkd3d-proton: private SHELL := $(VAGRANT_SHELL)
vkd3d-proton: | $(BUILD_ROOT)/vkd3d-proton/lib/wine/vkd3d-proton
vkd3d-proton: | $(BUILD_ROOT)/vkd3d-proton/lib64/wine/vkd3d-proton
vkd3d-proton: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -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/
cp -f $(BUILD_DIR)/dist/dist/lib/wine/vkd3d-proton/*.dll $(BUILD_ROOT)/vkd3d-proton/lib/wine/vkd3d-proton/ && \
cp -f $(BUILD_DIR)/dist/dist/lib64/wine/vkd3d-proton/*.dll $(BUILD_ROOT)/vkd3d-proton/lib64/wine/vkd3d-proton/
lsteamclient: | vagrant_share/lsteamclient/lib/wine
lsteamclient: | vagrant_share/lsteamclient/lib64/wine
lsteamclient: private SHELL := $(VAGRANT_SHELL)
lsteamclient: | $(BUILD_ROOT)/lsteamclient/lib/wine
lsteamclient: | $(BUILD_ROOT)/lsteamclient/lib64/wine
lsteamclient: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -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
cp -f $(BUILD_DIR)/dist/dist/lib/wine/lsteamclient.dll.so $(BUILD_ROOT)/lsteamclient/lib/wine && \
cp -f $(BUILD_DIR)/dist/dist/lib64/wine/lsteamclient.dll.so $(BUILD_ROOT)/lsteamclient/lib64/wine
vrclient: | vagrant_share/vrclient/lib/wine
vrclient: | vagrant_share/vrclient/lib64/wine
vrclient: private SHELL := $(VAGRANT_SHELL)
vrclient: | $(BUILD_ROOT)/vrclient/lib/wine
vrclient: | $(BUILD_ROOT)/vrclient/lib64/wine
vrclient: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -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
cp -f $(BUILD_DIR)/dist/dist/lib/wine/vrclient.dll.so $(BUILD_ROOT)/vrclient/lib/wine && \
cp -f $(BUILD_DIR)/dist/dist/lib64/wine/vrclient_x64.dll.so $(BUILD_ROOT)/vrclient/lib64/wine
wineopenxr: | vagrant_share/wineopenxr/lib/wine
wineopenxr: | vagrant_share/wineopenxr/lib64/wine
wineopenxr: private SHELL := $(VAGRANT_SHELL)
wineopenxr: | $(BUILD_ROOT)/wineopenxr/lib/wine
wineopenxr: | $(BUILD_ROOT)/wineopenxr/lib64/wine
wineopenxr: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) wineopenxr && \
cp -f $(BUILD_DIR)/dist/dist/lib64/wine/wineopenxr.dll.so /vagrant/wineopenxr/lib64/wine
cp -f $(BUILD_DIR)/dist/dist/lib64/wine/wineopenxr.dll.so $(BUILD_ROOT)/wineopenxr/lib64/wine
battleye: | vagrant_share/battleye/v1/lib/wine
battleye: | vagrant_share/battleye/v1/lib64/wine
battleye: private SHELL := $(VAGRANT_SHELL)
battleye: | $(BUILD_ROOT)/battleye/v1/lib/wine
battleye: | $(BUILD_ROOT)/battleye/v1/lib64/wine
battleye: downloads
$(MAKE) $(MFLAGS) $(MAKEOVERRIDES) -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) battleye && \
cp -f $(BUILD_DIR)/dist-battleye/v1/lib/wine/beclient.dll.so /vagrant/battleye/v1/lib/wine && \
cp -f $(BUILD_DIR)/dist-battleye/v1/lib64/wine/beclient_x64.dll.so /vagrant/battleye/v1/lib64/wine
cp -f $(BUILD_DIR)/dist-battleye/v1/lib/wine/beclient.dll.so $(BUILD_ROOT)/battleye/v1/lib/wine && \
cp -f $(BUILD_DIR)/dist-battleye/v1/lib64/wine/beclient_x64.dll.so $(BUILD_ROOT)/battleye/v1/lib64/wine
vagrant_share/%:
$(BUILD_ROOT)/%:
mkdir -p $@

138
README.md
View File

@ -46,23 +46,9 @@ Building Proton
---------------
Most of Proton builds inside the Proton SDK container with very few
dependencies on the host side. For convenience we also provide
[Vagrant][vagrant] scripts that will create a VM with all the dependencies
and a working container runtime and build Proton inside it.
dependencies on the host side.
The direct container build is recommended for people building Proton on a
regular basis as it is faster and less resource hungry.
The Vagrant VM is easier to set up but comes with higher overhead, which
makes it more suitable for an occasional Proton build.
[vagrant]: https://www.vagrantup.com/
Building with Podman or Docker
------------------------------
### Preparing the build environment
## Preparing the build environment
You need either a Docker or a Podman setup. We highly recommend [the rootless
Podman setup][rootless-podman]. Please refer to your distribution's
@ -77,6 +63,33 @@ documentation for setup instructions (e.g. Arch [Podman][arch-podman] /
[debian-docker]: https://wiki.debian.org/Docker
## The Easy Way
We provide a top-level Makefile which will execute most of the build commands
for you.
After checking out the repository and updating its submodules, assuming that
you have a working Docker or Podman setup, you can build and install Proton
with a simple:
```bash
make install
```
If your build system is missing dependencies, it will fail quickly with a clear
error message.
After the build finishes, you may need to restart the Steam client to see the
new Proton tool. The tool's name in the Steam client will be based on the
currently checked out branch of Proton. You can override this name using the
`build_name` variable.
See `make help` for other build targets and options.
## Manual building
### Configuring the build
```bash
@ -137,97 +150,6 @@ is only useful after building Proton.
`make dxvk` / `make vkd3d-proton` - rebuild DXVK / vkd3d-proton.
Building using Vagrant
----------------------
This section describes how to use a virtual machine to build proton.
### Preparing the build environment
The VM is managed with [Vagrant][vagrant], which you will need to install and
configure before invoking these commands. Proton's build system is most well
tested with Vagrant's VirtualBox and libvirt/qemu backends. It also requires
the vagrant-sshfs plugin. You may run into problems with the shared folder
(`vagrant_share`) and/or CPU and memory usage with other backends.
[vagrant]: https://www.vagrantup.com/
### The Easy Way
We provide a top-level Makefile which will execute most of the build commands
for you.
After checking out the repository and updating its submodules, assuming that
you have working Vagrant setup, you can build and install Proton with a
simple:
```bash
make install
```
You may need to restart the Steam client to see the new Proton tool. The
tool's name in the Steam client will be based on the currently checked out
branch of Proton. You can override this name using the `build_name` variable.
See `make help` for other build targets and options.
If your build VM gets cluttered, or falls out of date, you can use `vagrant
destroy` to wipe the VM clean, then invoke one of the below commands to start
over.
### The Detailed Way
Proton provides a Vagrantfile, which will automatically set up the Debian VM
for you. After installing Vagrant, initialize the VM by running from within
the Proton directory:
```bash
vagrant up
```
It will take a long time to download the base image and install all the build
dependencies. Eventually it will complete. You can SSH into the virtual
machine with:
```bash
vagrant ssh
```
**You are now inside a virtual machine with a working Docker setup.** At this
point you will need to configure and make the build, see [building with
podman or docker](#building-with-podman-or-docker) section for details.
```bash
mkdir build/
cd build
../proton/configure.sh --build-name=my_build
make
```
The Vagrantfile is set up to rsync the `proton` directory into the VM on
boot. On the host machine, you can use `vagrant rsync-auto` to have Vagrant
automatically sync changes on your host machine into the build machine. It is
recommended that you make changes on your host machine, and then perform the
build in the VM. Any changes you make in the `proton` directory on the VM may
be overwritten by later rsync updates from the host machine.
The Vagrantfile also creates a directory called `vagrant_share/` in the
`proton/` directory of your host machine, which is mounted at `/vagrant`
within the VM. You can use this shared folder to move your Proton build out
of the VM, or as one way to copy files into the VM.
When you are done with the VM, you can shut it down from the host machine:
```bash
vagrant halt
```
Please read the Vagrant documentation for more information about how to use
Vagrant VMs.
Install Proton locally
----------------------
@ -244,7 +166,7 @@ The `make install` target will perform this task for you, installing the
Proton build into the Steam folder for the current user. You will have to
restart the Steam client for it to pick up on a new tool.
A correct local tool installation should look like this:
A correct local tool installation should look similar to this:
```
compatibilitytools.d/my_proton/

104
Vagrantfile vendored
View File

@ -1,104 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version ">= 2.2.0"
module OS
def OS.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
def OS.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def OS.unix?
!OS.windows?
end
def OS.linux?
OS.unix? and not OS.mac?
end
end
# Vagrant file for setting up a build environment for Proton.
if OS.linux?
cpus = `nproc`.to_i
# meminfo shows KB and we need to convert to MB
memory = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 2
elsif OS.mac?
cpus = `sysctl -n hw.physicalcpu`.to_i
# sysctl shows bytes and we need to convert to MB
memory = `sysctl hw.memsize | sed -e 's/hw.memsize: //'`.to_i / 1024 / 1024 / 2
else
cpus = 1
memory = 1024
puts "Vagrant launched from unsupported platform."
end
memory = [memory, 4096].max
puts "Platform: " + cpus.to_s + " CPUs, " + memory.to_s + " MB memory"
Vagrant.configure(2) do |config|
#libvirt doesn't have a decent synced folder, so we have to use vagrant-sshfs.
#This is not needed for virtualbox, but I couldn't find a way to use a
#different synced folder type per provider, so we always use it.
config.vagrant.plugins = "vagrant-sshfs"
config.vm.provider "virtualbox" do |v|
v.cpus = [cpus, 32].min # virtualbox limit is 32 cpus
v.memory = memory
end
config.vm.provider "libvirt" do |v|
v.cpus = cpus
v.memory = memory
v.random_hostname = true
v.default_prefix = ENV['USER'].to_s.dup.concat('_').concat(File.basename(Dir.pwd))
end
#debian10-based build VM
config.vm.define "debian10", primary: true do |debian10|
debian10.vm.box = "generic/debian10"
debian10.vm.synced_folder "./vagrant_share/", "/vagrant/", create: true, type: "sshfs", sshfs_opts_append: "-o cache=no"
debian10.vm.synced_folder ".", "/home/vagrant/proton", id: "proton", type: "rsync", rsync__exclude: ["vagrant_share"]
debian10.vm.provision "shell", privileged: "true", inline: <<-SHELL
set -e
#install docker and steam-runtime dependencies
dpkg --add-architecture i386
apt-get update
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
#add docker repo
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"
#install host build-time dependencies
apt-get update
apt-get install -y ccache texinfo gpgv2 gnupg2 git docker-ce docker-ce-cli containerd.io \
fontforge-nox python-debian uuid-dev python3-pip
# https://github.blog/2021-09-01-improving-git-protocol-security-github/
git config --global url.https://github.com/.insteadOf git://github.com/
#install adobe font devkit to build source san hans
pip3 install afdko
#allow vagrant user to run docker
adduser vagrant docker
# use faster overlay2 docker driver
echo '{"storage-driver": "overlay2"}' >/etc/docker/daemon.json
#allow user to run stuff in steamrt
sysctl kernel.unprivileged_userns_clone=1
mkdir -p /etc/sysctl.d/
echo kernel.unprivileged_userns_clone=1 > /etc/sysctl.d/docker_user.conf
#ensure we use only the mingw-w64 that we built
apt-get remove -y '*mingw-w64*'
SHELL
end
end

View File

@ -1,100 +0,0 @@
#!/bin/bash
#this script resizes the build VM disk image. the generic/debian9 box that we
#use only ships a 32G disk, which is only just large enough to hold the Steam
#runtime, two Wine build trees, and final Proton dist/ folder.
set -e
NOTE_STYLE="\e[31m\e[1m"
RESET_STYLE="\e[0m"
NEW_LIBVIRT_DISK_SIZE=128G
function note {
echo -e "$NOTE_STYLE""$1""$RESET_STYLE"
}
function usage {
note "To automatically resize a libvirt disk to $NEW_LIBVIRT_DISK_SIZE:"
echo ""
echo -e "\t$0 --libvirt-disk <libvirt disk path>"
echo ""
note "You may find the disk path with \"virsh vol-list default\"."
echo ""
note "Or, if you've already manually resized the disk (e.g. VirtualBox users):"
echo ""
echo -e "\t$0 --resize-vm-partition"
exit 1
}
#to be run from within the VM
if [ "$1" == "--fdisk" ]; then
sudo sfdisk -d /dev/sda > /tmp/sda.sfdisk
#remove start and size params from sda3 line, sfdisk will automatically use the rest of the disk
sed -e "s/^.dev.sda3.*$/\/dev\/sda3 : type=83/" < /tmp/sda.sfdisk | sudo sfdisk --force /dev/sda
exit
#to be run from within the VM
elif [ "$1" == "--resize2fs" ]; then
#resize2fs automatically uses the whole partition
sudo resize2fs /dev/sda3
exit
#libvirt disk image to resize
elif [ "$1" == "--libvirt-disk" ]; then
if [ -z "$2" ]; then
note "You must give a disk path to --libvirt-disk"
echo ""
usage
exit 1
fi
LIBVIRT_DISK_PATH="$2"
note "Going to resize disk $LIBVIRT_DISK_PATH"
note "Shutting down VM"
vagrant halt
note "Resizing the VM disk image"
virsh vol-resize "$LIBVIRT_DISK_PATH" "$NEW_LIBVIRT_DISK_SIZE" --pool default
#just resize the partition in the VM
elif [ "$1" == "--resize-vm-partition" ]; then
: #noop
else
if [ -n "$1" -a "$1" != "--help" -a "$1" != "-h" ]; then
note "Unknown argument: $1"
exit 1
fi
usage
exit 1
fi
note "Starting the VM"
vagrant up
vagrant rsync
note "Repartitioning the disk"
vagrant ssh -c "/home/vagrant/proton/resize-vagrant-disk.sh --fdisk"
note "Restarting the VM"
#seems to be necessary for resize2fs to pick up on the new partition size
#maybe there's a way to do that without rebooting?
vagrant halt
vagrant up
note "Resizing the filesystem"
vagrant ssh -c "/home/vagrant/proton/resize-vagrant-disk.sh --resize2fs"
note "Here's the output from \"df -h /dev/sda3\":"
vagrant ssh -c "df -h /dev/sda3"
note "Shutting down the VM"
#just to be sure everything is in a clean state
vagrant halt
note "Done!"