开发者

Conditional compilation with Java and ant

I have a problem wit the software I'm working on.

We are accessing Windows system calls via JNA, and we have to define some Windows structure (Java class that extends the JNA Structure) to be able to access them.

The application has to work with 32-bit and 64-bit architecture, but the problem with the structures is that attributes in them change based on the system architecture (from int to long for example).

Is there an easy (and sane) way to do conditional compilation a-la #ifdef in Java using ant? Are there any other ways to achieve this kind of conditional #ifdef?

The other way we 开发者_Python百科are contemplating is to create a general interface, create two different structures for 32-bit and 64-bit, and then handle the different case with some if-else.

Thanks.


Would the Ant condition clauses not do

http://ant.apache.org/manual/Tasks/condition.html

UPDATE: I think I finally got what you're trying to do. Looking at the javac man here I don't think the Java compiler will let you do that, regardless of the conditions you put in Ant. Either way I found a post on stackoverflow on determining the system architecture and a thread on the sun forums that you might find helpful.


wwyt is a conditional compilation pre-processor for Java language. It accepts (commented out) directives like #if, #else, .... etc. It's a Windows command line tool and can be used as a pre-processor before calling Ant to make the build. (And after the build, it can restore the converted files back to their original state.) Not sure if this helps, just so you know. Link is here: http://www.adarian.com/wwyt

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