Sunday, May 24, 2009

How to use LayerD compilers

Meta D++ compilation

To compile a Meta D++ program into a Zoe program use the "metadppc.exe" compiler:

C:\LayerD\bin\metadppc.exe helloworld.dpp

That will generate a file with the same name but with .zoe extension.

To compile a program composed of more than one file call the compiler for each file:

C:\LayerD\bin\metadppc.exe helloworld1.dpp

C:\LayerD\bin\metadppc.exe helloworld2.dpp

C:\LayerD\bin\metadppc.exe helloworld3.dpp

Take into account that this is possible because the program analysis and code generation is implemented in the Zoe compiler and not in the Meta D++ compiler.

Zoe Compilation

When you have the .zoe files of your program you must compile them with "zoec.exe" compiler. If the program is composed of one file:

c:\layerd\bin>zoec.exe HelloWorld.zoe

That will generate an .exe file for .NET platform that is the default platform and module type.

If the program is composed of more than one file:

c:\layerd\bin>zoec.exe HelloWorld_Source1.zoe HelloWorld_Source2.zoe –pn:HelloWorld

The parameter "-pn:HelloWorld" set the output filename for the generated module, this is required when more than one file is provided for compilation. If your program is composed of only one file and you don't provide the "-pn" parameter then the filename of the sourcefile will be used for the module name.

All steps together

As you need to run Meta D++ compiler and Zoe compiler to get the executable/library these are all the steps together:

For a program composed of one source file:

c:\layerd\bin>metadppc.exe HelloWorld.dpp

c:\layerd\bin>zoec.exe HelloWorld.zoe

For a program composed of more than one source file:

c:\layerd\bin>metadppc.exe HelloWorld_Source1.dpp

c:\layerd\bin>metadppc.exe HelloWorld_Source2.dpp

c:\layerd\bin>zoec.exe HelloWorld_Source1.zoe HelloWorld_Source2.zoe –pn:HelloWorld

Take into account that there will be more than one high level LayerD language (in addition to Meta D++), the Zoe compiler is always used in the same form.

Generation of Dynamic libraries (.dll)

To compile dynamic libraries use the parameter "-lib":

c:\layerd\bin>metadppc.exe HelloWorldLib.dpp

c:\layerd\bin>zoec.exe HelloWorldLib.zoe –lib


 

To compile a Compile Time extension

Compile the extension source code:

c:\layerd\bin>metadppc.exe MyClassfactory.dpp

c:\layerd\bin>zoec.exe MyClassfactory.zoe –ae

Extension Added: MyClassfactory

Not special step required for client code, compile as always:

c:\layerd\bin>metadppc.exe MyClassfactoryClient.dpp

c:\layerd\bin>zoec.exe MyClassfactoryClient.zoe


 

More information on the wiki:

http://layerd.wiki.sourceforge.net/compiler_usage

And on the command line help of the metadppc and zoec compilers.

No comments: