RBuild Files

From ReactOS Wiki
Revision as of 04:00, 3 July 2008 by Encoded (talk | contribs)
Jump to: navigation, search

work in progress by Z98

If you have another program that you wish to compile into ReactOS, you will need the source code as well as create an rbuild config file for it. In this example, we will assume that the program is called foo. The order in which I explain the various options are the order they technically should be in when you create an .rbuild file.

In the first line, you define a new module (executable). For type, you have the option of using win32cui (console application), win32gui (Windows application), win32ocx (OLE custom control), win32dll (Dynamic Linked Libraries), objectlibrary (statically-linked library), exportdriver (drivers that export public symbols), and kernelmodedriver (.sys driver). The other two are self explanatory. Another option that could be added is unicode="true/false". If you are compiling a driver you should also add entrypoint="DriverEntry@8".

 <module name="foo" type="win32gui" installname="foo.exe" allowwarnings="true">

This line is only needed if you're trying to export functions. This is most frequently used in DLLs, in which case your file would be located in something like /dll/*/foo. Drivers sometimes also export functions.

 <importlibrary definition="foo.def" />

This line is only needed if you need some special header that are not located in the base include directories. Otherwise you don't need to add it in.

 <include base="namedir">actualdir</include>

With this, you can do something like #include "namedir/foo.h".

This statement is the same as a #define in your source code. Using this will make it a global for all files.

 <define name="_WIN32_WINNT">0x0501</define>

This statement is used to designate the use of a precompiled header. Basically this tells the compiler to precompile the specified header and all its includes.

 <pch>precomp.h</pch>

This statement specifies a subdirectory where you want to do something. Once you are done supplying config information, you must close it. You will see one of the uses for this further down.

 <directory name="stuff">
     (various other config options)
 </directory>

If you want to make use use of ROS config flags, you can use the following lines for conditional options.

 <if property="CONFIGFLAG" value="setting">
     (various other config options)
 </if>

This statement specifies what other modules your module is dependent upon, so that the compiler knows to recompile your module in the event there's a change in the other one.

 <dependency>wineheaders</dependency>

Next is which libraries you will be using. If you use more than one library, the declaration becomes multi-line.

 <library>user32</library>
 <library>shell32</library>

For this, you need to know what libraries your program will need. If you don't know, you can try compiling the program and see which functions GCC complains about no finding and figure out where they're from.

If you want to specify special linkerflags, use something like the following statement:

 <linkerflag>-nostdlib</linkerflag>

If you wish to merge several files together and compile them as one file, you will wrap <file> with this.

 <compilationunit name = allfoo.c>

Next comes the files that will be compiled.

 <file>main.c</file>
 <file>functions.c</file>

If you had used <compliationunit> above, you must close it.

 </compliationunit>

You end the module definition with this.

 </module>

Once you're done creating your rbuild file, you must go one level up and add this to the rbuild file there.

 <directory name = "foo"
     <x:include href="foo/foo.rbuild">
 </directory>

Now you should be able to compile the new module with "make foo".

Here's a more continuous example.

 <module name="foo" type="win32gui" installname="foo.exe">
 
     <library>user32</library>
 
     <file>foo.c</file>
 
 </module>

Notes:

  • Use of backslashes is liable to break Linux builds. Always use forward(/) slashes. mingw can figure out what you mean.
  • Also, use tab for indentation.