I've been reading about Phing and Ant and I'm not sure which, if either, of these tools are most useful for this scenario.
It could easily be debug statements etc, but I'll give you our literal scanario.
We have a free and premium version of a downloadable PHP app, and rather than including just a variable hidden somewhere and then doing:
if($premium == true) {
echo 'some additional functionality';
} else {
echo 'basic functionality';
}
Obviously someone could then take the source and change that variable, and bang - they've stolen our code. And something like Ioncube etc is just totally unwieldy in my experience and support on hosting companies is just not good enough.
I would prefer something.. perhaps similar to this:
## if premium ##
echo 'some additional functionality';
## else ##
echo 'basic functionality';
## endif ##
And then I would run two builds, one setting the premium to true and one to false, which would generate two files of simply:
echo 'some additional functionality';
and
echo 'basic functionality';
It would also be very helpful to be able to only include entire files based on this same condition passed to the build app.
I can't find a way to do this but I am open to any alternative ideas if possible.
Help would be outstanding,
UPDATE
Using the C preprocessor is great and looks like it does everything I need. However, I can't find how to do the following 3 things.
#1 I need to remove the comments generated into the output files. Below is an example of those.
# 1 "./index.php"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "./index.php"
I haven't found an example of how to do this in the manual page you linked me to.
#2 I need to make it recursively go through every discovered file. When I run my current code I get an error: ../target/./folder/test.php: No such file or directory
So basically I have my 'source' folder which I'm in, which contains a subfolder called 'folder' and it doesn't recreate that, nor the files inside it (test.php)
#3 I'm sure this one is easy - how can I get it to process .js files and probably .html just to be safe as well? In one call, I mean. I assume running it on .jpg etc etc files is a bad idea..
Thanks again!
packages.xml
(of course you cant name them bothpackage.xml
). – Whole