Android Question Source code preprocessor to strip conditional code?

Alessandro71

Well-Known Member
Licensed User
Longtime User
Scenario:
an app manages different customers using symbols like

B4X:
#if CUSTOMER1
customer-specific code
#end if
#if CUSTOMER2
customer-specific code
#end if

now, customer 1 requests source code of the app.
you can’t just send the whole source code, because it will expose customer 2 specific code, which is private to each customer.

is there a simple way to process all source files and remove CUSTOMER2 specific section?
like a preprocessor that will strip #if sections, producing a sanitized copy of the source code.

anyone having the same issue out there?
 

Sandman

Expert
Licensed User
Longtime User
is there a simple way to process all source files and remove CUSTOMER2 specific section?
No.

anyone having the same issue out there?
Not identical, but I have many times longed for a compiler step that happens before the actual compilation, where it would be possible to modify the code using external scripts.

As for solving your need, the best I can come up with is to move all customer-specific things into an external b4xlib per customer, and then adjust the code to basically be this:
B4X:
#if CUSTOMER1
Dim CustomerSpecifics as Customer1Class
#end if

#if CUSTOMER2
Dim CustomerSpecifics as Customer2Class
#end if

You would obviously need to have identical structures in the classes so you could avoid messy code outside of them.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…