The International Simutrans Forum

 

Author Topic: Revising revision.jse  (Read 453 times)

0 Members and 2 Guests are viewing this topic.

Offline Matthew

  • *
  • Posts: 98
  • Languages: EN, some ZH, DE & SQ
Revising revision.jse
« on: May 05, 2018, 01:30:16 AM »
I am attempting to compile Simutrans-Extended for the first time (TBH, it's my first time compiling anything for several decades...). I am using MSVS Express 2015 in Windows 7.

One problem that seems to often trip up us newcomers is the revision.jse file. As I understand it, this creates a file named revision.h containing the correct Simutrans revision number so that it can be displayed in-game and the client can compare its revision with the server. Without revision.h the game will not compile. With an empty revision.h, it has been reported that the game compiles, but I still get a compiler warning about line 9 in the .jse file with a cryptic reference to WshShell.

The file is slightly different in Standard and Expanded, because the former uses SVN and the latter uses Git. As this file is a legacy from Standard to Extended, and my query is about help with compilation, I am recording my experience in this forum for the benefit of others who have the same problem.

From my lay person's reading of the code, the file reaches through the compiler to access the Git/SVN APIs from the OS command line. If so, this assumes that users have Git and Tortoise available from the command line. The default options in the Git for Desktop installation process discourage this. I referred constantly to Prissi's very clear guide to installing Standard, but that did not make clear to me that Tortoise is needed for compilation (as well as for downloading). And I have Tortoise installed (for another project), but the error told me nothing about Tortoise itself.

To help future newcomers, I wonder whether the hard-pressed devs could spare a few moments to:
- update Prissi's guide between instructions 9 and 10 to emphasize that Tortoise is needed for the actual compilation of Standard (if that is true)
- tell me how to bypass revision.jse altogether (I am compiling the game because I want to tinker with it, so network compatibility isn't an issue)
- correct any misconceptions or wrong terminology in this post for the benefit of future forum users
- perhaps modify revision.jse so that it fails more gracefully, with an error message explaining that command line access to Git/SVN is necessary (if such a thing can be done)

But if you prefer to carry on playing with trains and trucks, I entirely understand.  ;D

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2376
  • Languages: EN
Re: Revising revision.jse
« Reply #1 on: May 05, 2018, 02:20:16 AM »
Technically it is not coupled to Tortoise on Windows. It is coupled to SVN, of which Tortoise is the most common provider of the service.

Making the game compile without the file is as simple as making your own revision.h file containing something like
Code: [Select]
#define REVISION   8370M

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2805
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Revising revision.jse
« Reply #2 on: May 05, 2018, 04:29:14 PM »
As @DrSuperGood explained the compilation is not tied with TortoiseSVN, but with SVN itself. On Extended it's tied to Git.

And that's only with MSVC because the revision.jse file is only used with MSVC, on GCC/Make you only need SVN/Git if you set the WITH_REVISION flag. You can also temporarily add SVN/Git in your PATH only for the compilation run.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5232
  • Languages: EN, NO
Re: Revising revision.jse
« Reply #3 on: May 05, 2018, 06:03:24 PM »
One of the drawbacks with Git as a Windows user is that Git is so Linux-minded (which is no wonder, since was made for Linux by the guy who made Linux) that it is a wonder it runs on Windows at all. One needs some form of Linux (or POSIX) emulation, since Windows' command line has little to nothing in common with Unix. At least with GCC, it likes to live in such an environment itself, so both can coexist in the same and be on its PATH. However, Microsoft is itself now using Git, so one really should expect their development tools to be able to interact with Git. (I'm a bit curious as to whether they use Cygwin or one of its derivatives, or Microsoft's promoted Ubuntu subsystem.)

Not that having tools on the PATH amounts to anything if the source code was not obtained using them in the first place, but through download a zip file or whatnot.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2805
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Revising revision.jse
« Reply #4 on: May 05, 2018, 08:14:34 PM »
Not that having tools on the PATH amounts to anything if the source code was not obtained using them in the first place, but through download a zip file or whatnot.
Yes, that's another point, you must have got the source from SVN (Standard) or Git (Extended). If the .svn or .git dirs are not in the root of Simutrans source then it will also fail as the commands request the commit numbers that will only exist in the mentioned dirs.

Offline Matthew

  • *
  • Posts: 98
  • Languages: EN, some ZH, DE & SQ
Re: Revising revision.jse
« Reply #5 on: May 05, 2018, 09:24:34 PM »
Thank you to everyone who has helpfully explained more about how this works.

Technically it is not coupled to Tortoise on Windows. It is coupled to SVN, of which Tortoise is the most common provider of the service.

Thank you clarifying that.

Quote
Making the game compile without the file is as simple as making your own revision.h file containing something like
Code: [Select]
#define REVISION   8370M

Everything is simple if you know how ;D .

So thank you, I have now added this to the revision.h file.

Not that having tools on the PATH amounts to anything if the source code was not obtained using them in the first place, but through download a zip file or whatnot.
Yes, that's another point, you must have got the source from SVN (Standard) or Git (Extended). If the .svn or .git dirs are not in the root of Simutrans source then it will also fail as the commands request the commit numbers that will only exist in the mentioned dirs.

That is the heart of the point that I am trying to make. Nowhere in the Extended compilation guide does it says that you have must have Git for Windows installed at the command line; in fact, it explicitly suggests that you can download the source as a ZIP file from GitHub. The Standard compilation guide says, after step 9, "Now you're set up for compiling". That's close, but not quite right: even if you already have the source, you are still missing a necessary prerequisite for the system. Tortoise is only mentioned under the subheading of things that you need to get the source. It would be helpful for newcomers if this point was made explicit in the text of the compilation guides. If they were in the wiki, I would make a small edit myself, but (quite rightly!) I don't have edit rights for those forum posts. The actual wiki page seems so outdated that I wouldn't know where to begin.

(Edit to add context:)
One of the drawbacks with Git as a Windows user is that Git is so Linux-minded (which is no wonder, since was made for Linux by the guy who made Linux) that it is a wonder it runs on Windows at all. One needs some form of Linux (or POSIX) emulation, since Windows' command line has little to nothing in common with Unix. At least with GCC, it likes to live in such an environment itself, so both can coexist in the same and be on its PATH. However, Microsoft is itself now using Git, so one really should expect their development tools to be able to interact with Git. (I'm a bit curious as to whether they use Cygwin or one of its derivatives, or Microsoft's promoted Ubuntu subsystem.)

Yes, I completely agree that this makes using Git more difficult than using SVN. To the best of my very limited understanding, Git for Windows can be used from the Windows command line (by overridiing default settings and ignoring warnings), but the recommended methods are using its GUI, or running a simplified Bash command line provided for the purpose. As I used Bash, Git is not in my PATH. And amusingly, the PATH would need to be to a very *nix \Git\bin\ address. And MSVS has Git integration, so hopefully I won't need to use the Bash tools very often. But you all probably knew all that anyway!
« Last Edit: May 05, 2018, 10:07:14 PM by Matthew »

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2805
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Revising revision.jse
« Reply #6 on: May 05, 2018, 11:29:54 PM »
The problem is that most of us here are always getting the latest code from SVN/Git, so we don't have this problem. I for example don't even use MSVC, but GCC/Make so it's impossible for me to get this 'bug'.

Another point is that the guides are old, and in the case of Standard after step 9 it says "Now you're set up for compiling - but don't have the sources!" followed by installing TortoiseSVN which means that the error won't happen.

Extended only added this support of revision numbers very recently, I helped James to understand some points of what the jse and the makefile were doing and what he had to change to add the support. James actually forgot to edit the guide to add this bit of info, probably because he doesn't know much about how the file works. He got it working on his PC but don't remember exactly all the steps required to compile.

Anyway, the problem is not on the guides themselves but on the script. It should check if the output of SVN/Git is valid and create a fallback file if not. I'll update the scripts for both versions to add support for people without SVN/Git installed.



Fixed in r8425 for Standard

Sent pull request to Extended
Fixed in c63572d for Extended
« Last Edit: May 06, 2018, 02:46:57 PM by An_dz »

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5232
  • Languages: EN, NO
Re: Revising revision.jse
« Reply #7 on: May 06, 2018, 09:43:53 AM »
Ideally, whatever creates a zip file from the source code repository should embed the revision number in the zip file contents somehow. That way, a build straight from the zip will have the same version as a build from code checked straight out from the repository. Unfortunately, there is then no way of telling whether files have been altered between zip extraction and source code compiling.

Offline ACarlotti

  • *
  • Posts: 187
Re: Revising revision.jse
« Reply #8 on: May 06, 2018, 10:15:14 AM »
Unfortunately, there is then no way of telling whether files have been altered between zip extraction and source code compiling.

There is also no way of telling (from a server's perspective) whether someone has manually hardcoded the version number to agree with the server. So this isn't really a new problem, and shouldn't be seen as a reason not to include version numbers in the process that creates the zips.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5232
  • Languages: EN, NO
Re: Revising revision.jse
« Reply #9 on: May 06, 2018, 02:53:29 PM »
That would be premeditated incompatibility. I was just thinking of getting it right for people with no malicious intent, so that they could download the source code for a given revision, compile it and run against a corresponding nightly server.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2805
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Revising revision.jse
« Reply #10 on: May 06, 2018, 03:08:54 PM »
For MSVC the laziest method would be to include a revision.h file with the correct revision. The new script doesn't replace the file if one already exists and there's no SVN or if output is invalid.

According to MSVC documentation the new output messages will generate a warning on MSVC to let people know that not having a versioned folder won't update the revision number and they might not be able to play online.

The problem would be GCC but perhaps having FLAGS=-DREVISION=XXXX in config.template would be enough.