You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Nico Seessle <ni...@seessle.de> on 2001/07/07 17:07:57 UTC

Re: build.exe

----- Original Message -----
From: "Michael Jennings" <so...@home.com>
To: <an...@jakarta.apache.org>
Sent: Sunday, June 24, 2001 9:56 PM
Subject: build.exe


> A while ago I sent a message to the ant-user mailing list saying that I
had
> developed a win32 executable for running ANT. I posted a URL with
> a link to source code+exe but it doesn't look like it made it into
> the ANT distribution.

I had a look at it today, since there are so many problems with ant.bat on
different Windows-versions.

I have it working on my system (W2K, SP2) with JDK 1.3, JDK 1.3.1, JDK 1.4
and it does not seem to have any problems with Ant being installed in a
directory with spaces.

I had the following problems with it:
- I didn't know how to compile it (found out that you can compile it with
for example
  "bcc32 -WC -ID:\jdk13\include -ID:\jdk13\include\win32 *.cpp")
- The source looked ugly to me (I reformatted it a little bit)
- It didn't work with JDK 1.4 (there is no classic-vm in JDK 1.4) (*1)
- It didn't worked for me without passing any argument (it passed "null" to
main() instead of an empty array)

(*1) It now searches for a VM in the following way:
- Read CurrentVersion from "HKEY_LOCAL_MACHINE\JavaSoft\Java Development
Kit"
- Read JavaHome from "HKEY_LOCAL_MACHINE\JavaSoft\Java Development
Kit\${CurrentVersion}"
- Try to load ${JavaHome}\jre\bin\hotspot\jvm.dll
- If no success: Try to load ${JavaHome}\jre\bin\classes\jvm.dll
- If no success: Read "RuntimeLib" from "HKEY_LOCAL_MACHINE\JavaSoft\Java
Runtime Environment\${CurrentVersion}" and try to load that one
- If no success: Abort.

Some problems remain:
- Doesn't work with JDK 1.1 (Don't know how to start a VM?)
- You can't pass any arguments to the VM (to specify memory sizes)

You will find the modified version at
http://www.seessle.de/ant/win32-launcher.jar (located in the directory
"src/native/win32/launcher" relative to $ANT_HOME). The build.xml will not
be useful for most of you, since it uses the "cc" and "link" tasks modified
for the free Borland C++ 5.5 Package. You can compile it using
"bcc32 -WC -ID:\jdk13\include -ID:\jdk13\include\win32 *.cpp" if you have
The free Borland package installed. antrun.exe is included for people who
would like to play with it and don't want to install the compiler.

Please be warned: I'm not a good C (or CPP) programmer, so that modified
version may do anything to your system (but I don't think so, maybe I
introduced some memory-leaks as I'm not very good at working with pointers).

Michael: you are ready to donate this source to the ASF and we can add the
ASF-Copyright header to it?

Others: Do you think it would be useful to add this (as ant.exe) to the Ant
Distribution, so we can avoid future problems with ant.bat?

Nico




Re: build.exe

Posted by Nico Seessle <ni...@apache.org>.
----- Original Message -----
From: "Michael Jennings" <so...@home.com>
To: <an...@jakarta.apache.org>
Sent: Monday, July 09, 2001 8:32 PM
Subject: Re: build.exe



> If ANT itself takes no "-" parameters I like that idea better.

Oops. I thought I finished that part if the sentence, but I have not... Of
course Ant also has some arguments that start with "-"
(-buildfile, -projecthelp, ...). The sentence should have been "maybe just
pass anything that starts with a "-"-sign to the
JVM if it's not a know argument for Ant - ugly since you must apply changes
regarding arguments to both Main.java and antrun.cpp"

Nico



RE: build.exe

Posted by Adam Murdoch <ad...@yahoo.com>.
Hi,

Just a comment on the invocation API and Java 1.1.

Using the 1.1 API isn't terribly different from the 1.2 API.  In fact,
provided you don't use any of the methods added in 1.2 (and I don't image an
ant exe would need to), then it's just a matter of providing a different
argument to JNI_CreateJavaVM().

Also, although they don't publicise the fact, the MS JVM supports JNI - and
so you can use the same mechanism for launching the MS JVM and the other 1.1
JVMs.

I can help out with getting this going, if it would be useful.


Adam

