Which Compiler gets used to compile .py to .grf?

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
PNDA
Engineer
Engineer
Posts: 12
Joined: 14 Mar 2018 15:05
Location: Germany

Which Compiler gets used to compile .py to .grf?

Post 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?
Image

User avatar
andythenorth
Tycoon
Tycoon
Posts: 5076
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Which Compiler gets used to compile .py to .grf?

Post 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.

PNDA
Engineer
Engineer
Posts: 12
Joined: 14 Mar 2018 15:05
Location: Germany

Re: Which Compiler gets used to compile .py to .grf?

Post 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)
Image

User avatar
andythenorth
Tycoon
Tycoon
Posts: 5076
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Which Compiler gets used to compile .py to .grf?

Post 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

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: rowdog and 3 guests