Author Topic: Script for compiling Linux nightlies  (Read 4117 times)

Offline Arthanor

  • Commander
  • *****
  • Posts: 2488
  • XCom Armoury Quartermaster
    • View Profile
Script for compiling Linux nightlies
« on: October 01, 2015, 05:43:37 am »
Currently, I use these steps to compile my own versions of OpenXCom (sometimes Extended, sometimes normal, sometimes old versions for some mods, sometimes patched versions with extra features, etc. So I'll leave out the git stuff).
Code: [Select]
0.    make installation directory (called "srcdir" in these notes)
 1.    git clone git@github.com:SupSuper/OpenXcom.git srcdir
 2.    {copy XCOM1 assets into srcdir/bin/data}
 2*    For new data structure: cp -rp ../PatchedData/* srcdir/bin/UFO
 3.    mkdir srcdir/build
 4.    cd srcdir/build
 5.    cmake ..
 6.    ccmake ..
 7.    {set CMAKE_BUILD_TYPE to Release (or Debug if you want useful stack traces)}
 8.    {set CMAKE_INSTALL_PREFIX to /home/yourusername/bin/OpenXcom (or wherever you want OpenXCom to be installed: /home/jpaucl/XCom/OpenXCom/ThisBuild)}
 9.    {set DATADIR to define folder in which OpenXCom will look for the data subfolder}
10.    {configure, generate, and exit}
11.    make -j3
12.    make install

I think there is a method to make that into a script that will take care of most things, but I don't remember how to replace the definition of build type, prefix and datadir in a script.

Another thing is, as soon as I change a little thing (say add a few lines in one of the .cpp files), the "make -j3" command will recompile the whole thing (which takes forever on my crappy laptop), but that is quite unlike other makefiles I have seen, which only recompile the files that changed. What am I doing wrong?

Offline R1dO

  • Colonel
  • ****
  • Posts: 442
    • View Profile
Re: Script for compiling Linux nightlies
« Reply #1 on: October 01, 2015, 10:20:23 am »
Just out of curiosity.
Why do you create a clone each time?
It is just as easy to pull in only the latest commits from the remote. Assuming you've used line 1 to set-up the local git clone, it would be:
Code: [Select]
git pull origin
As for your question on definition replacements. Define a variable to hold that definition and assign that variable when needed. For example:
Code: [Select]
TYPE="Release"  # No whitespace around the '=' character
cmake "-DCMAKE_BUILD_TYPE:STRING=${TYPE}" # Quotation marks are for safety.

Another thing is, as soon as I change a little thing (say add a few lines in one of the .cpp files), the "make -j3" command will recompile the whole thing (which takes forever on my crappy laptop), but that is quite unlike other makefiles I have seen, which only recompile the files that changed. What am I doing wrong?
There can be multiple reasons for this, for instance (but not limited to):
* The changed .cpp file might be included in (all) other files, triggering  a recompile of those.
* Running cmake before each build could possibly force a complete rebuild [1]
* If you delete the source repository between builds, clone again and apply your patches before rebuilding then make will treat all files as new.

[1]  Instead of running cmake each time just run make and let cmake decide if there is reason to update the build list.

Offline Arthanor

  • Commander
  • *****
  • Posts: 2488
  • XCom Armoury Quartermaster
    • View Profile
Re: Script for compiling Linux nightlies
« Reply #2 on: October 01, 2015, 05:15:23 pm »
Just out of curiosity.
Why do you create a clone each time?
It is just as easy to pull in only the latest commits from the remote. Assuming you've used line 1 to set-up the local git clone, it would be:
Code: [Select]
git pull origin
Yes, I do that when I update something I already have. This was more of a set of steps to start from scratch.

Quote
As for your question on definition replacements. Define a variable to hold that definition and assign that variable when needed. For example:
Code: [Select]
TYPE="Release"  # No whitespace around the '=' character
cmake "-DCMAKE_BUILD_TYPE:STRING=${TYPE}" # Quotation marks are for safety.
Good! That's what I was looking for!
Quote
There can be multiple reasons for this, for instance (but not limited to):
* The changed .cpp file might be included in (all) other files, triggering  a recompile of those.
* Running cmake before each build could possibly force a complete rebuild [1]
* If you delete the source repository between builds, clone again and apply your patches before rebuilding then make will treat all files as new.

[1]  Instead of running cmake each time just run make and let cmake decide if there is reason to update the build list.
I've just discovered it seems to be #2. If I make a few changes and just run make (steps 11 and 12), it only compiles what is new. But if I make a change in cmake or ccmake, then it will recompile the whole thing. I guess I have to stop keeping all the different versions and just update them instead.

Thanks!