> -----Original Message-----
> From: Michael Jennings [mailto:southgate.software@home.com]
> Sent: Tuesday, 10 July 2001 4:32 AM
> To: ant-dev@jakarta.apache.org
> Subject: Re: build.exe
>
>
> > > > - The source looked ugly to me (I reformatted it a little bit)
> > > I am the only person in the world who formats C++ code in that
> particular
> > > way (lining
> > > up left and right curly braces)
> >
> > Don't know how it should have looked (I can live with nearly anything,
> since
> > one of our developers in the czech republic uses something he call
> "kernigan
> > and ritchie"-style (don't even know if I have got the names right) while
> > programming in Java :-(
>
> K&R is kinduva dinosaur way of doing C function declarations as in:
> somefunction(x,y,z)
> (
> int x;
> char y;
> char *z;
> )
> {
> }
>
> Or something like that anyways.
> >
> > > > - It didn't worked for me without passing any argument (it passed
> "null"
> > > to
> > > > main() instead of an empty array)
> > > I guess it should probably spit out a usage message.
> >
> > That was mainly a problem of Ant - it simply didn't expect to
> *not* get a
> > String[] passed to main() (I don't think something like this can happen
> > normally).
>
> I don't know either. I seem to remember encountering both null and
> zero-length String[] objects
> being passed. Should probably be changed to pass zero-length
> String[] array
> to main
>
> >
> > > > Some problems remain:
> > > > - Doesn't work with JDK 1.1 (Don't know how to start a VM?)
> > >
> > > The invocation API is entirely different with 1.1 JVMs. Is it worth
> > > supporting 1.1 JVM's?
> > >
> >
> > I have just mentioned it for completeness - personally I don't have a
> > problem with running Ant under JDK 1.3/1.4, even if the Application I'm
> > building is based mainly on MS's VM. It's just that current Ant versions
> > state that they are mostly compatible with JDK 1.1.
>
> The new invocation API works with 1.2/1.3/1.4 it's just 1.1 that
> it doesn't
> work with.
> Of course Microsoft's 1.1 JVM is invoked differently again from
> Sun/IBM/Blackdown's JVMs.
>
> >
> > > > - You can't pass any arguments to the VM (to specify memory sizes)
> > >
> > > How do we differentiate between arguments meant for the VM
> and arguments
> > > meant for ANT?
> > >
> >
> > I don't know - maybe just pass anything that starts with a
> "-"-sign to the
> > JVM or start VM-Parameters with -J-realarg like some other apps
> are doing
> > it.
>
> If ANT itself takes no "-" parameters I like that idea better. Or
> maybe the
> VM params can be read
> from a file in the same directory as ant.exe? The whole point of
> ant.exe is
> to replace the .bat file
> which presumably a user would have to modify to pass parameters
> to the JVM.
> So maybe an jvm.options
> file or something like that?
>
> -Mike
> >
> > Nico
> >
> >
> >


Re: build.exe

Posted by Michael Jennings <so...@home.com>.
> > > - The source looked ugly to me (I reformatted it a little bit)
> > I am the only person in the world who formats C++ code in that
particular
> > way (lining
> > up left and right curly braces)
>
> Don't know how it should have looked (I can live with nearly anything,
since
> one of our developers in the czech republic uses something he call
"kernigan
> and ritchie"-style (don't even know if I have got the names right) while
> programming in Java :-(

K&R is kinduva dinosaur way of doing C function declarations as in:
somefunction(x,y,z)
(
int x;
char y;
char *z;
)
{
}

Or something like that anyways.
>
> > > - It didn't worked for me without passing any argument (it passed
"null"
> > to
> > > main() instead of an empty array)
> > I guess it should probably spit out a usage message.
>
> That was mainly a problem of Ant - it simply didn't expect to *not* get a
> String[] passed to main() (I don't think something like this can happen
> normally).

I don't know either. I seem to remember encountering both null and
zero-length String[] objects
being passed. Should probably be changed to pass zero-length String[] array
to main

>
> > > Some problems remain:
> > > - Doesn't work with JDK 1.1 (Don't know how to start a VM?)
> >
> > The invocation API is entirely different with 1.1 JVMs. Is it worth
> > supporting 1.1 JVM's?
> >
>
> I have just mentioned it for completeness - personally I don't have a
> problem with running Ant under JDK 1.3/1.4, even if the Application I'm
> building is based mainly on MS's VM. It's just that current Ant versions
> state that they are mostly compatible with JDK 1.1.

The new invocation API works with 1.2/1.3/1.4 it's just 1.1 that it doesn't
work with.
Of course Microsoft's 1.1 JVM is invoked differently again from
Sun/IBM/Blackdown's JVMs.

