Tremulous Forum
Mods => Modding Center => Topic started by: Syntac on August 29, 2008, 01:46:10 pm
-
I thought I'd write a guide for people who want to get started developing Tremulous and first need to be shown around a little. It would have been helpful to me, perhaps it'll be helpful to someone else. Contributions are welcome.
Note: This guide is for recent SVN. Some experience with software development and the programming language C is also useful.
Prerequisites
The first thing you need is a development environment, Subversion, and, of course, some source code.
[Instructions for Mac users (http://tremulous.net/forum/index.php?topic=5007.0)]
[Instructions for Windows users (http://tremulous.net/forum/index.php?topic=3408.0)]
(Note to Linux users: Most distros come with the relevant developer tools; if you don't have them installed, utilize your friendly neighborhood package manager. You will need to manually install Subversion from here (http://subversion.tigris.org/).)
The source directory
The directory with your source code should look something like this:
CC
ChangeLog
configs/
COPYING
cross-make-mingw.sh
GPL
make-macosx-ub.sh
Makefile
misc/
src/
ui/
CC, COPYING, GPL: Licensing information. Not useful to newbies.
ChangeLog: A history of Tremulous's evolution from version to version. Again, not useful to newbies.
configs/: Config files required by QVMs and clients built from recent SVN.
cross-make-mingw.sh: A shell script for Mac and Linux users. It builds Windows binaries in addition to the usual ones. (Note: Requires MinGW.)
make-macosx-ub.sh: A shell script for Mac users. This builds the application bundle and a number of binaries.
Makefile: The file that tells the compiler what to compile and where to put the result(s). Don't fiddle around with this unless you know what you're doing.
misc/: Miscellaneous stuff, including the source files for the miniprograms that actually do the QVM compiling. Again, not to be diddled with.
src/: The real meat of the Tremulous code. Juicy! (But not very easy to figure out.)
ui/: Files related to Tremulous's user interface.
The source code
src/ contains a truckload of source files. cgame/, game/, and ui/ are relevant to their respective QVMs (cgame.qvm, game.qvm, and ui.qvm). I recommend starting with game/, since almost anyone can write a decent game.qvm.
Backporting
Of course, most of the Tremulous world is still using old code, which is not very compatible with the current code. This is where backporting comes into play. It's what it sounds like: Porting in a backwards direction.
So how do you backport, exactly? Well, the recommend way is to use a premade patch (such as this (http://betaserv.tk/hacks/compat) one by Avenger; it works like a charm). Which brings us to...
Patching
Patches, put simply, contain the differences between two versions of source code. To patch Tremulous source code, cd to your source directory and then run patch -p0 < PATCHFILE (substituting PATCHFILE for the name of the patch).
So, to backport with Avenger's patch:
1] Download the patch and drop it into your source directory.
2] cd there.
3] patch -p0 < compat.patch
4] Your code should now be backported.
You can also make your own patches. Run svn diff > patchname.patch and it should generate one for you.
Mercenaries Guild currently hosts a patch repository. You can browse it here (http://patches.mercenariesguild.net/).
Compiling
Drumroll...
If your development environment works properly, you're ready to compile! Just run make and you should end up with a directory called build/, containing a subdirectory, containing some build products and a lot of files with extensions like .d and .o. Browse around a bit and you'll see some binaries (.x86, .ppc, or .exe) and some QVMs. (Note: Avenger's patch seems to disable all QVMs except game.qvm).
Using the shell scripts
To use the shell scripts for more advanced compilation:
1] cd to your source directory.
2] ./cross-make-mingw.sh or ./make-macosx-ub.sh
Note to Mac users: For maximum compatibility, install all the SDKs that came with your version of Xcode.
Customizing the build process (This section thanks to Amanieu, benmachine, and David.)
Often, you'll want to have the compiler only build a certain item. This is done be creating a text file, Makefile.local, in your source directory.
BUILD_STANDALONE = 0
BUILD_CLIENT = 0
BUILD_CLIENT_SMP = 0
BUILD_SERVER = 0
BUILD_GAME_SO = 0
BUILD_GAME_QVM = 1
This would configure the build process so only QVMs are compiled. Note: BUILD_CLIENT_SMP (Symmetric MultiProcessing) only has an effect on Mac OS X.
BUILD_MASTER_SERVER = 0
USE_OPENAL_DLOPEN = 0 # 1 on windows.
USE_CURL = 1
USE_CURL_DLOPEN = 1 # 0 on windows.
USE_CODEC_VORBIS = 0
USE_MUMBLE = 1
USE_VOIP = 1
USE_INTERNAL_SPEEX = 1
USE_LOCAL_HEADERS = 1 # SDL related?
You can also add parameters to make.
release — The default.
debug — Creates debug builds instead of release builds. This makes debugging with gdb easier.
clean — Removes all build products.
toolsclean — Removes the mini-compilers that are used to build QVMs. You'll only need to do this if you've been messing around with src/tools.
distclean — Does clean, then toolsclean, then deletes build/.
dist — Bundles up your source in a .tar.bz2 archive. Doesn't compile anything.
Where to go from here
Take a look at the source, learn by example. There's plenty of information to be had if you take the time to read through it.
-
Where'd the original version of this go?
-
I (Bomb) removed it. This is just to make things tidy.
-
Nice guide Bomb, I would love to see it evolve. :D
-
Well, if anyone wants to contribute, be my guest...
-
adding a link to merceneries guild would probably be a good idea. there the central spot for tremulous patches
-
You should just mention svn diff for making patches.
-
@SlackerLinux: Done.
@Amanieu: It's mentioned in Patching.
-
Well Syntac(Bomb), you made it, one of my first +1, you have a really well formed guide, i hope you will kep updating it, i remmeber these old times when i messed up with the admin.c and tremulous.h, so funny :P
-
I think this should be stickied so it doesn't get lost
-
Shh! That makes the moderators laugh.
-
newbie's developing trem? Very funny title
-
Apparently, you didn't read it properly.
The Newbie's Guide to Tremulous Development
In other words, a guide to Tremulous development. Aimed at newbies. In the hope that they will no longer be newbies after reading it.
-
I don't mean to seem abit naive, but is there going to be a linux verison of this guide? Im pretty good at x86 assembly and C, and C++ isnt hard to pick up, but im used to using windows developer tools. How do you compile Trem in linux?
Found my own answer in this post.
http://tremulous.net/forum/index.php?topic=8666.0
-
Everything in the guide applies to Linux as well. If you're having trouble with Subversion, your distro might have a package for it. For example:
sudo apt-get install subversion
...probably.
Note: You'll need to substitute your distro's package manager for apt-get, of course.
-
i'm getting a bunch of compile errors like the code is wrong, is there any setting in the make file i need to change or get a more up to date GCC?
-
If you haven't touched Makefile before, don't. I do recommend updating gcc, though.
-
Ok got the latests version. Thanks for helping me so far, now i got more issues =(
make[2]: Entering directory `/home/stephan/tremulous-svn'
DED_CC src/server/sv_client.c
make[2]: i586-mingw32msvc-gcc: Command not found
make[2]: *** [build/release-mingw32-x86/ded/sv_client.o] Error 127
make[2]: Leaving directory `/home/stephan/tremulous-svn'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/home/stephan/tremulous-svn'
make: *** [release] Error 2
as far as GCC I have this.
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu9)
-
Don't use cross-make-mingw.sh, just exec "make"
-
Don't use cross-make-mingw.sh, just exec "make"
Yeah I just figured that out lol.
You rock man, thanks a bunch id give u good karma but it isnt letting me =)
-
When I CD to tremulous,
and use this command:
patch -p0 < compat.patch
It replies:
'patch' is not recognizable as an internal or external command, operable program or batch file.
(that happends on windows command prompt)
This happends on Mysys:
cd tremulous
patch -p0 < compat.patch
Reply:
No such file or directory.
Help? xP
-
*sigh*
Does compat.patch actually exist?
-
yes it does exist,
I downloaded avengers backport patch, and put it in the source directory, just like the guide said.
windows command promt isnt recognizing patch as a command and mysys is saying that the file or path was not found or does not exist (when i try to patch -p0 < compat.patch
-
cd path/to/source/directory
ls compat.patch
If it finds anything, I don't know what your problem is.
-
Well now im getting this error when compiling..
make[2]: Entering directory `/home/stephan/tremulous-svn'
DED_CC src/server/sv_client.c
make[2]: i586-mingw32msvc-gcc: Command not found
make[2]: *** [build/release-mingw32-x86/ded/sv_client.o] Error 127
make[2]: Leaving directory `/home/stephan/tremulous-svn'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/home/stephan/tremulous-svn'
make: *** [release] Error 2
Im on windows xppro sp3.
And im pretty sure i used just 'make'
-
yes it does exist,
I downloaded avengers backport patch, and put it in the source directory, just like the guide said.
windows command promt isnt recognizing patch as a command and mysys is saying that the file or path was not found or does not exist (when i try to patch -p0 < compat.patch
Try restarting, I had same problem and restart fixed it.
-
Hm..another error, one right after another.
With mysys when i do this..
cd tremulous
patch -p0 < svn_950_to_tjw_s_tremded.patch
it sais..
"cant find file to patch at input line 5. Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
Index: src/game/bg_public.h
--- src/game/bg_public.h (revision 954)
+++ src/game/bg_public.h (working copy)"
Please help..=[
-
make sure you are in the trunk, so that's one above the src/ (go up with "Cd ..")
-
Drakotsu: You couldn't have just used make if it was throwing an "unknown command" error. Type "make" and hit return. That's all you have to do. Don't use the shell script.
-
Read plz syntac.
I said that windows console was throwing unknown cmd.
When i used mysys it gave me that error..and im not using shell commands..
The error in mysys is
"cant find file to patch at input line 5. Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
Index: src/game/bg_public.h
--- src/game/bg_public.h (revision 954)
+++ src/game/bg_public.h (working copy)"
-
Read plz syntac.
make[2]: Entering directory `/home/stephan/tremulous-svn'
DED_CC src/server/sv_client.c
make[2]: i586-mingw32msvc-gcc: Command not found
make[2]: *** [build/release-mingw32-x86/ded/sv_client.o] Error 127
make[2]: Leaving directory `/home/stephan/tremulous-svn'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/home/stephan/tremulous-svn'
make: *** [release] Error 2
"Unknown command" error, no? Next time follow your own advice.
The patch error is because you aren't in the right directory.
-
Follow my own advice?
I copy and pasted that error from another persons post because it was similar.
I think i read what I typed ::).
Well its building just fine now no help from PATHING. My paths were correct.
But now, when i make, the only qvm files it makes are cgame.qvm, any idea why? i need it to make a game.qvm.
Its (mingw) giving me a bunch of errors about g_main.c about expressions with no effect, saying that 1.1.0 is a preprocessing number and not a valid floating constant. Then error 1 and error 2.
Tried again,
Now its giving me a bunch of errors with the g_admin_admins and g_admin_levels and stuff =S
-
Follow my own advice?
I copy and pasted that error from another persons post because it was similar.
I think i fucking read what I typed ::).
Someone who doesn't read what they type is a defective person. What I meant is that you should have read what I posted, which would have revealed that I was in fact answering a different post than the one you assumed I was answering. Clear?
-
Still not compiling right..telling me a whole bunch of symbols are undefined, saying g_admin_bans, and just about all the other commands are undefined..
HELP
-
Did you modify the code before trying to compile it?
-
Hi Drakotsu,
I may have a solution for you. I am also in Windows XP SP3, using MSys and MinGW. Followed Risujin's sweet guide (http://tremulous.net/forum/index.php?topic=3408.0).
I was also experiencing this error:
make[2]: Entering directory `/home/stephan/tremulous-svn'
DED_CC src/server/sv_client.c
make[2]: i586-mingw32msvc-gcc: Command not found
make[2]: *** [build/release-mingw32-x86/ded/sv_client.o] Error 127
make[2]: Leaving directory `/home/stephan/tremulous-svn'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/home/stephan/tremulous-svn'
make: *** [release] Error 2
After searching and so, I realized that:
- MSys was installed in c:\msys\1.0
- MinGW should be installed in c:\msys\1.0\mingw
and not what I thought: c:\msys\mingw
So I moved the MinGW to the correct place, then did a make in Tremulous directory and it compiled smoothly (and faster than I expected :P).
Hope this helps!
-
Did you move everything to /1.0/ or did you only move the mingw folder to /1.0? Im getting another error..Here it is..
Output:
/bin/sh.exe -c: line1: syntax error near unexpected token `;'
/bin/sh.exe: -c: line 1: `for i in ; do echo " $i"; done'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/home/user/tremulous'
make: *** [release] Error 2
Thats the exact error, any idea whats wrong? :s
Im guessing that it has to do with the file sh.exe in the /bin/ folder..but I dont know what the problem it xP.
-
Stop spammin' mah guide. >:(
-
Stop spammin' mah guide. >:(
Sorry Syntac, can a moderator please split all these troubleshooting posts to keep the guide clean?
Drakotsu,
Yes I have everything inside the c:\msys\1.0\ folder. But I am sorry I can't help you more. It was my first time compiling and I'm still very newbie on it.