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

Bug 357442

Summary: Extend cygwin toolchain detection algorithm
Product: [Tools] CDT Reporter: Marko Tomljenovic <marko.tomljenovic>
Component: cdt-buildAssignee: Andrew Gvozdev <angvoz.dev>
Status: RESOLVED FIXED QA Contact: Andrew Gvozdev <angvoz.dev>
Severity: enhancement    
Priority: P3 CC: cdtdoug
Version: 7.0.2   
Target Milestone: 8.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Marko Tomljenovic CLA 2011-09-13 02:34:58 EDT
Build Identifier: 7.0.2

In the current implementation the cygwin detection is done in this order:

1. Check each of the PATH environment variable values whether the path + "cygwin1.dll" exists. The CYGWIN bin folder must be added to the PATH variable.
2. Find the name "rootdir" under the registry key "SOFTWARE\Cygwin\setup"
3. Find the name "rootdir" under the registry key "SOFTWARE\Wow6432Node\Cygwin\setup"
4. Find the name "native" under the registry key "SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\"+ "/"
5. Check existence of folder c:\cygwin

If the root is found then it is checked whether the the databse file [cygwin_root]/etc/setup/installed.db is available and the following packages are installed:
* gcc
* binutils
* make

If this is the case then CDT will provide the CYGWIN related functionalities.
==================================================================================
I would like to have two more checks for finding the cygwin root folder so that it looks like this:
1. Check for CYGWIN_HOME env. variable and then check for cygwin1.dll
2. Check for cygwin folder next to eclipse installation/executable
3.(1.) Check each of the PATH environment variable values whether the path + "cygwin1.dll" exists. The CYGWIN bin folder must be added to the PATH variable.
4.(2.) Find the name "rootdir" under the registry key "SOFTWARE\Cygwin\setup"
5.(3.) Find the name "rootdir" under the registry key "SOFTWARE\Wow6432Node\Cygwin\setup"
6.(4.) Find the name "native" under the registry key "SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\"+ "/"
7.(5.) Check existence of folder c:\cygwin
 

Reproducible: Always

Steps to Reproduce:
See details
Comment 1 Marko Tomljenovic CLA 2011-09-13 02:49:56 EDT
In addition it would be nice to also query the system properties for, e.g. CYGWIN_HOME.

I could provide a patch for mingw and cygwin detection.
Comment 2 Andrew Gvozdev CLA 2011-09-13 09:32:52 EDT
(In reply to comment #1)
> In addition it would be nice to also query the system properties for, e.g.
> CYGWIN_HOME.
> I could provide a patch for mingw and cygwin detection.
If you prepare a patch I'd take a look. What do you mean by system properties? Also I am curious if there is any particular reason to spell CYGWIN_HOME this way.
Comment 3 Marko Tomljenovic CLA 2011-12-01 01:28:40 EST
(In reply to comment #2)
> (In reply to comment #1)
> > In addition it would be nice to also query the system properties for, e.g.
> > CYGWIN_HOME.
> > I could provide a patch for mingw and cygwin detection.
> If you prepare a patch I'd take a look. What do you mean by system properties?
> Also I am curious if there is any particular reason to spell CYGWIN_HOME this
> way.

For MINGW they are using this spelling. But I do not care about the spelling unless there is a way to check for a specific env. variable.
Comment 4 Marko Tomljenovic CLA 2011-12-01 01:33:05 EST
Locally I now made the changes. For testing I put cygwin into the eclipse install location (next to the eclipse.exe).
Cygwin is detected properly when creating a Cygwin Managed Build Project (Example "Hello World Ansi C").

But when the project is created I get the following error message from the console: 

"/bin/sh: /usr/bin/gcc: cannot execute binary file
make: *** [src/hw.o] Error 126"

When I use the cygwin distribution from c:/cygwin it works fine.

HINT: I initially installed cygwin to c:/cygwin

But I initially thought that all necessary paths are somehow resolved through the class CygwinPathResolver. Or am I missing something else?
Comment 5 Andrew Gvozdev CLA 2011-12-01 09:15:40 EST
(In reply to comment #4)
> But I initially thought that all necessary paths are somehow resolved through
> the class CygwinPathResolver. Or am I missing something else?
I believe that should be enough. You can take a look what was done in bug 303900 for example.
Comment 6 Andrew Gvozdev CLA 2013-02-01 10:25:19 EST
I added the check for $CYGWIN_HOME and sorted out some related scenarios. Now changes to $CYGWIN_HOME and $PATH in Preferences C/C++>Build->Environment are visible by Cygwin toolchain in New Project Wizard. It is possible to set $CYGWIN_HOME per configuration now as well. Those are pretty big changes in cygwin handling especially related to having it on per-configuration basis.

I've been using $CYGWIN_HOME via custom CDT build for a few months and came to really like it. The changes added on master branch for CDT 8.2.

> 2. Check for cygwin folder next to eclipse installation/executable
I think it is questionable practice. We can discuss more in separate bug if you feel strong about it but for now I do not support the idea.
Comment 7 CDT Genie CLA 2013-02-27 11:46:11 EST
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: Added $CYGWIN_HOME to cygwin toolchain detection algorithm

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=459437b14db546d194971b945114d650913676de
Comment 8 CDT Genie CLA 2013-02-27 11:46:26 EST
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: avoid adding default drive letter to unresolved paths by language settings providers

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=4c0af173c9f790f3b50aaa79a6ab14657edf539e
Comment 9 CDT Genie CLA 2013-02-27 11:52:29 EST
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: User-friendlier message about missing toolchain

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=b1fc6f69bef0788f34d8c0f6eb4f173b8e62bfb9
Comment 10 CDT Genie CLA 2013-02-27 11:56:36 EST
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: Cosmetics changes mostly

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=50cf74d46127a8dad2804cd96d0f7ee69d330f1b
Comment 11 CDT Genie CLA 2013-02-27 12:15:20 EST
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: Added $CYGWIN_HOME to cygwin toolchain detection algorithm

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=d960fff7ddd0f1120d1ad733b04cc880461555fe
Comment 12 CDT Genie CLA 2013-02-27 12:15:22 EST
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: Added $CYGWIN_HOME to cygwin toolchain detection algorithm

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=4b5b30fe150c8ba54ebf4a6c156fd8aae007f6d8
Comment 13 CDT Genie CLA 2013-03-10 08:23:39 EDT
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: Protect EnvVarCollector against NPE when array of environment variables contains null

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=e034731fee40a363a2a40f3f843890357e506abb
Comment 14 CDT Genie CLA 2013-03-10 08:23:44 EDT
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: Tidy EnvironmentVariableManagerToolChain

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=180b19205413a0d73baf1a19adf98c816b38d3fb
Comment 15 CDT Genie CLA 2013-03-10 08:23:46 EDT
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: Contribute $CYGWIN_HOME by GnuCygwinConfigurationEnvironmentSupplier only if it does not come from preferences

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=2bccd664165de845640fe615a7c5b1f0b87995e9
Comment 16 CDT Genie CLA 2013-03-11 13:23:03 EDT
*** cdt git genie on behalf of Andrew Gvozdev ***

    bug 357442: A bit more of tidy EnvironmentVariableManagerToolChain

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=aed09ee4b8bdf2110254ae1e6e84ebd4a5d8e804