Page 1 of 1
Which Compiler gets used to compile .py to .grf?
Posted: 01 May 2018 15:50
by PNDA
Hi,
I noticed in the source code of FIRS, that 91% of the newgrf is .py and 3% .js.
So how is this GRF getting compiled?
Re: Which Compiler gets used to compile .py to .grf?
Posted: 01 May 2018 16:50
by andythenorth
TL;DR
python -> generated nml code -> nmlc compiler -> grf
More detail:
make -> python 'render_nml' entry point -> industry and cargo classes -> chameleon templates -> nmlc files -> combined nmlc file
make -> python 'render_lang' entry point -> lang files
make -> nmlc file + lang files -> nmlc compiler -> grf
make -> python 'render_docs' entry point -> chameleon templates -> html -> docs dir; filesystem operations -> js, css, img -> docs dir
grf + docs -> tar for distribution
There's also a python graphics pipeline, but it's mostly unused in FIRS.
Re: Which Compiler gets used to compile .py to .grf?
Posted: 01 May 2018 16:59
by PNDA
andythenorth wrote:
python -> generated nml code -> nmlc compiler -> grf
More detail:
make -> python 'render_nml' entry point -> industry and cargo classes -> chameleon templates -> nmlc files -> combined nmlc file
make -> python 'render_lang' entry point -> lang files
make -> nmlc file + lang files -> nmlc compiler -> grf
make -> python 'render_docs' entry point -> chameleon templates -> html -> docs dir; filesystem operations -> js, css, img -> docs dir
grf + docs -> tar for distribution
There's also a python graphics pipeline, but it's mostly unused in FIRS.
Thanks, i only dont really understand were I can perform the action "make". Is there a special program for python or is it possible in for example Notepad++?
(Info: Im trying to make a Industry GRF, and want to use python for that, im not copying FIRS)
Re: Which Compiler gets used to compile .py to .grf?
Posted: 01 May 2018 17:22
by andythenorth
PandaCode wrote:Thanks, i only dont really understand were I can perform the action "make". Is there a special program for python or is it possible in for example Notepad++?
'make' is GNU Make which consumes a makefile.
https://www.gnu.org/software/make/
The makefile specifies rules for triggering python scripts, also nmlc, and other scripts like shell (which creates the tar and zip archives).
Make is used for convenience, but you don't need it.
The absolute simplest way to make the grf is to just write nml code in a program like Notepad++ or any text editor. This is then compiled with the nmlc compiler from
https://newgrf-specs.tt-wiki.net/wiki/NML:Main
Adding python templating is convenient for making the nml easier to work with when programming. I wrote a guide with a simplified approach
viewtopic.php?f=68&t=58390&hilit=python ... templating