This text explains how you get and compile the Cafu source code.
Most steps that are explained below are only necessary once, when you get and compile the Cafu source code for the first time.
This section explains how you obtain the Cafu source code by checking it out from its Git repository.
Git is a version control system that allows the Cafu developers to work on their copy of the source code independently of each other, and to distribute the latest version of the source code to other developers at any time. Moreover, many developers prefer to manage their project independently in their own version control system, but also wish to integrate the latest changes (e.g. bug-fixes and new features) from the official Cafu repository into theirs from time to time: Git makes the synchronization of the projects code with the original Cafu source code as convenient and automatic as possible. If you don't know Git yet, have a look at the Git website and the Git documentation. The “Pro Git” book is very well written and available for free in several languages.
For Windows and many other systems, you can get Git from the Git downloads page. Popular Git clients with a graphical user interface are available at the Git downloads page as well.
With most Linux distributions, installing Git via the systems package manager is usually preferred. For example, under Ubuntu:
> sudo apt-get install git gitk
Then check out the source code at the command-line under Windows or Linux with this command:
> git clone --recursive https://bitbucket.org/cafu/cafu.git Cafu
--recursive option in the command above: it makes sure that submodules are automatically checked out as well. As we keep the texture images for the DeathMatch example game in a submodule, it is convenient to have them checked out along with the main repository. Be prepared though that this adds approximately 180 MiB to the download volume.
Our Git project page is https://bitbucket.org/cafu/cafu, where you can browse the repository online, create forks, post pull requests, and find additional help about Git.
Cafu uses SCons as its software build system on all supported platforms.
SCons is a modern replacement for
SCons requires the Python scripting language to be installed,
so that you have to get and install both Python and SCons on your computer.
If in doubt, pick the Windows installers for both Python 2.7 and SCons 2.3: they are easy to use, lightweight, and automatically setup the proper environment variables.
That is normally all, but you may wish to check if the Python installer added Python's
Scripts directory to the
PATH environment variable of your system.
For example, if Python was installed in
PATH should contain both
Otherwise, you have to add the proper directories manually: See http://support.microsoft.com/kb/310519 and http://vlaurie.com/computers2/Articles/environment.htm for additional information.
In order to verify that everything is working correctly, open a new command prompt and enter
> scons -v SCons by Steven Knight et al.: script: v2.3.0, 2013/03/03 09:48:35, by garyo on reepicheep engine: v2.3.0, 2013/03/03 09:48:35, by garyo on reepicheep engine path: ['C:\\Python27\\Scripts\\..\\Lib\\site-packages\\scons-2.3.0\\SCons'] Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation
The report of the SCons version indicates that both Python and SCons are ready for use. Please make sure that you use SCons version 2.3 or newer, older versions don't work!
Under Linux, just use the systems package manager in order to install SCons. The package manager will automatically install SCons and all software that SCons depends on, such as Python. For example, under Ubuntu:
> sudo apt-get install scons
Additional software packages must be installed on a Linux system before the Cafu source code can be compiled.
On a fresh, newly installed Debian or Ubuntu system, you'll need the following packages.
They can be installed at the command prompt with the
apt-get install command, or via the easy to use “Synaptic Package Manager”.
Similar packages and package managers also exist on RedHat Linux, SuSE, etc., where you can proceed analogously.
Make sure that when you're done, all packages from the list and their dependencies are installed on your Linux system.
Cafu can be compiled as 32-bit and 64-bit software on all platforms. The following compilers are supported:
| Visual C++ 2015|
Visual C++ 2013
Visual C++ 2012
Visual C++ 2010
|You can use the free Express Editions with Cafu. They are available at http://www.microsoft.com/express/vc/ and automatically install the related Microsoft Windows SDK.|
|GCC 4.4+||The GNU Compiler Collection with its C++ front-end, version 4.4 or any newer version.|
The Cafu-specific compiler setup is fully automatic: No action is required in this step, and you can directly proceed to the next.
Optionally, if you want to change the default settings now or later, here is an overview of how it works:
Cafu/CompilerSetup.pyalready exists. If it doesn't (e.g. when you do this for the first time), it automatically creates the file as a copy of
Cafu/CompilerSetup.pymanually. This is only required once, and only if you want to edit
Cafu/CompilerSetup.pybefore SCons is run for the first time.
Cafu/CompilerSetup.pyin order to set the compiler and tools that are used to build Cafu, and to set the target architecture (such as
x86_64) that it is build for. Each setting is well documented, so you should have no problems to make the desired changes.
If you do this for the first time, we recommend that you don't bother with
Cafu/CompilerSetup.py at all. Just let the automatism determine the settings and come back later if desired or required.
On 64-bit Windows systems, SCons tries to find a 64-bit compiler, but Visual C++ 2010 Express Edition comes with a 32-bit compiler only. To tell SCons to use the 32-bit compiler instead, please edit file
Cafu/CompilerSetup.py as described here.
Even though the Visual C++ 2012 Express Edition comes with a 64-bit compiler, at this time the same edits must be done for it as well.
You are now ready compile the Cafu source code.
At the command prompt, change into the top-level
Cafu directory (where also the files
SConstruct are), then start the compilation with:
When you do this for the first time, be prepared that it will take a while: Everything is being built from scratch, once for the debug and once for the release build. When you repeat the same command in the future, e.g. after source code changes or updates, only the minimum set of files will be rebuilt and the entire process will complete much faster.
Under Linux, if you have a multi-core system, you can speed this up by having several build jobs run in parallel:
> scons -j N
where N is the maximum number of jobs to start simultaneously. For example, try
-j 4 on a quad-core machine.
You may use the time while the build process is running to download some supplemental files. These files are not strictly required, but will help you with trying out the newly compiled programs as described below.
We recommend that you download and extract the following files:
Note that although these files are zip archives, they are for use on all platforms (Windows and Linux). With these files, you can immediately run the Cafu engine and see some example worlds when the compilation has finished.
When the SCons script has finished, all Cafu programs have been built in several variants:
debugvariant contains additional program information and no code optimizations, and is often used during development and for finding and fixing bugs.
releasevariant has program optimizations enabled in order to maximize the execution speed and contains no debug information. This variant is usually shipped to end users.
profilevariant is not built by default. It is similar to the
releasevariant, but also has debug information in order to make it suitable for use with a performance profiler.
As all variants can be built for each compiler on each platform, the build process organizes the binaries in a directory hierarchy of the form
That is, if your compiler is Visual C++ 2015 (abbreviated as
vc14) and your platform is Windows (abbreviated as
win32), and you want to run the release variant of the new programs, then the related binaries are relative to the path
Another important consideration is that all programs assume the top-level
Cafu directory as their working directory.
Combining these facts provides you with several options on how you can run the new programs:
Cafu/build/$platform/$compiler/$variant/…directly into the
Cafudirectory. This is what we do for the prepackaged binary releases, as end-users can then simply and directly double-click each executable in the Windows Explorer.
.lnk) or batch (
.bat) file in the proper working directory that calls the desired program in its original location.
Cafu, then type the relative path to the desired program (TAB completion – also on Windows – proves to be a great help here!).
Running the release version of Cafu under Linux looks like this:
If you have downloaded the binary assets as instructed above, you can now run your self-compiled Cafu engine
build\win32\vc14\release\Ca3DE\Cafu.exe and try one of the included demo levels!
Congratulations! When you get here, you have managed to successfully compile the Cafu source code and run the resulting binaries. You may now wish to familiarize yourself more completely with the world of Cafu.
One way to do this is to approach Cafu from a map designers perspective, for example by exploring the Cafu World Editor CaWE. CaWE is not only a map editor, it also contains the GUI editor, a font conversion tool, a materials viewer and a model editor. CaWE can also act as a bridge towards scripting: map scripting, GUI scripting, materials scripting and vegetation scripting are powerful features in Cafu, and it doesn't stop there!
Programmers should definitively have a look at the other sections in this chapter (At the Core: The Cafu Source Code), such as IDEs and Text Editors or Starting your own Game. If instead you prefer to dig into the source code right away – just pick your favorite piece of code, and start reading and hacking.
Consider Using the Autodesk FBX SDK in order to add support for several additional file formats in the Model Editor.
Or you just browse the files and folders in the
Cafu directory, and start with whatever you feel most attracted to.
In any case, if you have questions or comments, or if you need help, post a message at the support forums at any time!