authorAndrew Krasny <akrasny@netbeans.org>
Tue Aug 27 20:34:20 2013 +0400 (20 months ago)
changeset 2626112b8a5a621d68
parent 262610 6140115a0216
child 262627 b8b289bbf2f0
child 262629 03bc22f23681
Bug #234221 - run doesn't work with latest 64-bit cygwin (Unable to start pty process)

This fix makes it possible to use nb (to run executable) when bitness of jdk/executable/cygwin match.
In case of mismatch user is notified...
     1.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/Bundle.properties
     1.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/Bundle.properties
     1.3 @@ -384,3 +384,6 @@
     1.4  ToolCollectionPanel.cbAsRequired.toolTipText=Assembler is required
     1.5  
     1.6  UserAddedToolCollection.tooltip.text=Tool collection "{0}" was added by user and will be preserved if user restores defaults.
     1.7 +
     1.8 +ToolsPanel.Cygwin32OnJDK64.warning=It is advised to start 32-bit NetBeans to use 32-bit Cygwin.
     1.9 +ToolsPanel.Cygwin64OnJDK32.warning=It is advised to start 64-bit NetBeans to use 64-bit Cygwin.
     2.1 --- a/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/ToolsPanel.java
     2.2 +++ b/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/ui/options/ToolsPanel.java
     2.3 @@ -50,10 +50,14 @@
     2.4  import java.awt.event.ActionListener;
     2.5  import java.awt.event.ItemEvent;
     2.6  import java.awt.event.ItemListener;
     2.7 +import java.io.File;
     2.8  import java.io.IOException;
     2.9  import java.util.ArrayList;
    2.10  import java.util.Collection;
    2.11  import java.util.List;
    2.12 +import java.util.concurrent.Callable;
    2.13 +import java.util.concurrent.ExecutionException;
    2.14 +import java.util.concurrent.Future;
    2.15  import java.util.concurrent.atomic.AtomicBoolean;
    2.16  import java.util.logging.Level;
    2.17  import java.util.logging.Logger;
    2.18 @@ -82,16 +86,19 @@
    2.19  import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
    2.20  import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
    2.21  import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
    2.22 +import org.netbeans.modules.nativeexecution.api.util.ProcessUtils;
    2.23  import org.netbeans.spi.options.OptionsPanelController;
    2.24  import org.openide.DialogDescriptor;
    2.25  import org.openide.DialogDisplayer;
    2.26  import org.openide.NotifyDescriptor;
    2.27 +import org.openide.util.Exceptions;
    2.28  import org.openide.util.HelpCtx;
    2.29  import org.openide.util.ImageUtilities;
    2.30  import org.openide.util.Lookup;
    2.31  import org.openide.util.NbBundle;
    2.32  import org.openide.util.NbPreferences;
    2.33  import org.openide.util.RequestProcessor;
    2.34 +import org.openide.util.Utilities;
    2.35  
    2.36  /** Display the "Tools Default" panel */
    2.37  @OptionsPanelController.Keywords(keywords={"#ToolsPanelKeywords"}, location=CndUIConstants.TOOLS_OPTIONS_CND_CATEGORY_ID, tabTitle= "#TAB_ToolsTab")
    2.38 @@ -475,6 +482,8 @@
    2.39          return true; //serverList == null ? true : serverList.get((String)cbDevHost.getSelectedItem()).isOnline();
    2.40      }
    2.41  
    2.42 +    private Future<String> extraValidationTask = null;
    2.43 +
    2.44      private void changeCompilerSet(CompilerSet cs) {
    2.45          getToolCollectionPanel().preChangeCompilerSet(cs);
    2.46          if (cs == null) {
    2.47 @@ -500,6 +509,12 @@
    2.48          getToolCollectionPanel().changeCompilerSet(cs);
    2.49          changingCompilerSet = false;
    2.50          currentCompilerSet = cs;
    2.51 +
    2.52 +        if (extraValidationTask != null) {
    2.53 +            extraValidationTask.cancel(true);
    2.54 +        }
    2.55 +        extraValidationTask = RP.submit(new ExtraValidationTask(currentCompilerSet, lblErrors));
    2.56 +
    2.57          fireCompilerSetChange();
    2.58          dataValid();
    2.59      }
    2.60 @@ -623,7 +638,18 @@
    2.61                  validate();
    2.62                  repaint();
    2.63              } else {
    2.64 -                lblErrors.setText("");
    2.65 +                String warnings = ""; // NOI18N
    2.66 +                Future<String> fwarnings = extraValidationTask;
    2.67 +                if (fwarnings != null && fwarnings.isDone()) {
    2.68 +                    try {
    2.69 +                        warnings = fwarnings.get();
    2.70 +                    } catch (InterruptedException ex) {
    2.71 +                        Exceptions.printStackTrace(ex);
    2.72 +                    } catch (ExecutionException ex) {
    2.73 +                        Exceptions.printStackTrace(ex);
    2.74 +                    }
    2.75 +                }
    2.76 +                lblErrors.setText("<html>" + warnings + "</html>"); // NOI18N
    2.77              }
    2.78  
    2.79              boolean baseDirValid = getToolCollectionPanel().isBaseDirValid();
    2.80 @@ -1058,6 +1084,66 @@
    2.81          
    2.82      }
    2.83  
    2.84 +    private static class ExtraValidationTask implements Callable<String> {
    2.85 +
    2.86 +        private final CompilerSet cs;
    2.87 +        private volatile boolean isInterrupted = false;
    2.88 +        private final JLabel lblErrors;
    2.89 +
    2.90 +        public ExtraValidationTask(CompilerSet cs, JLabel lblErrors) {
    2.91 +            this.cs = cs;
    2.92 +            this.lblErrors = lblErrors;
    2.93 +        }
    2.94 +
    2.95 +        @Override
    2.96 +        public String call() throws Exception {
    2.97 +            if (cs.getCompilerFlavor().isCygwinCompiler() && Utilities.isWindows()) {
    2.98 +                String jdkBitness = System.getProperty("os.arch"); // NOI18N
    2.99 +                if (jdkBitness == null) {
   2.100 +                    jdkBitness = ""; // NOI18N
   2.101 +                }
   2.102 +                String cygwinBitness = "";
   2.103 +                File uname_exe = new File(cs.getDirectory(), "uname.exe"); // NOI18N
   2.104 +                if (uname_exe.exists()) {
   2.105 +                    ProcessUtils.ExitStatus exitStatus = ProcessUtils.execute(ExecutionEnvironmentFactory.getLocal(), uname_exe.getPath(), "-m"); // NOI18N
   2.106 +                    if (exitStatus.isOK()) {
   2.107 +                        cygwinBitness = exitStatus.output.trim();
   2.108 +                    }
   2.109 +                }
   2.110 +
   2.111 +                String warning = ""; // NOI18N
   2.112 +                if (cygwinBitness.equals("i686") && !jdkBitness.equals("x86")) { // NOI18N
   2.113 +                    warning = NbBundle.getMessage(ToolsPanel.class, "ToolsPanel.Cygwin32OnJDK64.warning"); // NOI18N
   2.114 +                } else if (cygwinBitness.equals("x86_64") && jdkBitness.equals("x86")) { // NOI18N
   2.115 +                    warning = NbBundle.getMessage(ToolsPanel.class, "ToolsPanel.Cygwin64OnJDK32.warning"); // NOI18N
   2.116 +                }
   2.117 +                final String text = warning;
   2.118 +                if (!isInterrupted()) {
   2.119 +                    SwingUtilities.invokeLater(new Runnable() {
   2.120 +                        @Override
   2.121 +                        public void run() {
   2.122 +                            lblErrors.setText("<html>" + text); // NOI18N
   2.123 +                        }
   2.124 +                    });
   2.125 +                }
   2.126 +                return warning;
   2.127 +            }
   2.128 +            return ""; // NOI18N
   2.129 +        }
   2.130 +
   2.131 +        private boolean isInterrupted() {
   2.132 +            try {
   2.133 +                Thread.sleep(0);
   2.134 +            } catch (InterruptedException ex) {
   2.135 +                isInterrupted = true;
   2.136 +                Thread.currentThread().interrupt();
   2.137 +            }
   2.138 +
   2.139 +            isInterrupted |= Thread.currentThread().isInterrupted();
   2.140 +            return isInterrupted;
   2.141 +        }
   2.142 +    }
   2.143 +
   2.144      private class MyDevHostListCellRenderer extends DefaultListCellRenderer {
   2.145  
   2.146          @Override
     3.1 --- a/dlight.nativeexecution/external/binaries-list
     3.2 +++ b/dlight.nativeexecution/external/binaries-list
     3.3 @@ -1,2 +1,2 @@
     3.4 -886018BFD299115709FB351D28D9C1F5A2C6F5FD exechlp-1.0.zip
     3.5 +D19F70E8CC5D326509B1BF8C1A8FC87BD258E990 exechlp-1.0.zip
     3.6  
     4.1 --- a/dlight.nativeexecution/nbproject/project.properties
     4.2 +++ b/dlight.nativeexecution/nbproject/project.properties
     4.3 @@ -5,7 +5,7 @@
     4.4  project.license=cddl-netbeans-sun
     4.5  nbm.executable.files=bin/nativeexecution/**
     4.6  jnlp.indirect.files=bin/nativeexecution/**
     4.7 -spec.version.base=1.30.2
     4.8 +spec.version.base=1.30.3
     4.9  
    4.10  test.config.stableBTD.includes=**/*Test.class
    4.11  test.config.stableBTD.excludes=\
    4.12 @@ -46,6 +46,7 @@
    4.13  release.external/exechlp-1.0.zip!/Windows-x86_64/pty_open       = bin/nativeexecution/Windows-x86_64/pty_open
    4.14  release.external/exechlp-1.0.zip!/Windows-x86_64/sigqueue       = bin/nativeexecution/Windows-x86_64/sigqueue
    4.15  release.external/exechlp-1.0.zip!/Windows-x86_64/killall        = bin/nativeexecution/Windows-x86_64/killall
    4.16 +release.external/exechlp-1.0.zip!/Windows-x86_64/unbuffer.dll   = bin/nativeexecution/Windows-x86_64/unbuffer.dll
    4.17  release.external/exechlp-1.0.zip!/MacOSX-x86/process_start      = bin/nativeexecution/MacOSX-x86/process_start
    4.18  release.external/exechlp-1.0.zip!/MacOSX-x86/pty                = bin/nativeexecution/MacOSX-x86/pty
    4.19  release.external/exechlp-1.0.zip!/MacOSX-x86/pty_open           = bin/nativeexecution/MacOSX-x86/pty_open
     5.1 --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/Bundle.properties
     5.2 +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/Bundle.properties
     5.3 @@ -52,6 +52,14 @@
     5.4  ShellValidationSupport.ValidationError.fileNotFound=Required file {0} not found
     5.5  ShellValidationSupport.ValidationError.validationFailed=Unable to validate {0}
     5.6  ShellValidationSupport.ValidationError.rootIsNotMounted=No mount point for root (/) is defined
     5.7 +ShellValidationSupport.ValidationWarning.Cygwin32OnJDK64=\
     5.8 +32-bit cygwin is used while you are running 64-bit netbeans.\n\
     5.9 +This may cause problems while execution.\n\
    5.10 +Please either start 32-bit netbeans or install 64-bit cygwin.
    5.11 +ShellValidationSupport.ValidationWarning.Cygwin64OnJDK32=\
    5.12 +64-bit cygwin is used while you are running 32-bit netbeans.\n\
    5.13 +This may cause problems while execution.\n\
    5.14 +Please either start 64-bit netbeans or install 32-bit cygwin.
    5.15  PasswordManagerPasswordFor=Password for {0}
    5.16  SftpConnectionReceivedMessageIsTooLong.error.text=\
    5.17  Looks like you have faced with the known \
     6.1 --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ShellValidationSupport.java
     6.2 +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ShellValidationSupport.java
     6.3 @@ -53,6 +53,7 @@
     6.4  import java.util.regex.Matcher;
     6.5  import java.util.regex.Pattern;
     6.6  import javax.swing.JButton;
     6.7 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
     6.8  import org.netbeans.modules.nativeexecution.api.util.Shell.ShellType;
     6.9  import org.netbeans.modules.nativeexecution.support.ui.ShellValidationStatusPanel;
    6.10  import org.openide.DialogDescriptor;
    6.11 @@ -92,6 +93,26 @@
    6.12          ArrayList<String> validationErrors = new ArrayList<String>();
    6.13          ArrayList<String> validationWarnings = new ArrayList<String>();
    6.14  
    6.15 +        String jdkBitness = System.getProperty("os.arch"); // NOI18N
    6.16 +        if (jdkBitness == null) {
    6.17 +            jdkBitness = ""; // NOI18N
    6.18 +        }
    6.19 +
    6.20 +        String cygwinBitness = "";
    6.21 +        File uname_exe = new File(shell.bindir, "uname.exe"); // NOI18N
    6.22 +        if (uname_exe.exists()) {
    6.23 +            ProcessUtils.ExitStatus exitStatus = ProcessUtils.execute(ExecutionEnvironmentFactory.getLocal(), uname_exe.getPath(), "-m"); // NOI18N
    6.24 +            if (exitStatus.isOK()) {
    6.25 +                cygwinBitness = exitStatus.output.trim();
    6.26 +            }
    6.27 +        }
    6.28 +
    6.29 +        if (cygwinBitness.equals("i686") && !jdkBitness.equals("x86")) { // NOI18N
    6.30 +            validationWarnings.add(NbBundle.getMessage(ShellValidationSupport.class, "ShellValidationSupport.ValidationWarning.Cygwin32OnJDK64")); // NOI18N
    6.31 +        } else if (cygwinBitness.equals("x86_64") && jdkBitness.equals("x86")) { // NOI18N
    6.32 +            validationWarnings.add(NbBundle.getMessage(ShellValidationSupport.class, "ShellValidationSupport.ValidationWarning.Cygwin64OnJDK32")); // NOI18N
    6.33 +        }
    6.34 +
    6.35          try {
    6.36              File mount_util = new File(shell.bindir, "mount.exe"); // NOI18N
    6.37              File cygpath_util = new File(shell.bindir, "cygpath.exe"); // NOI18N
     7.1 --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/UnbufferSupport.java
     7.2 +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/UnbufferSupport.java
     7.3 @@ -112,7 +112,7 @@
     7.4  
     7.5          try {
     7.6              unbufferPath = macroExpander.expandPredefinedMacros(
     7.7 -                    "bin/nativeexecution/$osname-$platform"); // NOI18N
     7.8 +                    "bin/nativeexecution/$osname-$platform" + (isWindows ? "${_isa}" : "")); // NOI18N
     7.9              unbufferLib = macroExpander.expandPredefinedMacros(
    7.10                      "unbuffer.$soext"); // NOI18N
    7.11          } catch (ParseException ex) {
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo