Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 343731

Summary: Can't run scripts on Windows
Product: z_Archived Reporter: Doug Schaefer <cdtdoug>
Component: AutotoolsAssignee: Jeff Johnston <jjohnstn>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 0.8.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Doug Schaefer CLA 2011-04-25 10:08:31 EDT
I tried autotools on Windows using MinGW. All the required tools seem to be available there so it should work.

However, as I found out with other projects, you can't run scripts directly on Windows. You need to wrap the calls with a call to the shell, e.g. using 'sh -c'. (I had to do this with Android and the call to the ndk-build script). I would do this only if the Platform.getOS was win32 and leave it normal for the rest of the platforms.
Comment 1 Jeff Johnston CLA 2011-04-25 18:04:21 EDT
(In reply to comment #0)
> I tried autotools on Windows using MinGW. All the required tools seem to be
> available there so it should work.
> 
> However, as I found out with other projects, you can't run scripts directly on
> Windows. You need to wrap the calls with a call to the shell, e.g. using 'sh
> -c'. (I had to do this with Android and the call to the ndk-build script). I
> would do this only if the Platform.getOS was win32 and leave it normal for the
> rest of the platforms.

We do wrap the configure and autogen.sh script with "sh" as part of a fix suggested by a Windows user.  So the -c also required?  I take it you were just trying to run the build and the configure step failed or were you trying another command?
Comment 2 Doug Schaefer CLA 2011-04-26 10:34:54 EDT
I got a autoreconf command not found when creating the project. I've checked out the source and I'll see if I can get it working. Thanks!
Comment 3 Doug Schaefer CLA 2011-04-26 10:36:29 EDT
BTW, the other problem could be the environment passed down to these commands. I have the path to MSYS/MinGW in my Build environment settings. I generally have multiple toolchains installed on my machine so I don't put these in my main Windows environment.
Comment 4 Doug Schaefer CLA 2011-04-26 11:40:16 EDT
OK. I got it working. Yes, you need to run the shell command as sh -c <cmd>. Here's a snippet I used:

if (Platform.getOS().equals(Platform.OS_WIN32)
        || Platform.getOS().equals(Platform.OS_MACOSX)) {
    // Neither Mac or Windows support calling scripts directly.
    String command = null;
    for (String arg : configTargets) {
        // TODO check for spaces in args
        if (command == null)
            command = arg;
        else
            command += " " + arg;
    }
    configTargets = new String[] { "-c", command };
}

I also noticed you have runScript, which runs configure, and runCommand, which ran autoreconf. autoreconf is a script, no?

I ran into a couple of other problems that I'll raise bugs for as well.
Comment 5 Jeff Johnston CLA 2011-04-26 16:20:06 EDT
(In reply to comment #4)
> OK. I got it working. Yes, you need to run the shell command as sh -c <cmd>.
> Here's a snippet I used:
> 
> if (Platform.getOS().equals(Platform.OS_WIN32)
>         || Platform.getOS().equals(Platform.OS_MACOSX)) {
>     // Neither Mac or Windows support calling scripts directly.
>     String command = null;
>     for (String arg : configTargets) {
>         // TODO check for spaces in args
>         if (command == null)
>             command = arg;
>         else
>             command += " " + arg;
>     }
>     configTargets = new String[] { "-c", command };
> }
> 
> I also noticed you have runScript, which runs configure, and runCommand, which
> ran autoreconf. autoreconf is a script, no?
> 
> I ran into a couple of other problems that I'll raise bugs for as well.

Thanks Doug.  Patch has been applied and I changed autoreconf to use runScript as well.  This still leaves the various autotool commands run from the Project Menu which are run directly but that should be a separate bug.