>
> > > - You can't pass any arguments to the VM (to specify memory sizes)
> >
> > How do we differentiate between arguments meant for the VM and arguments
> > meant for ANT?
> >
>
> I don't know - maybe just pass anything that starts with a "-"-sign to the
> JVM or start VM-Parameters with -J-realarg like some other apps are doing
> it.

If ANT itself takes no "-" parameters I like that idea better. Or maybe the
VM params can be read
from a file in the same directory as ant.exe? The whole point of ant.exe is
to replace the .bat file
which presumably a user would have to modify to pass parameters to the JVM.
So maybe an jvm.options
file or something like that?

-Mike
>
> Nico
>
>
>


Re: build.exe

Posted by Diane Holt <ho...@yahoo.com>.
--- Nico Seessle <ni...@apache.org> wrote:
> Don't know how it should have looked (I can live with nearly anything,
> since one of our developers in the czech republic uses something he call
> "kernigan and ritchie"-style (don't even know if I have got the names
> right) while programming in Java :-(

It's Kernighan and Ritchie... a long time ago in a software industry far,
far away, all you had to say was K&R, and people knew what you meant. They
wrote this little book called "The C Programming Language"...

  http://cm.bell-labs.com/cm/cs/cbook/index.html

Diane


 

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: build.exe

Posted by Nico Seessle <ni...@apache.org>.
----- Original Message -----
From: "Michael Jennings" <so...@home.com>
To: <an...@jakarta.apache.org>
Sent: Monday, July 09, 2001 6:38 PM
Subject: Re: build.exe


> > - The source looked ugly to me (I reformatted it a little bit)
> I am the only person in the world who formats C++ code in that particular
> way (lining
> up left and right curly braces)

Don't know how it should have looked (I can live with nearly anything, since
one of our developers in the czech republic uses something he call "kernigan
and ritchie"-style (don't even know if I have got the names right) while
programming in Java :-(

> > - It didn't worked for me without passing any argument (it passed "null"
> to
> > main() instead of an empty array)
> I guess it should probably spit out a usage message.

That was mainly a problem of Ant - it simply didn't expect to *not* get a
String[] passed to main() (I don't think something like this can happen
normally).

> > Some problems remain:
> > - Doesn't work with JDK 1.1 (Don't know how to start a VM?)
>
> The invocation API is entirely different with 1.1 JVMs. Is it worth
> supporting 1.1 JVM's?
>

I have just mentioned it for completeness - personally I don't have a
problem with running Ant under JDK 1.3/1.4, even if the Application I'm
building is based mainly on MS's VM. It's just that current Ant versions
state that they are mostly compatible with JDK 1.1.

> > - You can't pass any arguments to the VM (to specify memory sizes)
>
> How do we differentiate between arguments meant for the VM and arguments
> meant for ANT?
>

I don't know - maybe just pass anything that starts with a "-"-sign to the
JVM or start VM-Parameters with -J-realarg like some other apps are doing
it.

Nico



Re: build.exe

Posted by Michael Jennings <so...@home.com>.
Nico,

Thanks for having a look at the win32 ant-launcher. I appreciate the changes
you have made
to make it work with java 1.4

> I had the following problems with it:
> - I didn't know how to compile it (found out that you can compile it with
> for example
>   "bcc32 -WC -ID:\jdk13\include -ID:\jdk13\include\win32 *.cpp")

My fault. I use IDE's to handle all of that for me. Makefile's are
inconsistent and
tedious for my tastes, except for ANT (hence my interest in it).

> - The source looked ugly to me (I reformatted it a little bit)
I am the only person in the world who formats C++ code in that particular
way (lining
up left and right curly braces)

> - It didn't work with JDK 1.4 (there is no classic-vm in JDK 1.4) (*1)
Looks like you fixed this.

> - It didn't worked for me without passing any argument (it passed "null"
to
> main() instead of an empty array)
I guess it should probably spit out a usage message.

> Some problems remain:
> - Doesn't work with JDK 1.1 (Don't know how to start a VM?)

The invocation API is entirely different with 1.1 JVMs. Is it worth
supporting 1.1 JVM's?

> - You can't pass any arguments to the VM (to specify memory sizes)

How do we differentiate between arguments meant for the VM and arguments
meant for ANT?


> Michael: you are ready to donate this source to the ASF and we can add the
> ASF-Copyright header to it?

Sure! As long as my name stays on as the original author.

> Others: Do you think it would be useful to add this (as ant.exe) to the
Ant
> Distribution, so we can avoid future problems with ant.bat?

I think so.



Re: build.exe

Posted by Ken Wood <kw...@i2.com>.
I presume this approach is platform independent?

ant.bat is "dos"

