Flemmbrav / Pak192.Comic

Pakset and Theme for Simutrans
https://forum.simutrans.com/index.php/board,120.0.html
Other
25 stars 20 forks source link

New faster compile scripts with hash check #7

Closed An-dz closed 4 years ago

An-dz commented 5 years ago

I decided to improve the compilation scripts to close #4, the new scripts now create a csv file containing hashes of the files (dat & png) to know what can be updated and what can be skipped.

The scripts are also faster because of reduced output. Both script versions (Bash and PowerShell) show a progress bar and the file being processed. Some warnings and all errors are raised but all the rest is skipped.

Below are the times of the old and new scripts

9:31.21 - Old Bash script
8:14.52 - New Bash script (cold run)
2:14.36 - New Bash script (hot run)

9:09.14 - Old batch script
7:56.02 - New PowerShell (v2 cold run)
2:42.26 - New PowerShell (v2 hot run)
6:02.33 - New PowerShell (v5 cold run)
0:34.22 - New PowerShell (v5 hot run)
5:58.17 - New PowerShell (v6 cold run)
0:34.81 - New PowerShell (v6 hot run)
5:57.96 - New PowerShell (v7p3 cold run)
0:24.52 - New PowerShell (v7p3 hot run)

Cold run: Clean first run without any compiled package Hot run: Second run with everything already compiled

The PowerShell script is compatible with version 2.0 meaning it runs on stock Windows 7. With PowerShell v5.1 the script is much faster as you can see on the list above. To update PowerShell on Windows 7 & 8 (highly recommended) download the update from Microsoft. This package is also necessary to run PowerShell Core v6, v6 is standalone and is also available on Linux and Mac. v7 is an upcoming version that will replace v5 and v6.

Both Bash and PowerShell scripts can run on any platform, just make sure you change the makeobj call as Windows requires the exe file and Linux the elf file.

Observations

The hash check is per dat file and not per pak file as one can't really know which parts of the file have changed since last run without resorting to slow processing defeating the purpose of a faster run.

The scripts don't delete pak files and they rely solely on the hashes and the csv, if you delete all paks but keep the csv the script will not generate the files.

If you kill the script or an error occurs it will continue to keep track of all the hashes, the script only modifies its database if no errors happen. This should allow canceling it without losing its benefits.

Images of the magic

bash powershell