Difference between revisions of "CompilingWesnoth/fr"

From The Battle for Wesnoth Wiki
(Compiler Wesnoth)
m (Compiler Wesnoth)
Line 11: Line 11:
 
*[[CompilingWesnothOnSyllable|Compiler Wesnoth sur Syllable]] (en)
 
*[[CompilingWesnothOnSyllable|Compiler Wesnoth sur Syllable]] (en)
 
*[[CompilingWesnothOnSuSE|Compiler Wesnoth sur SuSE]] (en) -Pour installer sur SuSE 10.0
 
*[[CompilingWesnothOnSuSE|Compiler Wesnoth sur SuSE]] (en) -Pour installer sur SuSE 10.0
 
Forcemstr<sup>ref ?</sup> peut être utilisé pour "compiler en croisé", c'est à dire produire un executable pour Windows tout en restant sur Linux grâce au logiciel gratuit [http://www.mingw.org/ mingw32].
 
  
 
Pour plus de détails, voir le fichier [https://github.com/wesnoth/wesnoth/blob/master/INSTALL.md INSTALL] dans le code source.
 
Pour plus de détails, voir le fichier [https://github.com/wesnoth/wesnoth/blob/master/INSTALL.md INSTALL] dans le code source.

Revision as of 12:05, 8 September 2019

[edit]Compiling Wesnoth

Platforms

Compiler Wesnoth

Cette page présente comment compiler le jeu dans un environnement UNIX. Les moteurs de productions utilisés sont scons et cmake.

Voir aussi:

Pour plus de détails, voir le fichier INSTALL dans le code source.

Pré-requis

Avant tout, assurez-vous d'avoir un compilateur C++ tel que gcc .

Pour compiler Wesnoth 1.14, les bibliothèques suivantes doivent être installé sur votre système. Beaucoup de distributions Linux séparent les paquets de développement des bibliothèques. Si c'est le cas pour votre distribution, vous devez choisir le paquet development (ce dernier comprend les fichiers d'entêtes headers requis pour compiler). Vous aurez aussi besoin des paquets runtime pour lancer Wesnoth.

Ces bibliothèques sont facultatives:

Pré-requis supplémentaires pour version dev

À partir de Wesnoth 1.15, les pré-requis suivants ont été ajoutés:

  • Compilateur pour C++14 (GCC 5.0/Clang 3.8 ou plus)
  • libboost >= 1.56.0
  • sdl-ttf n'est plus requis

Moteurs de productions

Pour pouvoir produire des fichiers binaires (exécutables), vous aurez besoin d'un moteur de production. Vous pouvez utiliser soit:

ou soit:

Linux Tips to Easily Gather Dependencies

On all Linux distributions that are based on Debian (like e.g. Ubuntu, Linux Mint) it may be enough to use these commands if your distribution ships a recent version of Wesnoth. (However dependencies might be outdated for building the Development version or building Stable versions newer than are shipped with your distribution. In those case you will need to install the additional dependencies by hand after running the following commands):

sudo apt build-dep wesnoth-1.12
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libboost-all-dev libvorbis-dev libcairo2-dev libpango1.0-dev libssl-dev libreadline-dev cmake make scons pkgconf

For testing purposes wesnoth uses Docker images, you can also have a look at which packages are installed by them here. (Though note that your system may use different version numbers.)

The following command will install the prerequisites for Wesnoth 1.14 in openSuSE. All dependencies are in the standard OSS repository.

sudo zypper install libSDL2-devel libSDL2_image-devel libSDL2_mixer-devel libSDL2_ttf-devel boost-devel libopenssl-devel libbz2-devel zlib-devel libvorbis-devel pango-devel cairo-devel fontconfig-devel dbus-1-devel readline-devel fribidi-devel gettext-runtime cmake make scons pkg-config

The following command will install the prerequisites for Wesnoth 1.14 in CentOS, RedHat or Fedora. All dependencies are in the standard OSS repository. You may use yum instead of dnf

sudo dnf install SDL2-devel SDL2_image-devel SDL2_mixer-devel SDL2_ttf-devel boost-devel openssl-devel bzip2-devel zlib-devel libvorbis-devel pango-devel cairo-devel fontconfig-devel dbus-devel readline-devel fribidi-devel gettext cmake make scons pkgconf-pkg-config

This command installs the prerequisites for Wesnoth 1.14 in Arch Linux.

sudo pacman -S sdl2 sdl2_image sdl2_mixer sdl2_ttf boost-libs openssl bzip2 zlib libvorbis pango cairo fontconfig dbus readline fribidi boost gettext cmake make scons pkgconf

Source Code

You can get it here:

Compiling

Our future choice of build system is not yet final -- SCons and CMake are both in contention -- but for the moment both build systems (SCons and CMake) should in general work.

scons is a better choice for beginners, because it requires less configuration and it is more widely used and tested. cmake is used primarily for making certain releases, and is not as well tested.

If any config checks fail, look in the respective log files (eg in build/config.log when using scons) for details. When using scons, a check can spuriously fail due to caching. If this happens, please use --config=force to force its rerun.

Building with SCons

To build using SCons, simply type

$ scons 

in the Wesnoth top-level directory. This will perform the equivalent of "configure --enable-editor --enable-tools; make" under autotools, buiding all client-side tools. To find out more about build options, type

$ scons --help

Equivalents of many configure options will be available, and you can easily build individual targets such as wesnothd.

Because scons checks for out-of-dateness with MD5 checksums of a target's ancestors and its build environment (including compiler and linker flags), the "make clean" and "make uninstall" preliminaries that you need for safety under autotools won't be necessary.


Tips

Good options to use with scons are

  • ctool=clang
This uses clang instead of gcc, which is empirically significantly faster (about 2x)
  • ccache=true
Enables ccache.
If you have ccache available on your system, and you are using git, then this is highly recommended, it can enable you to switch branches and rebuild in minutes.
  • build=release vs. build=debug
Determines whether you build with -O3 optimizations, or -O0 with debugging symbols.
Keep in mind this preference, like the others mentioned, are "sticky" and will be remembered in the future.
  • -j 2, or --jobs 4, etc.
Build parallelism: This tells scons to run multiple compilation steps in parallel. The number of jobs you tell it to run at once should not be larger than the number of cores that you have.

Building with CMake

CMake supports so called "out of tree" builds. That is you compile in a place completely different from the folder where your checkout is in. To do so, simply create a folder to compile in and call cmake with the path to your checkout. Of course you can also just call cmake from the checkout folder with a plain cmake ., but this is boring, isn't it?

To have cmake build wesnoth in a new dir called cmake_build_dir, just use these commands (PATH/TO/WESNOTH/TOPLEVEL-DIR means the base of your repository checkout or the folder where you extracted the tarball to, not src/ in there!):

$ mkdir cmake_build_dir
$ cd cmake_build_dir
$ cmake PATH/TO/WESNOTH/TOPLEVEL-DIR

This will perform the equivalent of "configure --enable-editor --enable-server" under autotools. To get an interface for editing settings, just type

$ ccmake .

in the cmake_build_dir. When done with your changes hit 'c' to configure and 'g' to generate the files and exit. In general you can either add commands to your cmake PATH/TO/WESNOTH/TOPLEVEL-DIR call, or change the parameters later on via ccmake or a cmake gui. Equivalents of many configure options are be available.

In the 2nd step you just have to build the game. This is done as with autotools using

$ make

This by default builds all the targets you activated. If you want to you can also just build specific targets like wesnothd.

Because CMake checks for out-of-dateness, the "make clean" and "make uninstall" preliminaries that you need for safety under autotools won't be necessary.

Install / Uninstall

Become superuser, so that you have permission to install or uninstall.

$ su
  Password: /*doesn't show*/

Now that you have permission, proceed

Using SCons

If you are using SCons, install with:

# scons install

And uninstall with:

# scons uninstall

Using CMake

If you are using CMake, installing basically happens the same way as when using autotools. When authorized as admin (see above), just type this:

# make install

Running the game without installing

After compiling it is also possible to just run the game without installing it. All you have to do is execute the compiled binary and provide the path to the data location as argument. This looks e.g. like this:

$ ./wesnoth

or, if you compiled outside the place where you have your repository checkout or the extracted tarball (lets assume this content lies in ../wesnoth-1.14):

$ ./wesnoth ../wesnoth-1.14/

See also