ant.sh is "unix"

build.exe is "dos"

Your approach I like best if it runs anywhere as I expect it
should.

Adam Murdoch wrote:
> 
> Hi,
> 
> I put together a Java-based launcher a while ago, plus a task which builds
> custom application launchers.  The launchers are assembled into Jar files
> that can be run with "java -jar".
> 
> A quick description of what the launcher does:
> 
> When the launcher starts up, it builds up a classpath from the system
> classpath, plus whatever .jar and .zip files it finds in various
> directories.  The directories to search are customisable, and can be
> specified as an absolute path, a path relative to the working dir, or a path
> relative to the directory containing the launcher Jar.
> 
> It includes some hackery to locate tools.jar and add it to the classpath, if
> needed.
> 
> Once the classpath is built, the launcher invokes the main() method of the
> app's main class.  The main class name is customisable.
> 
> I have used the task to build launchers for a bunch of apps, including ant.
> No need to set JAVA_HOME or ANT_HOME - it figures it all out.
> 
> I feel it would be useful for ant to provide a task like this.  Every Java
> app has - to some degree or other - the same problems that ant has with
> launching itself.  Whatever solution ant comes up with, we should try to
> make generally available.
> 
> I can send in what I have.  It needs some work to fit a little better with
> ant.  In particular, it uses some Java 2 stuff, to locate the launcher Jar,
> and to build a classloader.  I think AntClassLoader could be used instead
> (need to abstract out the dependency on a Project).
> 
> Adam
> 
> > -----Original Message-----
> > From: Conor MacNeill [mailto:conor@cortexebusiness.com.au]
> > Sent: Sunday, 8 July 2001 9:26 AM
> > To: ant-dev@jakarta.apache.org
> > Subject: Re: build.exe
> >
> >
> > From: "Nico Seessle" <ni...@seessle.de>
> > > Others: Do you think it would be useful to add this (as ant.exe) to the
> > Ant
> > > Distribution, so we can avoid future problems with ant.bat?
> > >
> >
> > I'm happy to have it in there as source, but I think the real solution is
> > to move this processing into Java code, not C++. That is the
> > approach taken
> > by most of the Ant2 proposals. I might play around with a Java based
> > launcher.
> >
> > Conor
> >
> >
> >

RE: build.exe

Posted by Adam Murdoch <ad...@yahoo.com>.
Hi,

I put together a Java-based launcher a while ago, plus a task which builds
custom application launchers.  The launchers are assembled into Jar files
that can be run with "java -jar".

A quick description of what the launcher does:

When the launcher starts up, it builds up a classpath from the system
classpath, plus whatever .jar and .zip files it finds in various
directories.  The directories to search are customisable, and can be
specified as an absolute path, a path relative to the working dir, or a path
relative to the directory containing the launcher Jar.

It includes some hackery to locate tools.jar and add it to the classpath, if
needed.

Once the classpath is built, the launcher invokes the main() method of the
app's main class.  The main class name is customisable.

I have used the task to build launchers for a bunch of apps, including ant.
No need to set JAVA_HOME or ANT_HOME - it figures it all out.

I feel it would be useful for ant to provide a task like this.  Every Java
app has - to some degree or other - the same problems that ant has with
launching itself.  Whatever solution ant comes up with, we should try to
make generally available.

I can send in what I have.  It needs some work to fit a little better with
ant.  In particular, it uses some Java 2 stuff, to locate the launcher Jar,
and to build a classloader.  I think AntClassLoader could be used instead
(need to abstract out the dependency on a Project).


Adam

> -----Original Message-----
> From: Conor MacNeill [mailto:conor@cortexebusiness.com.au]
> Sent: Sunday, 8 July 2001 9:26 AM
> To: ant-dev@jakarta.apache.org
> Subject: Re: build.exe
>
>
> From: "Nico Seessle" <ni...@seessle.de>
> > Others: Do you think it would be useful to add this (as ant.exe) to the
> Ant
> > Distribution, so we can avoid future problems with ant.bat?
> >
>
> I'm happy to have it in there as source, but I think the real solution is
> to move this processing into Java code, not C++. That is the
> approach taken
> by most of the Ant2 proposals. I might play around with a Java based
> launcher.
>
> Conor
>
>
>


Re: build.exe

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
From: "Nico Seessle" <ni...@seessle.de>
> Others: Do you think it would be useful to add this (as ant.exe) to the
Ant
> Distribution, so we can avoid future problems with ant.bat?
>

I'm happy to have it in there as source, but I think the real solution is
to move this processing into Java code, not C++. That is the approach taken
by most of the Ant2 proposals. I might play around with a Java based
launcher.

