ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <co...@cortexebusiness.com.au>
Subject Re: [SUBMISSION] New task to compile jni, c, dll
Date Tue, 13 Feb 2001 10:29:06 GMT
Gerald,

Thanks for posting this. I won't be looking at new tasks until I get Ant
1.3 out the door so unless someone else has time to pick this up, you may
have to wait a week or two before I can review it. If someone else wants to
comment on it or give Gerald some feedback, please go ahead.

Thanks
Conor.

----- Original Message -----
From: "SQUELART,GERALD (HP-Australia,ex2)" <gerald_squelart@hp.com>
To: "ant-dev" <ant-dev@jakarta.apache.org>
Sent: Tuesday, February 13, 2001 6:59 PM
Subject: [SUBMISSION] New task to compile jni, c, dll


> Hi all!
>
> I needed it, and it seems it was requested by a few people... So here it
is!
> This task creates jni C header files, compiles C source files and builds
DLL
> libraries...
> Sorry, it only support Windows for the moment, but I will add gcc/linux
> support soon.
>
> I post this here as a very first draft pre-alpha version! It works for
me!
> Comments, requests, help are welcome. (It's my first time on a dev
mailing
> list, so please have mercy :-)
>
> If you're interested in a more complete and reliable jni/c task, wait a
few
> weeks!
> If you want to try it, you'll probably have to modify it, because I've
> hard-coded the include/bin names to the compiler... (I told you: draft
> pre-alpha!).
>
> If you're courageous enough to give it a try, here's some help below...
>
> Have fun,
> Gerald.
>
> ---------------------------------------------
> <jnicc> Arguments:
> - srcdir, the source directory containing C and Java files (required)
> - lib, the library name built by this task
> - destdir, the destination dir for the lib (defaults to srcdir)
> - desthdir, the destination dir for the header files (defaults to
destdir)
> - destodir, the destination dir for the object files (defaults to
destdir)
> - classname, the dir containing the compiled java classes
>
> Constraints:
> - Every .java source file declaring native functions *must* have a
> corresponding .c source file with the same filename, in the same
directory.
> This is how the task knows that it should create a jni header file.
> - If classname is omitted, the system classname is used, and should point
to
> the directory containing the compiled class files corresponding to the
Java
> source files needed to create the jni headers.
> - If lib is omitted, the library name *must* appear in the first
> System.loadLibrary() in every Java source file needed to create the jni
> headers (see examples below).
>
> There are two major ways to use this task:
> *** To build one library
> Files:
> - in build.xml:
> <jnicc srcdir="src" lib="mylib" destdir="build/lib"
desthdir="build/jni_h"
> destodir="build/jni_o" classname="build/classes">
> - src/com/mycomp/myclass.java (containing native declarations)
> - src/com/mycomp/myclass.c (should #include "com_mycomp_myclass.h")
> Ant will create:
> - build/jni_h/com_mycomp_myclass.h
> - build/jni_o/com_mycomp.myclass.obj
> - build/lib/mylib.dll
>
> *** To build different libraries
> - in build.xml:
> <jnicc srcdir="src" destdir="build/lib" desthdir="build/jni_h"
> destodir="build/jni_o" classname="build/classes">
> - src/com/mycomp/myclass.java (must contain System.loadLibrary("mylib"),
may
> contain native declarations)
> - src/com/mycomp/myclass.c (should #include "com_mycomp_myclass.h")
> Ant will create:
> - build/jni_h/com_mycomp_myclass.h
> - build/jni_o/mylib/com_mycomp.myclass.obj
> - build/lib/mylib.dll
> If there are more than one library name, each of them will be created,
and
> will contain the object files corresponding to their java loadLibrary
> name...
>
> (I'm not sure this second use is very useful, you can have one task per
> library if needed...)
>
>
> OK, that's what it does at the moment!
>
>
> The real-soon future: (at least what *I* need)
> - parameterized path for include, bin, etc.
> - javah<1.2 support
> - gcc (or other through nested <cc ...>) support
> - cross-platform compilation support
>
>


---------------------------------------------------------------------------
-----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ant-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ant-dev-help@jakarta.apache.org


Mime
View raw message