Building spring: Difference between revisions
updated python and scons links (newer versions) |
Auswaschbar (talk | contribs) svn -> git |
||
| Line 13: | Line 13: | ||
== Keep track what others do == | == Keep track what others do == | ||
If you develop with others, you need to know what they do. | If you develop with others, you need to know what they do. You can browse the source [http://github.com/spring/spring/tree/master at our github-page], and there is a [http://github.com/feeds/spring/commits/spring/master commit neewsfeed]. | ||
===Source Code Documentation=== | ===Source Code Documentation=== | ||
| Line 22: | Line 22: | ||
==Obtaining the Source== | ==Obtaining the Source== | ||
Our GIT repository can be cloned from git://github.com/spring/spring.git. | |||
Another option is to manually [http://spring.clan-sy.com/download.php download] it along with the latest released version of the game. However, for serious developers, a better way would be to download the source straight from the | Another option is to manually [http://spring.clan-sy.com/download.php download] it along with the latest released version of the game. However, for serious developers, a better way would be to download the source straight from the GIT repository. This will also allow you to make a patch out of the changes you make to the code, and send it to one of the developers with repository access. | ||
Assuming the GIT-commandline client is installed, you can clone the repository with | |||
<code>git clone git://github.com/spring/spring.git</code> | |||
and update it with | |||
<code>git pull</code> | |||
==Learning C++== | ==Learning C++== | ||
| Line 223: | Line 206: | ||
* [http://sourceforge.net/projects/springrts SourceForge project page (OLD)] | * [http://sourceforge.net/projects/springrts SourceForge project page (OLD)] | ||
* [http://buildbot.no-ip.org/~buildbot/spring/stacktraceTranslator.php StackTrace Translator] | * [http://buildbot.no-ip.org/~buildbot/spring/stacktraceTranslator.php StackTrace Translator] | ||
* [https://spring.clan-sy.com/svn/spring/trunk/ Subversion repository] | * [https://spring.clan-sy.com/svn/spring/trunk/ Old Subversion repository] | ||
* [http://spring.clan-sy.com/dl/docs/unitsync/group__unitsync__api.html Unitsync API docs] | * [http://spring.clan-sy.com/dl/docs/unitsync/group__unitsync__api.html Unitsync API docs] | ||
[[Category:Development]] [[Category:Source development]] | [[Category:Development]] [[Category:Source development]] | ||
Revision as of 11:26, 30 December 2008
NOTE: Outlined below is information on assisting with the development of the Spring source itself. For information about developing a mod (units, widgets, maps, etc.) see the Mod_and_Unit_development page.
Even if you are developing a mod, it is highly recommended that you get the engine source. Engine source + full text search: DO IT.
Below you can find information on how to work with the Spring source in the current mainline (Windows platform) if you like to work on another platform (Linux & Mac) please look at the bottem of this page under "Multiplatform development"
Starting Development
To start development, you will need
- To read the Coding_Standards
- The latest version of the source
- A good code manipulation program
- Compiling your modified source
Keep track what others do
If you develop with others, you need to know what they do. You can browse the source at our github-page, and there is a commit neewsfeed.
Source Code Documentation
A good place to start is the source code documentation.
An explanation on how the code is executed in game can be found in the Spring Engine Code page.
Obtaining the Source
Our GIT repository can be cloned from git://github.com/spring/spring.git.
Another option is to manually download it along with the latest released version of the game. However, for serious developers, a better way would be to download the source straight from the GIT repository. This will also allow you to make a patch out of the changes you make to the code, and send it to one of the developers with repository access.
Assuming the GIT-commandline client is installed, you can clone the repository with
git clone git://github.com/spring/spring.git
and update it with
git pull
Learning C++
You will need to know C++ to modify or understand Spring's source code. If you are interested in learning C++, see Learning_CPP
However please note that badly designed code (code created by a C++ novice for example), even if working will likely not be included in the spring code. Spring is a large project, and therefore it is necessary to stay away from hack jobs and create general solutions to problems.
Setting up your development environment
You have either to use the SCons build system that is multi platform, or use Microsoft Visual Studio for building spring. See also Development_IDEs for some more background information about the IDE to choose.
Visual Studio 8 (2005)
(possibly the free Express Edition)
- Install the vclibs library package. You need to install this in the /spring directory from the SVN checkout or the zipped source. If done right, it will look like:
- /spring/
- /spring/installer
- /spring/rts
- /spring/... other dirs
- /spring/vclibs
- Install the DirectX SDK
- Install the PlatformSDK. I got away with unchecking the parts of the PlatformSDK that were obviously not related (IIS, web stuff). Makes for a smaller download. Make sure the Platform SDK and DirectX SDK are in the VS search/include directories:
- After installing them, open Visual C++. Click Tools >> Options >> Projects and Solutions >> VC++ Directories. Add these entries to the corresponding sections (paths just a reference, yours may be different):
- Include files:
- $(ProgramFiles)\Microsoft DirectX SDK (August 2007)\Include
- $(ProgramFiles)\Microsoft Platform SDK\include
- Library files:
- $(ProgramFiles)\Microsoft DirectX SDK (August 2007)\Lib\x86 (Might need \x64 on a 64-bit platform, I don't know.)
- $(ProgramFiles)\Microsoft Platform SDK\lib
- Include files:
- Open the solution. /spring/rts/build/vstudio8/rts.sln
- Start building (usually you want to select the release/no debug build, debug is really too slow and is used only when you really know what you want to test)
- Select the working directory in the project properties, otherwise spring will not work correctly
Visual Studio 9 (2008)
(possibly the free Express Edition)
Not yet fully working as far as I know; you need at least this hotfix from Microsoft though:
http://support.microsoft.com/kb/946040
For the rest the Visual Studio 8 instructions should apply, mostly.
SCONS/MinGW
Code::Blocks and Dev C++ use MinGW too, so if you are using one of these IDEs, you'll want to follow these instructions too.
Getting the compiler
Compiling in MinGW requires GCC 4.x which is only available in experimental builds. TDM's experimental MinGW
Previous versions of this document suggested using Dev-C++ or Code::Blocks for their included MinGW. They both come with MinGW 3.4 which no longer compiles a fully working Spring.exe. If you want to use Dev-C++ or Codeblocks, you can install the experimental MinGW build over the one that's included.
Get at least the following packages:
- mingw-runtime
- core
- c++
- java (if MinGW 4.3.1 is out yet, you dont need this)
- binutils
- win32api
Use v12 of the MinGW library package if you have MinGW 4.
Compiling spring
Make sure you install the MinGW library package in the checkout directory, so the path is: /spring/mingwlibs. If done right, it will look like:
- /spring/
- /spring/installer
- /spring/rts
- /spring/... other dirs
- /spring/mingwlibs
These programs are a must have if you want to compile Spring with MinGW, so install them now, if you don't have them already.
- Python 2.5 installer
- Python 2.5 win32 extensions installer
- Scons 1.1.0 installer
- CMake 2.6 installer
Oh, and quick instructions:
- Grab and install the above programs.
- Make sure C:\Python25, C:\Python25\Scripts and C:\Dev-Cpp\bin are in your PATH environment variable. Set environment variables by: Start -> Settings -> Control Panel -> System -> Advanced -> Environment variables (for Windows XP).
- Make sure a MINGDIR environment variable with value C:\Dev-Cpp exists. (change paths where appropriate.)
- Checkout the Spring SVN repository, following the instructions above in obtaining source. (TODO:link)
- Open a console (Start -> Run -> cmd.exe -> Run), cd \where you checked it out in the previous step, if you checked it out on a different drive make sure to change drives with DriveLetter:<enter> first.
- Type scons configure<enter>. Refer to scons --help for options which can be passed to scons configure. Gotchas:
- If you get an error message starting with "EOFError: : env = Environement...", try deleting the file build/scons_signatures.dblite
- If you get an error message stating "ImportError: No module named win32file:", you have probably not installed the python-win32-extensions.
- If all proceeds as intended you will see a message similar to: "Everything seems OK. Run `scons' now to build."
- Type scons<enter> to start the compilation.
- If you have Delphi installed and get an error message that the commandline params "--no-print-directory" & "-C" aren't supported, then you should remove the Delphi dirs from your PATH variable, because scons tried to run the delphi's make.exe instead of using mingw32-make. (this will cause that streflop can't be build!)
- Wait for the compilation to finish, this may take a while.
- Copy datafiles and stuff from official Spring installation to the /spring/game directory (where spring.exe is located, after the compilation finished.)
- Copy missing DLLs from mingwlibs/dll.
- Start developing.
If you are using Linux, refer to the SetupGuide to build Spring and get it running.
CMake/GCC
Currently the CMake scripts are not capable of generating Visual Studio project files, so CMake can only be used for gcc compiling.
- Install CMake (must be at least version 2.6.0) from either www.cmake.org or through your distributions package manager
- get the source code (from svn, tarballs...)
The GUI method
CMake offers a nice Qt4 gui to ease the following steps (to use the gui explained here, cmake must be at least version 2.6.1). Doing so should be straightforward:
- select source directory
- select (and/or create) build directory where temporary files are stored
- hit configure button
- choose your build type:
- Unix makefile if you are using linux and want to compile linux executables
- mingw makefiles if you are working on windows
- Unix makefile with cross compiler setup to cross-compile mingw32 executables, you have to select the toolchain file you want to use (see below)
- configure variables to your need (move the mouse over the options and read the tooltip for further informations on them and or see Section "Options")
- push generate button
- open commandline and do "make" and "make install"
The commandline method
Only works with the linux version of cmake, and is easiely scriptable.
- cd to (and/or create) build directory where temporary files are stored
- "cmake <path to source tree> <options>" where:
- <path to source tree> is the path to the spring source directory
- <options> are defined like "-D<option name>=<value>
- depending on your settings you may need to run "cmake ..." twice
- run "make" and "make install"
- PACKAGE MAINTAINERS:
- doing "make install DESTDIR=/some/path" will install spring in the specified place, putting files in subdirectories like configured. This may be helpfull when making packages so spring don'T get installed on your system for real (see also CMake FAQ [[1]]).
- You need to update the mime database (update-mime-database) and the kde database (kbuildsycoca) after installing to make the system aware of the newly installed mime types and desktop shortcuts.
Some Options Explained
- MINGWLIBS: directory where the v12 of the MinGW library package is (only needed when compiling with mingw)
- CMAKE_BUILD_TYPE: either RELEASE, DEBUG, DEBUG2, DEBUG3 which compiler options to use
- CMAKE_INSTALL_PREFIX: installation prefix (defaults to /usr/local) defines the base directory for installing
- DATADIR, LIBDIR, BINDIR: where to install data, libraries or binaries (relative paths are based on CMAKE_INSTALL_PREFIX, absolute paths are absolute (DESTDIR is still respected))
- APPLICATIONS_DIR, MIME_DIR, PIXMAPS_DIR: where to install freedesktop-files (icons, mime-types and application-description)
The toolchain file
An example should be self-explainatory:
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i686-mingw32-gcc)
SET(CMAKE_CXX_COMPILER i686-mingw32-g++)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i686-mingw32)
SET(MINGWLIBS /home/karl/spring/mingwlibs_v12)
Pass this with "-DCMAKE_TOOLCHAIN_FILE=/your/toolchain/file" to cmake or select it in the gui to make a cross-compilation.
Further reference
Development Suggestions
Before starting to make modifications to the source, take a look at the development guidelines which outlines some important things to think about. To find something interesting to work on, look at SpringEngineTODO. You can also check the list of whois doing what to see what others are doing. If you do edit the code, please add Doxygen style comments to the code, which will then enhance the source code documentation.
How to get your code included
If you create something that you think should be included in the official source tree, you can report a "bug" in mantis, our BTS. Add your patch as attachment, and put "[patch]" in front of the subject, so it is easy for us to separate patches from bugs.
It's also considered standard practice to post one's modifications in the development forum and get feedback.
Spring Engine TODO list
There is a TODO list for developers who want to contribute to the engine itself: SpringEngineTODO. There is also a feature request forum, which may give you some ideas. Don't be overwhelmed by the sheer number of (silly) requests though!
Development links
- Automatic installer builds (crosscompiled, mingw)
- Spring base content files
- BerliOS project page (OLD)
- Bug Tracking System
- Buildbot
- Commit mailing list
- Development libraries for Visual Studio 2005
- Development libraries for MinGW
- SourceForge project page (OLD)
- StackTrace Translator
- Old Subversion repository
- Unitsync API docs