Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Optimize Your Resource Management with Brew and XML : Page 3

Reduce your build management headaches and handle your resource objects in plain text using the power of Brew's new XML resource file architecture.


advertisement
Building the Files
There are two basic ways to build .brx and .mfx files. The first is through the .mif and .bar editors respectively. The process is as straightforward as it is simple. Open the .mfx or .brx in the appropriate application. Pull down the build menu and select Build. A dialogue box will appear and the appropriate output files appear in the same directory.

The second, and much more interesting method, is the command line compile tool. The Brew ResourceEditor has a simple but effective command line interface. Here's this tool in action:

"C:\Program Files\BREW SDK Tools 1.0.1\ResourceEditor\brewrc" ./testing.brx

This is a fairly straightforward command line call. If you reference images from a folder other than where the .brx file resides, be sure to use the '-i' flag and specify the path to the wayward images.



To build an .mfx file to a .mif file, simply add -o and the .mfx filename into the previous figure as shown below:

"C:\Program Files\BREW SDK Tools 1.0.1\ResourceEditor\brewrc" -o ./mif/testing.mif -nh testing.mfx

This also specifies the name and location of the compiled output file. For this to work, you must specify the extension of your .mif file. The 'brewrc' application will default to '.bar'. For more information on building .mif and .bar files on the command line be sure to read through the "SDK Tools User Docs" included with the toolset.

Figure 1. Visual Studio Screenshot: The location and content of the custom build step, which builds the brx on every compile.

There are two very appealing places this minimal command line interface can be used. You could add this line to a batch file or as a custom build step to a Visual Studio project. These would allow you to build your resource files alongside your source code in one simple step.

Add the command line to a batch file that drives the make file for your project. This will compile and output the .bar/.mif files for you at the same time your project builds for ARM.

When you put this command line to use in Visual Studio, adding and removing resources to your project is drastically simplified.

With Figure 1's custom build step in place, you can manipulate your resource file in plain text from within Visual Studio. Each time the code is compiled, the new .bar and .brh files are produced and used in the project.

An Essential New Resource
Now, with a complete understanding of the methodology, architecture, and implementation of Brew's new resource files, it should be simple to create and manage the resources in your project. Dynamic runtime resources are not for all platforms. Because of the porting demands of a Brew development project, it’s almost essential to have a way to modify the look, feel, language, and layout of an application at runtime.



Chris Haseman is an independent software engineer specializing in wireless development. He can be found riding his bike between coffee shops in San Francisco. He's the author of the book Android Essentials (published by Apress). In his spare time, he's a resident DJ at xtcradio.com and a martial arts instructor.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap