Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Alternative preprocessors?

Does anyone have any experience using alternative preprocessors like Prebop or Antenna? (Any stories about getting one of these tools configured in a BB project would be most welcome!) Are there any downsides to using an alternative preprocessor?

 

<rant>

The reason I ask is that the RIM preprocessor doesn't work very smoothly with Eclipse, at least with the most recent plugin version. For instance, with a construct like:

 

 

//#ifdef 4_2_1
int perm = ApplicationPermissions.PERMISSION_EXTERNAL_CONNECTIONS;
//#else
int perm = ApplicationPermissions.PERMISSION_INTERNET;
//#endif

 

Eclipse will complain about a duplicate field and, when targetting 4.2.1, an unresolved symbol PERMISSION_INTERNET. I've read suggestions on the forum for eliminating these errors, but they create source code that starts to look unmaintainable:

 

 

int perm;
//#ifdef 4_2_1
perm = ApplicationPermissions.PERMISSION_EXTERNAL_CONNECTIONS;
/*
//#else
perm = ApplicationPermissions.PERMISSION_INTERNET;
//#endif
//#ifdef 4_2_1
*/
//#endif

 

(And even that won't get rid of the deprecation warning about PERMISSION_EXTERNAL_CONNECTIONS when targeting 4.3 and above. For that, the preprocessing code has to become even more baroque.)

 

And heaven help you if you then (maybe out of habit) press Ctrl-Shift-F:

 

int perm;
// #ifdef 4_2_1
perm = ApplicationPermissions.PERMISSION_EXTERNAL_CONNECTIONS;
/*
* //#else perm = ApplicationPermissions.PERMISSION_INTERNET; //#endif
* //#ifdef 4_2_1
*/
// #endif

 

That isn't going to complie anywhere. (Not to mention that "//#preprocess" became "// #preprocess" back on line 1, so preprocessing isn't happening at all.)

 

Maybe it would be easier to just maintaining separate projects for all the target platforms. Smiley Sad

</rant>




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 64
Registered: ‎05-09-2009
My Device: Not Specified

Re: Alternative preprocessors?

I'm also looking for an alternative to the RIM preprocessor, my goal is to create more elaborated error logging using __FILE__ and __LINE__ directives.

New Contributor
Posts: 6
Registered: ‎03-08-2010
My Device: BlackBerry Simulator
My Carrier: Engineer

Re: Alternative preprocessors?

[ Edited ]

I totally agree with Ted_Hopp. I also had the terrible experience of using preprocessor under eclipse.

If there is any better idea, please share with us.

Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Alternative preprocessors?

I would write my own (and post it when done) but Eclipse isn't very helpful for telling how to extend it.

 

I always seem to have issues with those already available, they either are limited like the BB preprocessor or don't go in depth enough, so I would rather write my own.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 26
Registered: ‎08-26-2009
My Device: Not Specified

Re: Alternative preprocessors?

I am having the same issue here. Looking for an answer. So far I am still working with the way Class.getName("*").getInstance. But this way doesn't give me enough flexibility and some overhead. Smiley Sad

Developer
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Alternative preprocessors?

[ Edited ]

I develop in Netbeans and it's pre-processing support is excellent.

 

I can pre-process based on custom values I enter, any combination of if/else/and/or and by project configurations.   You also get source filtering per configuration... and it comments out code that does not fit the preprocessor logic automatically in real time Smiley Very Happy

 

Right now I have it setup to have 5 configurations, each for different OS level.

 

I click a single button, it preprocesses all 5, builds them, obfuscates them using proguard, signs them and creates OTA/Desktop loading files.

 

Using bb-ant-tools and custom ant script to integrate it with Netbeans.  

 

 

 

 

 

 

Developer
Posts: 26
Registered: ‎08-26-2009
My Device: Not Specified

Re: Alternative preprocessors?

cool. Actually I am also developing by using bb-ant-tools. I will give a try. thanks a lot.