Jump to content
XCOMUFO & Xenocide

Compilation Instructions


Serge

Recommended Posts

[size=4][b]Part 1. Getting the latest sources and compiling the game[/b][/size]

Here are some simple instructions how to build win32 binaries of the game and make installer.

First you need a set of tools.

[b]Subversion console client[/b] (needed to download the latest sources of the game):
[url="http://subversion.tigris.org/files/documents/15/24487/svn-1.2.1-setup-2.exe"]http://subversion.tigris.org/files/documen...2.1-setup-2.exe[/url]

[b]Mingw GCC compiler[/b] (the game is compiled using it):
[url="http://prdownloads.sourceforge.net/mingw/MinGW-3.1.0-1.exe?download"]http://prdownloads.sourceforge.net/mingw/M...-1.exe?download[/url]

[b]MSYS[/b] (minimal set of unix tools, it is required when compiling the game):
[url="http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=24963&release_id=89960"]http://sourceforge.net/project/showfiles.p...elease_id=89960[/url]

[b]NSIS installer[/b] (optional, for making installer of the game)
[url="http://sourceforge.net/project/showfiles.php?group_id=22049&package_id=15374"]http://sourceforge.net/project/showfiles.p...ackage_id=15374[/url]

[b]Important:[/b] make sure that you have all these tools registered in your PATH, so that you can run 'svn --version', 'gcc --version', 'make --version' from console. If you are getting 'bad command or file name', something is wrong and needs to be fixed. Also make sure that 'make --version' displays something like [i]GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.[/i], some people had issues with [i]Borland make utility[/i], unfortunately it has the same name but you can't use it for compiling ufo2000.

After you get all these tools installed, you can get the latest sources of the game.
Create some directory "C:\Projects" for example. Then run from a command line:
'svn checkout [url="https://ufo2000.svn.sourceforge.net/svnroot/ufo2000/trunk"]https://ufo2000.svn.sourceforge.net/svnroot/ufo2000/trunk[/url] c:\projects\ufo2000'
You will have the latest sources installed into c:\projects\ufo2000

To successfully compile the game you will also need a set of additional libraries (Allegro, Expat, ...). A good news is that we already have them compiled and packaged. Download [url="http://ufo2000.sourceforge.net/mingw-libs-20111202.zip"]http://ufo2000.sourceforge.net/mingw-libs-20111202.zip[/url] and extract it to ufo2000 sources directory. You will get mingw-libs subdirectory with all the needed libraries ready for use.

The directory structure should look like this:

[code]c:\projects\ufo2000
|->lots of files and folders
|->mingw-libs
|->readme.txt
|->include
|->lib
|->licenses
|->src
|->*.cpp and *.h files[/code]

After that everything is simple. Just run 'make' from ufo2000 sources directory and it will compile ufo2000.exe, run 'make server' to compile ufo2000 game server (ufo2000-srv.exe). Running 'make win32-installer' will build win32 installer of the game (ufo2000-xx.yy.zz.exe, where xx.yy.zz is the version of the game). You need extra package [url="http://ufo2000.sourceforge.net/nsis-plugins.zip"]http://ufo2000.sourceforge.net/nsis-plugins.zip[/url] to make installer. Extract it to the ufo2000 sources directory just like mingw-libs.zip

As people are working on the game, new changes get committed to the repository. Getting these changes to your local copy is simple. Just run 'svn update' in the ufo2000 sources directory to update them to the latest version. Updating the sources is a safe operation, if you made some changes to the sources as well, they will not be lost, in the worst case subversion will detect a conflict and show which of your changes are not compatible with the changes received from the server.

If you have any problems following these instructions, don't hesitate to ask questions [url="http://www.xcomufo.com/forums/index.php?showtopic=3877"]here[/url], these instructions will be updated when needed. Edited by Serge
Link to comment
Share on other sites

  • 2 weeks later...
[size=4][b]Part 2. Taking part in development of UFO2000[/b][/size]

The sources of the game are stored in Subversion repository. Subversion (http://subversion.tigris.org) is a version control system like CVS. In fact, it was developed to be a replacement for CVS and in general it works very similar to CVS but has some important improvements. Using Subversion is very easy for people familiar with CVS as it has the same concept and a similar command line syntax.

Repository is located here: [url="http://ufo2000.svn.sourceforge.net/viewvc/ufo2000/trunk/"]http://ufo2000.svn.sourceforge.net/viewvc/ufo2000/trunk/[/url]
You can view the sources online using any web browser. But if you want to do something more serious, you need to install subversion client.

Console subversion client can be downloaded from [url="http://subversion.tigris.org"]http://subversion.tigris.org[/url]
Alternatively you can use GUI Win32 client downloadable from [url="http://tortoisesvn.tigris.org"]http://tortoisesvn.tigris.org[/url]
But it is better to have both console and GUI subversion client installed.

Before making anything, you need to [b]checkout[/b] the sources of the game. It is better to use the latest version from SVN repository for making changes to the game, it can already contain some changes and fixes that were added after releasing a stable version.

Checking out the sources using console client is performed using the following command:
'svn co [url="https://ufo2000.svn.sourceforge.net/svnroot/ufo2000/trunk/"]https://ufo2000.svn.sourceforge.net/svnroot/ufo2000/trunk/[/url] ufo2000'

After this step, you will have a working copy of the latest sources of the game on your computer. You can keep it up to date using [b]update[/b] command. Just run 'svn up' from the directory with your working copy.

You can always get a log of all the changes made to the sources using [b]log[/b] command. Run 'svn log --verbose [url="https://ufo2000.svn.sourceforge.net/svnroot/ufo2000/trunk/"]https://ufo2000.svn.sourceforge.net/svnroot/ufo2000/trunk/[/url] to get the list of changes. Also, every change in ufo2000 sources repository generates e-mail notification which is sent to the [url="https://lists.sourceforge.net/lists/listinfo/ufo2000-svn"]ufo2000 svn commit notifications mailing list[/url].

Well, I have already explained how to get the latest sources of the game and keep them up to date. Now it is time to explain how to help in the development of the game.

After you make some changes to your working copy, test it and ensure that it compiles and works as expected, you may want to share your changes with the others and add them to the repository. Developers with write access to the repository can execute [b]commit[/b] command to do this. All the others can make patch and send it to someone who has write access (or to the mailing list). To make a patch, you can run 'svn diff > mycoolpatch.diff' from the command line in your working copy. This will create mycoolpatch.diff file which will contain all the changes you made to the sources in text format. This patch can be applied to the sources to get your changes in.

Here is an example of a patch file (for those who do not know how it looks):

[code]Index: src/main.cpp
===================================================================
--- src/main.cpp (revision 1092)
+++ src/main.cpp (working copy)
@@ -526,6 +526,25 @@
*allegro_errno = 0;
}

+static int find_files_callback(const char *filename, int attrib, void *param)
+{
+ std::set<std::string> *files = (std::set<std::string> *)param;
+ files->insert(filename);
+ // $$$ Fixme: lua_dofile sets errno variable in some mysterious way,
+ // so allegro for_each_file function stops searching files if we do not
+ // reset this back to 0
+ *allegro_errno = 0;
+ return 0;
+}
+
+static int find_files(const char *dir, const char *searchmask, std::set<std::string> &files)
+{
+ char tmp[1024];
+ append_filename(tmp, dir, searchmask, sizeof(tmp));
+ for_each_file_ex(tmp, 0, 0, find_files_callback, &files);
+ return 1;
+}
+
static std::map<std::string, double> g_extensions_loading_time;

void find_dir_callback(const char *filename, int attrib, int param)
@@ -539,9 +558,14 @@
lua_pushstring(L, filename);
lua_settable(L, LUA_GLOBALSINDEX);

- char tmp[1024];
- sprintf(tmp, "%s/*.lua", filename);
- for_each_file(tmp, FA_RDONLY | FA_ARCH, find_lua_files_callback, 0);
+ std::set<std::string> files;
+ std::set<std::string>::iterator it;
+ find_files(filename, "*.lua", files);
+
+ for (it = files.begin(); it != files.end(); ++it) {
+ lua_safe_dofile(L, it->c_str(), "plugins_sandbox");
+ }
+
clock_t after = clock();
g_extensions_loading_time[filename] = (double)(after - before) / (double)CLOCKS_PER_SEC;
}[/code]

Restricting write access to the repository is only done for safety reasons. After you send a few patches and they prove to be usable, you will get write access to the repository, that's not a problem :)

One more note: the best way to review the changes you made to the sources is to use GUI subversion client configured to use external visual diff utility. I would recommend to use WinMerge: [url="http://winmerge.sourceforge.net"]http://winmerge.sourceforge.net[/url]

If you have any problems following these instructions, don't hesitate to ask questions [url="http://www.xcomufo.com/forums/index.php?showtopic=3877"]here[/url], these instructions will be updated when needed. Edited by Serge
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...