project-navigation
Personal tools

Author Topic: SConscript sketch  (Read 4845 times)

Offline wrwrwr

  • Rookie
  • ***
  • Posts: 19
    • View Profile
SConscript sketch
« on: January 04, 2009, 04:46:45 pm »
Needed some project to test my little SCons regular expression globbing utility, UFO looked very suitable with it's original directory structure. However once that was finished, I've added a few lines (and then a few lines more ;)) and got a SConscript that can compile game with maps and languages and radiant (without packages/archives/utility targets).

Considering that you already have autoconf scripts, this is probably quite useless -- but who knows maybe it'll help somebody with something -- so I'll share anyway. Part of mingw and mac configuration is dropped, but could be readded if someone is interested; on the other hand it's < 300 lines compared to > 1500 of configure.ac + Makefile.in + *.mk (of course you need SCons (http://scons.org) and Python (http://python.org) to use it).

[attachment deleted by admin]

Offline wrwrwr

  • Rookie
  • ***
  • Posts: 19
    • View Profile
Re: SConscript sketch
« Reply #1 on: January 18, 2009, 09:21:54 pm »
Mhm, great interest  ::)

Here's a small update:
  • proper translations directory structure, so they really work now,
  • radiant plugins compiled before maps too,
  • do not use map for side effects as this wouldn't work with Py3k.

Nevertheless, I've been using this to compile the game and catch a few aliens every once in a while since the original posting, and no file list changes were required as those made in *.mks, so I'm reasonably satisfied with this script (still, platforms other than posix-compliant are possible, but not handled, same goes with cross compilation or archives & package building).

[attachment deleted by admin]
« Last Edit: January 18, 2009, 09:24:05 pm by Wrwrwr »

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: SConscript sketch
« Reply #2 on: January 19, 2009, 06:52:06 am »
i will give it a try - it looks a lot cleaner than what we currently have. problem is, a lot of stuff is missing, too

update-po update-po-radiant pk3

what about make install? how can i define that target dirs?

oh, and also darwin support is missing.

this means all in all, that it's not (yet) useable for ufoai.

wasn't scons the one that was able to create different project files for different ide's?

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: SConscript sketch
« Reply #3 on: January 19, 2009, 06:55:59 am »
« Last Edit: January 19, 2009, 06:58:41 am by Mattn »

Offline wrwrwr

  • Rookie
  • ***
  • Posts: 19
    • View Profile
Re: SConscript sketch
« Reply #4 on: January 22, 2009, 07:11:09 am »
Thanks for spotting the thread. Of course this would need a lot of work, moreover someone could write a CMake one too (this is the one that can generate project files out of the box, and is said to be a decent tool also), and maybe some other, so you can compare. Nevertheless, lets push that a little step forward.



Yes, installation, this is an interesting feature ;)

Added directory configuration, install targets and shell starters generation, example:

Code: [Select]
scons prefix=/usr/local bindir=bin gamedir=games/ufoai install

Note that the directory with data and executables is called gamedir and not datadir -- just doesn't feel like data. One question here is how should radiant be installed.

This requires pk3 generation, so it is partially done (using python's zipfile module) -- it can only recreate zips, can't update them. Appending new files isn't hard, but I don't know how to delete unneeded ones from the archive (I've seen a custom module somewhere that can do that, but haven't tried that yet). By the what are the use cases for pk3's, this is needed only if someone 'make install's or builds one of the installers?



Update-po-radiant went rather easily, could be improved by making a simple builder that would search for xgettext and allow setting gettextdir, Wesnoth has something in this direction: http://svn.gna.org/viewcvs/wesnoth/trunk/scons/gettext.py.

Update-po: wow, this is quite convoluted, I enjoyed studying those scripts, because I'm not the one who's maintaining them :) My understanding here is that:

  • first this generates the message catalog (.pot) by scanning client/game sources, .ufos and .umps; using xgettext in the former case and ufoai.pl in the latter,
  • charset=CHARSET should be replaced by charset=UTF-8,
  • if the new file and the old file differ only in creation date line, then the .pot is not replaced,
  • file paths need to be relative to the src directory,
  • in the end it merges .pot with each translation.

Is this right or am I missing something? Why ufo and radiant have their rules so different (different base, with and without a header, different options, update-po-radiant not msgmerging .po-s)?

I've been seriously considering just running make here, but in the end managed to get a .pot that diffs in just a few lines compared to the make's one (five within the header: names of source/base partial .pots, creation dates and one msgid for m_node_base.c:190, which po-check apparently misses; uforadiant.pot comes out 100% same provided you add --sort-by-file and --no-wrap to the makefile rule). The solution uses OTHER_STRINGS and ufopo.pl (which it shouldn't -- would be cleaner and faster to write a small builder for that), but ignores POTFILES.in, FINDUFOS etc. completely -- just globs for client/game/radiant sources instead (or uses a list constructed earlier when appropriate). Please, note that if you change a translatable string in source and just type 'scons' it will refresh the .pot and update .po-s; might be a little scary, but I'd say this is the right thing to do (this is because compiled translations are set as a default target and it can figure out that they depend on .po-s and these depend on .pot; also xgettext, msgmerge or msgcat commands don't have a builder, so need to be in path and don't pretty print yet).



Also:
  • aliases for some targets (client, server, game, ufo2map, radiant, langs, maps, archives, install, update-po, update-po-radiant); you can always use the target name also, but with maps this would be inconvenient ;) ,
  • fixed some FIXMEs,
  • and most importantly: written a list of tasks that need to done before this is usable (inside the SConstruct).


It has become somewhat big and slow already (that is the null build takes more than it could take), partly due to my lousy programming -- there's no optimization in the SConscript itself -- some parts of it often don't need to be analyzed (for example: unless it's install there is no need to parse install rules). Moreover, I have to admit that the script needed adding shared/parse.c manually to sources' lists (can't glob 'shared' because different parts use different files therein).

[attachment deleted by admin]