# HG changeset patch # User Alexander Simon # Date 1222781953 -14400 # Node ID 00ad58cc034e26ba53e197d1ad63a9abd8028d4a # Parent 856691ad6b1a705a94d6d2271fe1555485b28028 fixing: IZ#148552:65cat] java.io.IOException: Cannot run program "make" (in directory "C:\Users\Sunbon\Documents\NetBeansProjects\Pi_1"): CreateProcess error=2, The system cannot find the file specified diff -r 856691ad6b1a -r 00ad58cc034e cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProject.java --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProject.java Mon Sep 29 23:21:07 2008 -0700 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeProject.java Tue Sep 30 17:39:13 2008 +0400 @@ -61,6 +61,8 @@ import org.netbeans.api.project.ProjectInformation; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.queries.FileEncodingQuery; +import org.netbeans.modules.cnd.api.compilers.CompilerSet; +import org.netbeans.modules.cnd.api.compilers.ToolchainProject; import org.netbeans.modules.cnd.api.remote.RemoteProject; import org.netbeans.modules.cnd.api.utils.IpeUtils; import org.netbeans.modules.cnd.loaders.CCDataLoader; @@ -101,7 +103,6 @@ import org.openide.util.Lookup; import org.openide.util.Mutex; import org.openide.util.NbBundle; -import org.openide.util.Utilities; import org.openide.util.lookup.Lookups; import org.openidex.search.SearchInfo; import org.w3c.dom.Element; @@ -231,7 +232,8 @@ new FolderSearchInfo(projectDescriptorProvider), new MakeProjectType(), new MakeProjectEncodingQueryImpl(this), - new RemoteProjectImpl() + new RemoteProjectImpl(), + new ToolchainProjectImpl() }); } @@ -839,4 +841,16 @@ } } + + class ToolchainProjectImpl implements ToolchainProject { + + public CompilerSet getCompilerSet() { + MakeConfigurationDescriptor projectDescriptor = (MakeConfigurationDescriptor) projectDescriptorProvider.getConfigurationDescriptor(); + MakeConfiguration conf = (MakeConfiguration)projectDescriptor.getConfs().getActive(); + if (conf != null) { + return conf.getCompilerSet().getCompilerSet(); + } + return null; + } + } } \ No newline at end of file diff -r 856691ad6b1a -r 00ad58cc034e cnd/src/org/netbeans/modules/cnd/actions/AbstractExecutorRunAction.java --- a/cnd/src/org/netbeans/modules/cnd/actions/AbstractExecutorRunAction.java Mon Sep 29 23:21:07 2008 -0700 +++ b/cnd/src/org/netbeans/modules/cnd/actions/AbstractExecutorRunAction.java Tue Sep 30 17:39:13 2008 +0400 @@ -38,14 +38,21 @@ */ package org.netbeans.modules.cnd.actions; +import java.io.File; +import java.io.IOException; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.modules.cnd.api.compilers.CompilerSet; import org.netbeans.modules.cnd.api.compilers.CompilerSetManager; +import org.netbeans.modules.cnd.api.compilers.Tool; +import org.netbeans.modules.cnd.api.compilers.ToolchainProject; import org.netbeans.modules.cnd.api.remote.RemoteProject; +import org.netbeans.modules.cnd.api.utils.IpeUtils; import org.netbeans.modules.cnd.api.utils.PlatformInfo; +import org.netbeans.modules.cnd.builds.MakeExecSupport; import org.netbeans.modules.cnd.settings.CppSettings; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; import org.openide.loaders.DataObject; import org.openide.nodes.Node; import org.openide.util.HelpCtx; @@ -89,6 +96,52 @@ return developmentHost; } + protected String getMakeCommand(Node node){ + DataObject dataObject = node.getCookie(DataObject.class); + FileObject fileObject = dataObject.getPrimaryFile(); + Project project = FileOwnerQuery.getOwner(fileObject); + String makeCommand = null; + if (project != null) { + ToolchainProject toolchain = project.getLookup().lookup(ToolchainProject.class); + if (toolchain != null) { + Tool tool = toolchain.getCompilerSet().findTool(Tool.MakeTool); + if (tool != null) { + makeCommand = tool.getPath(); + } + } + } + if (makeCommand == null) { + MakeExecSupport mes = node.getCookie(MakeExecSupport.class); + makeCommand = mes.getMakeCommand(); + } + return makeCommand; + } + + protected File getBuildDirectory(Node node){ + MakeExecSupport mes = node.getCookie(MakeExecSupport.class); + DataObject dataObject = node.getCookie(DataObject.class); + FileObject fileObject = dataObject.getPrimaryFile(); + File makefile = FileUtil.toFile(fileObject); + + // Build directory + String bdir = mes.getBuildDirectory(); + File buildDir; + if (bdir.length() == 0 || bdir.equals(".")) { // NOI18N + buildDir = makefile.getParentFile(); + } else if (IpeUtils.isPathAbsolute(bdir)) { + buildDir = new File(bdir); + } else { + buildDir = new File(makefile.getParentFile(), bdir); + } + try { + buildDir = buildDir.getCanonicalFile(); + } + catch (IOException ioe) { + // FIXUP + } + return buildDir; + } + protected static String[] prepareEnv(String developmentHost) { CompilerSet cs = null; String csdirs = ""; // NOI18N diff -r 856691ad6b1a -r 00ad58cc034e cnd/src/org/netbeans/modules/cnd/actions/MakeBaseAction.java --- a/cnd/src/org/netbeans/modules/cnd/actions/MakeBaseAction.java Mon Sep 29 23:21:07 2008 -0700 +++ b/cnd/src/org/netbeans/modules/cnd/actions/MakeBaseAction.java Tue Sep 30 17:39:13 2008 +0400 @@ -44,8 +44,6 @@ import java.io.File; import java.io.IOException; import org.netbeans.modules.cnd.api.execution.NativeExecutor; -import org.netbeans.modules.cnd.api.utils.IpeUtils; -import org.netbeans.modules.cnd.builds.MakeExecSupport; import org.netbeans.modules.cnd.loaders.MakefileDataObject; import org.netbeans.modules.cnd.settings.MakeSettings; import org.openide.LifecycleManager; @@ -71,33 +69,16 @@ } protected void performAction(Node node, String target) { - MakeExecSupport mes = node.getCookie(MakeExecSupport.class); - DataObject dataObject = node.getCookie(DataObject.class); - FileObject fileObject = dataObject.getPrimaryFile(); - if (MakeSettings.getDefault().getSaveAll()) { LifecycleManager.getDefault().saveAll(); } - + DataObject dataObject = node.getCookie(DataObject.class); + FileObject fileObject = dataObject.getPrimaryFile(); File makefile = FileUtil.toFile(fileObject); // Build directory - String bdir = mes.getBuildDirectory(); - File buildDir; - if (bdir.length() == 0 || bdir.equals(".")) { // NOI18N - buildDir = makefile.getParentFile(); - } else if (IpeUtils.isPathAbsolute(bdir)) { - buildDir = new File(bdir); - } else { - buildDir = new File(makefile.getParentFile(), bdir); - } - try { - buildDir = buildDir.getCanonicalFile(); - } - catch (IOException ioe) { - // FIXUP - } + File buildDir = getBuildDirectory(node); // Executable - String executable = mes.getMakeCommand(); + String executable = getMakeCommand(node); // Arguments String arguments = "-f " + makefile.getName() + " " + target; // NOI18N // Tab Name diff -r 856691ad6b1a -r 00ad58cc034e cnd/src/org/netbeans/modules/cnd/api/compilers/ToolchainProject.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cnd/src/org/netbeans/modules/cnd/api/compilers/ToolchainProject.java Tue Sep 30 17:39:13 2008 +0400 @@ -0,0 +1,54 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.cnd.api.compilers; + +/** + * Interface is returned by project lookup. + * + * @author Alexander Simon + */ +public interface ToolchainProject { + + /** + * + * @return toolchain for active project configuration + */ + CompilerSet getCompilerSet(); +}