This document describes the Danger Resource Compiler (drc). The resource compiler allows you to store and edit data separately from your source code. This data includes things like text strings, graphics, sounds, and user interface layout descriptions. The data is compiled into a single binary file called a resource database.

Individual resources are stored using key/value pairs. They keys used in resource files are defined in java interfaces that can be referenced from your source code allowing you to access the data. There is a mechanism that allows these java interface files to be automatically generated so any key you use in a resource file is automatically available for use in your java source code.

Using drc
drc reads a text based input file. This file contains raw data such as text strings as well as references to other data files such as sound or graphics files. It compiles the data, in some cases converting it to a more appropriate format, and outputs a binary resource database. The following is a simple example of executing drc:
drc -i myresources.rsrc -o myresources.rdb
In this example, the resource file "myresources.rsrc" is compiled into a resource database named "myresources.rdb".
Resource Files
There is typically one resource file per application. It is stored in the application source directory and has the same name as the application with the ".rsrc" extension.

The resource file is a simple text file that contains individual resource definitions. A resource definition consists of three components: a type, a unique identifier, and the data. For example:

string kStringID "This is a string."

The data can either be the actual data as in the definition above, or a reference to a file containing the data:

sound kSoundID "sounds/sound.wav"
All paths specified are relative to the location of the resource file.

Any line that begins with the '#' character is considered a comment and is ignored by the compiler.

# This is a comment.

There are two required resource definitions for each application. They are the application name and application class. Some examples:

string ID_AppName "Hello World"
string ID_AppClass "com.examples.helloworld"
Applications must define these two resources properly to be displayed in the Simulator. Their resource IDs are predefined by the system and must be ID_AppName and ID_AppClass.
Command Line Options
-i input filename
Specifies the name of the input file to compile. The common extension for a resource file is ".rsrc".
-o output filename
Specifies the name of the resource database to be created. The common extension for this file is ".rdb".
-S system interface filename
Specifies the name of a system interface file containing a java interface definition. The common extension for this file is ".java".
-s interface filename
Specifies the name of an application interface file containing a java interface definition. The common extension for this file is ".java".
-C
If specified, the resource database will be compiled for color. By default, resource databases are compiled for grayscale.
-h resource id interface filename
Specifies the name of a resource id interface file to be auto-generated when the resource file is compiled. Resource keys used in the input file are automatically assigned values and defined in this interface. The common extension for this file is ".java".
-c resource id interface name
Specifies the name of the auto-generated resource id interface. This is normally the same as the -h interface filename without the ".java" extension.
-e event id interface filename
Specifies the name of an event id interface file to be auto-generated when the resource file is compiled. Resource keys used in the input file are automatically assigned values and defined in this interface. The common extension for this file is ".java".
-E event id interface name
Specifies the name of the auto-generated event id interface. This is normally the same as the -h interface filename without the ".java" extension.
-p package name
Specifies the name of the package that auto-generated resource or event id interfaces will be stored in. This is normally the same package that the application class is stored in.