Conor





Re: build.exe

Posted by Nico Seessle <ni...@apache.org>.
----- Original Message -----
From: "Steve Loughran" <st...@iseran.com>
To: <an...@jakarta.apache.org>
Cc: <so...@home.com>
Sent: Saturday, July 07, 2001 6:58 PM
Subject: Re: build.exe


> > Some problems remain:
> > - Doesn't work with JDK 1.1 (Don't know how to start a VM?)
>
> MS JVM is fairly easy to start from an exe; its just a COM object or
> something. The source to do it comes with the MS j++ SDK. But I'm not sure
> we should encourage use of java1.1 or corrupted variants, at least not if
it
> involves extra effort on our part.

I just mentioned it because Ant 1.x is generally supported under JDK 1.1.
Not really under MS VM, but personally I use the MS VM (and Visual J++) at
work.

> > - You can't pass any arguments to the VM (to specify memory sizes).
>
> Interesting -I wonder how java.exe does it?

I didn't want to say it's impossible - just wanted to say that it's not
possible with the current implementation of "ant.exe"...

> I've looked at the source; no pointer problems spring to mind, though I'd
> use more of std::sting than legacy sprintf stuff.

I have only changed small parts of it - the original source was written by
Michael Jennings and posted to the list...

> If I were using/editing this app, here are the changes I'd make. Note I'm
> not promising to make the changes, I just know what to do if I had the
time
> :-)

Thanks for you input - Iwill see if I can (will) dive so deep into C++...

Nico



Re: build.exe

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Nico Seessle" <ni...@seessle.de>
To: <an...@jakarta.apache.org>
Cc: <so...@home.com>
Sent: Saturday, July 07, 2001 8:07 AM
Subject: Re: build.exe


> ----- Original Message -----
> From: "Michael Jennings" <so...@home.com>
> To: <an...@jakarta.apache.org>
> Sent: Sunday, June 24, 2001 9:56 PM
> Subject: build.exe
>
>
> > A while ago I sent a message to the ant-user mailing list saying that I
> had
> > developed a win32 executable for running ANT. I posted a URL with
> > a link to source code+exe but it doesn't look like it made it into
> > the ANT distribution.
>
> I had a look at it today, since there are so many problems with ant.bat on
> different Windows-versions.
>
> I have it working on my system (W2K, SP2) with JDK 1.3, JDK 1.3.1, JDK 1.4
> and it does not seem to have any problems with Ant being installed in a
> directory with spaces.
>
> I had the following problems with it:
> - I didn't know how to compile it (found out that you can compile it with
> for example
>   "bcc32 -WC -ID:\jdk13\include -ID:\jdk13\include\win32 *.cpp")
> - The source looked ugly to me (I reformatted it a little bit)
> - It didn't work with JDK 1.4 (there is no classic-vm in JDK 1.4) (*1)
> - It didn't worked for me without passing any argument (it passed "null"
to
> main() instead of an empty array)

> Some problems remain:
> - Doesn't work with JDK 1.1 (Don't know how to start a VM?)

MS JVM is fairly easy to start from an exe; its just a COM object or
something. The source to do it comes with the MS j++ SDK. But I'm not sure
we should encourage use of java1.1 or corrupted variants, at least not if it
involves extra effort on our part.

> - You can't pass any arguments to the VM (to specify memory sizes).

Interesting -I wonder how java.exe does it?

>
> Please be warned: I'm not a good C (or CPP) programmer, so that modified
> version may do anything to your system (but I don't think so, maybe I
> introduced some memory-leaks as I'm not very good at working with
pointers).

I've looked at the source; no pointer problems spring to mind, though I'd
use more of std::sting than legacy sprintf stuff.

If I were using/editing this app, here are the changes I'd make. Note I'm
not promising to make the changes, I just know what to do if I had the time
:-)

1. check for JIKESPATH and set the jikes option if found
2. check for ANT_HOME and if it is there (and valid), use it instead of
using ::GetModulePath() to work out location

Adding these two checks would let you install by configuring the env
variables but not changing path -dropping ant into %SYSTEM32% instead would
be all that an installer needs to do.

3. make it build under msvc. Some pragmas and things look different; a few
#ifdefs will address that

I'd debate making the thing build in unicode, but am not in favour. The
source is very char oriented right now, but even if it was upped to using
TCHAR for narrow and wide builds, without a unicode entry point to the jvm
invocation, you dont gain much from the work. Plus it would inevitably make
dual bcc and msvc building more complex.

-Steve