From 6ffdeda712da7b49588b34b15b6391dbbd326612 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 9 Dec 2022 05:04:10 -0800 Subject: [PATCH] adapt cross compiling guide to buildmaster image --- docs/dev/Compile.rst | 75 +++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 49 deletions(-) diff --git a/docs/dev/Compile.rst b/docs/dev/Compile.rst index 333f03930..0c804e0c2 100644 --- a/docs/dev/Compile.rst +++ b/docs/dev/Compile.rst @@ -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:: xhost set +local:root - git clone git@github.com:mstorsjo/msvc-wine.git - cd msvc-wine + git clone https://github.com/BenLubar/build-env.git + cd build-env docker build . docker image ls 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 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 container. Inside the container, run the following commands:: - apt-get update; apt-get upgrade -y - 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 - echo 'export BIN=/opt/msvc/bin/x64' >>~/.bashrc - echo 'PATH=/opt/msvc:$BIN:$HOME/bin/cmake/bin:$PATH' >>~/.bashrc - . ~/.bashrc - mkdir ~/src; cd ~/src - git clone https://gitlab.kitware.com/mstorsjo/cmake.git - cd cmake; git checkout 844ccd2280d11ada286d0e2547c0fa5ff22bd4db - mkdir build; cd build - ../configure --prefix=~/bin/cmake --parallel=$(nproc) -- -DBUILD_CursesDialog=ON - make -j$(nproc) - make install - cd ~/src - git clone https://github.com/ab9rf/dfhack.git - cd dfhack; git submodule init; git submodule update - cd build; cmake .. -GNinja - ninja protoc + ccache -C + export CCACHE_BASEDIR=/home/buildmaster/.ccache + git clone https://github.com/DFHack/dfhack.git + cd dfhack + git submodule update --init + cd build + dfhack-configure windows 64 Release + dfhack-make + +Inside the ``dfhack-*`` scripts there are several commands that set up the wine +server. 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 configure and build DFHack +with regular ``cmake`` and ``ninja`` commands, but your build will go much slower. 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:: 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:: - mkdir ~/src/dfhack/build_win; cd ~/src/dfhack/build_win - . 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 + cd dfhack/build 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 - wine64 Dwarf\ Fortress.exe + wine64 "Dwarf Fortress.exe" Other notes ----------- @@ -839,11 +819,8 @@ host when you want to reattach:: docker start -ai dfhack-win -Make sure you run ``wineserver -p`` and ``wine64 wineboot`` before you start building -or running DF in the container or risk terrible slowness. - -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. +If you edit code and need to rebuild, run ``dfhack-make`` and then ``ninja install``. +That will handle all the wineserver management for you. Building the documentation ==========================