News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Revising revision.jse

Started by Matthew, May 05, 2018, 01:30:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Matthew

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
(Signature being tested) If you enjoy playing Simutrans, then you might also enjoy watching Japan Railway Journal
Available in English and simplified Chinese
如果您喜欢玩Simutrans的话,那么说不定就想看《日本铁路之旅》(英语也有简体中文字幕)。

DrSuperGood

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
#define REVISION   8370M


An_dz

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.

Ters

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.

An_dz

Quote from: Ters on May 05, 2018, 06:03:24 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.

Matthew

#5
Thank you to everyone who has helpfully explained more about how this works.

Quote from: DrSuperGood 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.

Thank you clarifying that.

QuoteMaking the game compile without the file is as simple as making your own revision.h file containing something like
#define REVISION   8370M

Everything is simple if you know how ;D .

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

Quote from: Ters on May 05, 2018, 06:03:24 PMNot 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.
Quote from: An_dz on May 05, 2018, 08:14:34 PM
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:)
Quote from: Ters on May 05, 2018, 06:03:24 PMOne 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!
(Signature being tested) If you enjoy playing Simutrans, then you might also enjoy watching Japan Railway Journal
Available in English and simplified Chinese
如果您喜欢玩Simutrans的话,那么说不定就想看《日本铁路之旅》(英语也有简体中文字幕)。

An_dz

#6
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

Ters

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.

ACarlotti

Quote from: Ters on May 06, 2018, 09:43:53 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.

Ters

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.

An_dz

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.