adapt cross compiling guide to buildmaster image

develop
Myk Taylor 2022-12-09 05:04:10 -08:00
parent 8c59f9f92a
commit 6ffdeda712
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 26 additions and 49 deletions

@ -755,39 +755,36 @@ Step 1: prepare a docker image
On your Linux host, install and run the docker daemon and then run these commands:: On your Linux host, install and run the docker daemon and then run these commands::
xhost set +local:root xhost set +local:root
git clone git@github.com:mstorsjo/msvc-wine.git git clone https://github.com/BenLubar/build-env.git
cd msvc-wine cd build-env
docker build . docker build .
docker image ls docker image ls
IMAGE_ID=<your image id> IMAGE_ID=<your image id>
docker run -it --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume=/tmp/.X11-unix:/tmp/.X11-unix --name dfhack-win $IMAGE_ID docker run -it --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume=/tmp/.X11-unix:/tmp/.X11-unix --user buildmaster --name dfhack-win $IMAGE_ID
The ``xhost`` command and ``--env`` parameters are there so you can eventually The ``xhost`` command and ``--env`` parameters are there so you can eventually
run Dwarf Fortress from the container and have it display on your host. run Dwarf Fortress from the container and have it display on your host.
Step 2: prepare to build in the container Step 2: build DFHack
----------------------------------------- --------------------
The ``docker run`` command above will give you a shell prompt (as root) in the The ``docker run`` command above will give you a shell prompt (as root) in the
container. Inside the container, run the following commands:: container. Inside the container, run the following commands::
apt-get update; apt-get upgrade -y ccache -C
apt-get install -y gcc g++ ninja-build git zlib1g-dev libsdl1.2-dev libxml-libxml-perl libxml-libxslt-perl make wget unzip vim ccache libncurses-dev curl libssl-dev bash-completion export CCACHE_BASEDIR=/home/buildmaster/.ccache
echo 'export BIN=/opt/msvc/bin/x64' >>~/.bashrc git clone https://github.com/DFHack/dfhack.git
echo 'PATH=/opt/msvc:$BIN:$HOME/bin/cmake/bin:$PATH' >>~/.bashrc cd dfhack
. ~/.bashrc git submodule update --init
mkdir ~/src; cd ~/src cd build
git clone https://gitlab.kitware.com/mstorsjo/cmake.git dfhack-configure windows 64 Release
cd cmake; git checkout 844ccd2280d11ada286d0e2547c0fa5ff22bd4db dfhack-make
mkdir build; cd build
../configure --prefix=~/bin/cmake --parallel=$(nproc) -- -DBUILD_CursesDialog=ON Inside the ``dfhack-*`` scripts there are several commands that set up the wine
make -j$(nproc) server. Each invocation of a windows tool will cause wine to run in the container.
make install Preloading the wineserver and telling it not to exit will speed configuration and
cd ~/src compilation up considerably (approx. 10x). You can configure and build DFHack
git clone https://github.com/ab9rf/dfhack.git with regular ``cmake`` and ``ninja`` commands, but your build will go much slower.
cd dfhack; git submodule init; git submodule update
cd build; cmake .. -GNinja
ninja protoc
Step 3: copy Dwarf Fortress to the container Step 3: copy Dwarf Fortress to the container
-------------------------------------------- --------------------------------------------
@ -802,34 +799,17 @@ Otherwise, you can do something like this in your host Linux environment to copy
installed version to the container:: installed version to the container::
cd ~/.steam/steam/steamapps/common/Dwarf\ Fortress/ cd ~/.steam/steam/steamapps/common/Dwarf\ Fortress/
docker cp . dfhack-win:/root/df/ docker cp . dfhack-win:df/
Step 4: build and install the cross-compiled DFHack binary Step 4: install DFHack and run DF
---------------------------------------------------------- ---------------------------------
Back in the container, run the following commands:: Back in the container, run the following commands::
mkdir ~/src/dfhack/build_win; cd ~/src/dfhack/build_win cd dfhack/build
. msvcenv-native.sh
wineserver -p
wine64 wineboot
CC=cl CXX=cl cmake .. -GNinja -DCMAKE_INSTALL_PREFIX=~/df -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CROSSCOMPILING=ON -DDFHACK_NATIVE_BUILD_DIR=~/src/dfhack/build
ninja install ninja install
Those wine commands are very important. Each invocation of a windows tool will
cause wine to run in the container. Preloading the wineserver and telling it not
to exit will speed configuration and compilation up considerably (approx. 10x).
You can shut the wineserver down again with ``wineserver -k``.
Step 5: run Dwarf Fortress with DFHack
--------------------------------------
Now that DFHack is built and installed, you can run DF in the container. The commands
we ran earlier will allow container apps to connect to the host Xserver and the Dwarf
Fortress game window will apear on your screen::
cd ~/df cd ~/df
wine64 Dwarf\ Fortress.exe wine64 "Dwarf Fortress.exe"
Other notes Other notes
----------- -----------
@ -839,11 +819,8 @@ host when you want to reattach::
docker start -ai dfhack-win docker start -ai dfhack-win
Make sure you run ``wineserver -p`` and ``wine64 wineboot`` before you start building If you edit code and need to rebuild, run ``dfhack-make`` and then ``ninja install``.
or running DF in the container or risk terrible slowness. That will handle all the wineserver management for you.
If you edit code and need to rebuild, just ``ninja install`` should suffice. You
shouldn't need to source ``msvcenv-native.sh`` or reconfigure cmake from scratch.
Building the documentation Building the documentation
========================== ==========================