PageRenderTime 54ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/netbeans-7.3/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeActionProvider.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 965 lines | 830 code | 56 blank | 79 comment | 260 complexity | f669ea19d3cb812d349c788cf8d3bdf2 MD5 | raw file
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
  5. *
  6. * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  7. * Other names may be trademarks of their respective owners.
  8. *
  9. * The contents of this file are subject to the terms of either the GNU
  10. * General Public License Version 2 only ("GPL") or the Common
  11. * Development and Distribution License("CDDL") (collectively, the
  12. * "License"). You may not use this file except in compliance with the
  13. * License. You can obtain a copy of the License at
  14. * http://www.netbeans.org/cddl-gplv2.html
  15. * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  16. * specific language governing permissions and limitations under the
  17. * License. When distributing the software, include this License Header
  18. * Notice in each file and include the License file at
  19. * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
  20. * particular file as subject to the "Classpath" exception as provided
  21. * by Oracle in the GPL Version 2 section of the License file that
  22. * accompanied this code. If applicable, add the following below the
  23. * License Header, with the fields enclosed by brackets [] replaced by
  24. * your own identifying information:
  25. * "Portions Copyrighted [year] [name of copyright owner]"
  26. *
  27. * Contributor(s):
  28. *
  29. * The Original Software is NetBeans. The Initial Developer of the Original
  30. * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
  31. * Microsystems, Inc. All Rights Reserved.
  32. *
  33. * If you wish your version of this file to be governed by only the CDDL
  34. * or only the GPL Version 2, indicate your decision by adding
  35. * "[Contributor] elects to include this software in this distribution
  36. * under the [CDDL or GPL Version 2] license." If you do not indicate a
  37. * single choice of license, a recipient has the option to distribute
  38. * your version of this file under either the CDDL, the GPL Version 2 or
  39. * to extend the choice of license to its licensees as provided above.
  40. * However, if you add GPL Version 2 code and therefore, elected the GPL
  41. * Version 2 license, then the option applies only if the new code is
  42. * made subject to such option by the copyright holder.
  43. */
  44. package org.netbeans.modules.cnd.makeproject;
  45. import java.awt.Dialog;
  46. import java.awt.Frame;
  47. import java.awt.event.ActionListener;
  48. import java.io.File;
  49. import java.io.IOException;
  50. import java.text.MessageFormat;
  51. import java.util.ArrayList;
  52. import java.util.HashMap;
  53. import java.util.Iterator;
  54. import java.util.List;
  55. import java.util.Map;
  56. import java.util.Set;
  57. import java.util.TreeMap;
  58. import java.util.concurrent.atomic.AtomicBoolean;
  59. import javax.swing.JButton;
  60. import javax.swing.JOptionPane;
  61. import javax.swing.SwingUtilities;
  62. import org.netbeans.api.project.ProjectUtils;
  63. import org.netbeans.modules.cnd.actions.ShellRunAction;
  64. import org.netbeans.modules.cnd.api.remote.HostInfoProvider;
  65. import org.netbeans.modules.cnd.api.remote.RemoteProject;
  66. import org.netbeans.modules.cnd.api.remote.ServerList;
  67. import org.netbeans.modules.cnd.api.remote.ServerRecord;
  68. import org.netbeans.modules.cnd.api.toolchain.AbstractCompiler;
  69. import org.netbeans.modules.cnd.api.toolchain.CompilerFlavor;
  70. import org.netbeans.modules.cnd.api.toolchain.CompilerSet;
  71. import org.netbeans.modules.cnd.api.toolchain.CompilerSetManager;
  72. import org.netbeans.modules.cnd.api.toolchain.PlatformTypes;
  73. import org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind;
  74. import org.netbeans.modules.cnd.api.toolchain.Tool;
  75. import org.netbeans.modules.cnd.api.toolchain.ui.BuildToolsAction;
  76. import org.netbeans.modules.cnd.api.toolchain.ui.LocalToolsPanelModel;
  77. import org.netbeans.modules.cnd.api.toolchain.ui.ToolsPanelModel;
  78. import org.netbeans.modules.cnd.api.toolchain.ui.ToolsPanelSupport;
  79. import org.netbeans.modules.cnd.api.utils.PlatformInfo;
  80. import org.netbeans.modules.cnd.execution.ShellExecSupport;
  81. import org.netbeans.modules.cnd.makeproject.api.MakeArtifact;
  82. import org.netbeans.modules.cnd.makeproject.api.MakeCustomizerProvider;
  83. import org.netbeans.modules.cnd.makeproject.api.PackagerManager;
  84. import org.netbeans.modules.cnd.makeproject.api.ProjectActionEvent;
  85. import org.netbeans.modules.cnd.makeproject.api.ProjectActionEvent.Type;
  86. import org.netbeans.modules.cnd.makeproject.api.ProjectActionHandler;
  87. import org.netbeans.modules.cnd.makeproject.api.ProjectActionSupport;
  88. import org.netbeans.modules.cnd.makeproject.api.ProjectSupport;
  89. import org.netbeans.modules.cnd.makeproject.api.StepControllerProvider;
  90. import org.netbeans.modules.cnd.makeproject.api.StepControllerProvider.StepController;
  91. import org.netbeans.modules.cnd.makeproject.api.configurations.AssemblerConfiguration;
  92. import org.netbeans.modules.cnd.makeproject.api.configurations.CCCompilerConfiguration;
  93. import org.netbeans.modules.cnd.makeproject.api.configurations.CCompilerConfiguration;
  94. import org.netbeans.modules.cnd.makeproject.api.configurations.CompilerSet2Configuration;
  95. import org.netbeans.modules.cnd.makeproject.api.configurations.Configuration;
  96. import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptorProvider;
  97. import org.netbeans.modules.cnd.makeproject.api.configurations.CustomToolConfiguration;
  98. import org.netbeans.modules.cnd.makeproject.api.configurations.Folder;
  99. import org.netbeans.modules.cnd.makeproject.api.configurations.FortranCompilerConfiguration;
  100. import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
  101. import org.netbeans.modules.cnd.makeproject.api.configurations.ItemConfiguration;
  102. import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
  103. import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor;
  104. import org.netbeans.modules.cnd.makeproject.api.configurations.StringConfiguration;
  105. import org.netbeans.modules.cnd.makeproject.api.runprofiles.RunProfile;
  106. import org.netbeans.modules.cnd.makeproject.configurations.CppUtils;
  107. import org.netbeans.modules.cnd.makeproject.platform.Platform;
  108. import org.netbeans.modules.cnd.makeproject.platform.Platforms;
  109. import org.netbeans.modules.cnd.makeproject.spi.configurations.AllOptionsProvider;
  110. import org.netbeans.modules.cnd.makeproject.spi.configurations.CompileOptionsProvider;
  111. import org.netbeans.modules.cnd.makeproject.ui.utils.ConfSelectorPanel;
  112. import org.netbeans.modules.cnd.spi.toolchain.CompilerSetFactory;
  113. import org.netbeans.modules.cnd.utils.CndPathUtilitities;
  114. import org.netbeans.modules.cnd.utils.CndUtils;
  115. import org.netbeans.modules.cnd.utils.NamedRunnable;
  116. import org.netbeans.modules.cnd.utils.cache.CndFileUtils;
  117. import org.netbeans.modules.cnd.utils.ui.ModalMessageDlg;
  118. import org.netbeans.modules.dlight.util.usagetracking.SunStudioUserCounter;
  119. import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
  120. import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
  121. import org.netbeans.modules.nativeexecution.api.HostInfo;
  122. import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
  123. import org.netbeans.modules.nativeexecution.api.util.ConnectionManager.CancellationException;
  124. import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
  125. import org.netbeans.modules.nativeexecution.api.util.LinkSupport;
  126. import org.netbeans.modules.nativeexecution.api.util.Path;
  127. import org.netbeans.modules.nativeexecution.api.util.Shell;
  128. import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport;
  129. import org.netbeans.modules.nativeexecution.api.util.ShellValidationSupport.ShellValidationStatus;
  130. import org.netbeans.modules.nativeexecution.api.util.WindowsSupport;
  131. import org.netbeans.spi.project.ActionProvider;
  132. import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
  133. import org.openide.DialogDescriptor;
  134. import org.openide.DialogDisplayer;
  135. import org.openide.LifecycleManager;
  136. import org.openide.NotifyDescriptor;
  137. import org.openide.filesystems.FileObject;
  138. import org.openide.filesystems.FileUtil;
  139. import org.openide.loaders.DataObject;
  140. import org.openide.nodes.Node;
  141. import org.openide.util.Cancellable;
  142. import org.openide.util.Exceptions;
  143. import org.openide.util.Lookup;
  144. import org.openide.util.NbBundle;
  145. import org.openide.util.RequestProcessor;
  146. import org.openide.util.Utilities;
  147. import org.openide.util.actions.SystemAction;
  148. import org.openide.windows.WindowManager;
  149. /** Action provider of the Make project. This is the place where to do
  150. * strange things to Make actions. E.g. compile-single.
  151. */
  152. public final class MakeActionProvider implements ActionProvider {
  153. // Commands available from Make project
  154. public static final String COMMAND_BATCH_BUILD = "batch_build"; // NOI18N
  155. public static final String COMMAND_BUILD_PACKAGE = "build_packages"; // NOI18N
  156. public static final String COMMAND_CUSTOM_ACTION = "custom.action"; // NOI18N
  157. public static final String COMMAND_DEBUG_TEST = "debug.test"; // NOI18N
  158. public static final String COMMAND_DEBUG_STEP_INTO_TEST = "debug.stepinto.test"; // NOI18N
  159. private static final String[] supportedActions = {
  160. COMMAND_BUILD,
  161. COMMAND_CLEAN,
  162. COMMAND_REBUILD,
  163. COMMAND_COMPILE_SINGLE,
  164. COMMAND_RUN,
  165. COMMAND_RUN_SINGLE,
  166. COMMAND_DEBUG,
  167. COMMAND_DEBUG_STEP_INTO,
  168. COMMAND_DEBUG_SINGLE,
  169. COMMAND_BATCH_BUILD,
  170. COMMAND_BUILD_PACKAGE,
  171. COMMAND_DELETE,
  172. COMMAND_COPY,
  173. COMMAND_MOVE,
  174. COMMAND_RENAME,
  175. COMMAND_CUSTOM_ACTION,
  176. COMMAND_TEST,
  177. COMMAND_TEST_SINGLE,
  178. COMMAND_DEBUG_TEST,
  179. COMMAND_DEBUG_STEP_INTO_TEST,
  180. };
  181. // Project
  182. private MakeProject project;
  183. // Project Descriptor
  184. private MakeConfigurationDescriptor projectDescriptor = null;
  185. /** Map from commands to make targets */
  186. private Map<String, String[]> commands;
  187. private Map<String, String[]> commandsNoBuild;
  188. private boolean lastValidation = false;
  189. private static final String SAVE_STEP = "save"; // NOI18N
  190. private static final String BUILD_STEP = "build"; // NOI18N
  191. private static final String BUILD_PACKAGE_STEP = "build-package"; // NOI18N
  192. private static final String CLEAN_STEP = "clean"; // NOI18N
  193. private static final String RUN_STEP = "run"; // NOI18N
  194. private static final String DEBUG_STEP = "debug"; // NOI18N
  195. private static final String DEBUG_STEPINTO_STEP = "debug-stepinto"; // NOI18N
  196. private static final String RUN_SINGLE_STEP = "run-single"; // NOI18N
  197. private static final String DEBUG_SINGLE_STEP = "debug-single"; // NOI18N
  198. private static final String COMPILE_SINGLE_STEP = "compile-single"; // NOI18N
  199. private static final String CUSTOM_ACTION_STEP = "custom-action"; // NOI18N
  200. private static final String VALIDATE_TOOLCHAIN = "validate-toolchain"; // NOI18N
  201. private static final String BUILD_TESTS_STEP = "build-tests"; // NOI18N
  202. private static final String TEST_STEP = "test"; // NOI18N
  203. private static final String TEST_SINGLE_STEP = "test-single"; // NOI18N
  204. private static final String DEBUG_TEST_STEP = "debug-test"; // NOI18N
  205. private static final String DEBUG_STEPINTO_TEST_STEP = "debug-stepinto-test"; // NOI18N
  206. private static final RequestProcessor RP = new RequestProcessor("Make Action RP", 1);// NOI18N
  207. public MakeActionProvider(MakeProject project) {
  208. this.project = project;
  209. commands = loadAcrionSteps("CND/BuildAction"); // NOI18N
  210. commandsNoBuild = loadAcrionSteps("CND/NoBuildAction"); // NOI18N
  211. }
  212. private Map<String, String[]> loadAcrionSteps(String root) {
  213. Map<String, String[]> res = new HashMap<String, String[]>();
  214. FileObject folder = FileUtil.getConfigFile(root);
  215. if (folder != null && folder.isFolder()) {
  216. for (FileObject subFolder : folder.getChildren()) {
  217. if (subFolder.isFolder()) {
  218. TreeMap<Integer, String> map = new TreeMap<Integer, String>();
  219. for (FileObject file : subFolder.getChildren()) {
  220. Integer position = (Integer) file.getAttribute("position"); // NOI18N
  221. map.put(position, file.getNameExt());
  222. }
  223. res.put(subFolder.getNameExt(), map.values().toArray(new String[map.size()]));
  224. }
  225. }
  226. }
  227. return res;
  228. }
  229. private boolean isProjectDescriptorLoaded() {
  230. if (projectDescriptor == null) {
  231. ConfigurationDescriptorProvider pdp = project.getLookup().lookup(ConfigurationDescriptorProvider.class);
  232. return pdp.gotDescriptor();
  233. } else {
  234. return true;
  235. }
  236. }
  237. private MakeConfigurationDescriptor getProjectDescriptor() {
  238. if (projectDescriptor == null) {
  239. ConfigurationDescriptorProvider pdp = project.getLookup().lookup(ConfigurationDescriptorProvider.class);
  240. projectDescriptor = pdp.getConfigurationDescriptor();
  241. }
  242. return projectDescriptor;
  243. }
  244. @Override
  245. public String[] getSupportedActions() {
  246. return supportedActions;
  247. }
  248. private void saveIfModified() {
  249. if (getProjectDescriptor() != null && getProjectDescriptor().isModified()) {
  250. getProjectDescriptor().save();
  251. }
  252. }
  253. @Override
  254. public void invokeAction(String command, final Lookup context) throws IllegalArgumentException {
  255. if (COMMAND_DELETE.equals(command)) {
  256. try {
  257. // it's better to set deleted flag right here, otherwise we can start saving the project
  258. // #196501 - "Error synchronizing project to <login>@<host> null"
  259. project.setDeleting(true); // can't set setDeleted here since user can answer "No"
  260. DefaultProjectOperations.performDefaultDeleteOperation(project);
  261. } finally {
  262. project.setDeleting(false);
  263. }
  264. return;
  265. }
  266. if (COMMAND_COPY.equals(command)) {
  267. saveIfModified();
  268. DefaultProjectOperations.performDefaultCopyOperation(project);
  269. return;
  270. }
  271. if (COMMAND_MOVE.equals(command)) {
  272. saveIfModified();
  273. DefaultProjectOperations.performDefaultMoveOperation(project);
  274. return;
  275. }
  276. if (COMMAND_RENAME.equals(command)) {
  277. saveIfModified();
  278. DefaultProjectOperations.performDefaultRenameOperation(project, null);
  279. return;
  280. }
  281. if (COMMAND_RUN_SINGLE.equals(command)) {
  282. Node node = context.lookup(Node.class);
  283. if (node != null) {
  284. ShellRunAction.performAction(node);
  285. }
  286. return;
  287. }
  288. // Basic info
  289. final MakeConfigurationDescriptor pd = getProjectDescriptor();
  290. MakeConfiguration activeConf = pd.getActiveConfiguration();
  291. if (activeConf == null) {
  292. return;
  293. }
  294. final List<MakeConfiguration> confs = new ArrayList<MakeConfiguration>();
  295. if (command.equals(COMMAND_BATCH_BUILD)) {
  296. BatchConfigurationSelector batchConfigurationSelector = new BatchConfigurationSelector(project, pd.getConfs().toArray());
  297. String batchCommand = batchConfigurationSelector.getCommand();
  298. Configuration[] confsArray = batchConfigurationSelector.getSelectedConfs();
  299. if (batchCommand == null || confsArray == null || confsArray.length == 0) {
  300. return;
  301. }
  302. command = batchCommand;
  303. for (Configuration conf : confsArray) {
  304. confs.add((MakeConfiguration) conf);
  305. }
  306. } else {
  307. confs.add(activeConf);
  308. }
  309. final String finalCommand = command;
  310. CancellableTask actionWorker = new CancellableTask() {
  311. @Override
  312. protected void runImpl() {
  313. final ArrayList<ProjectActionEvent> actionEvents = new ArrayList<ProjectActionEvent>();
  314. for (MakeConfiguration conf : confs) {
  315. addAction(actionEvents, pd, conf, finalCommand, context, cancelled);
  316. }
  317. // Execute actions
  318. if (actionEvents.size() > 0 && !cancelled.isCanceled()) {
  319. RP.post(new NamedRunnable("Make Project Action Worker") { //NOI18N
  320. @Override
  321. protected void runImpl() {
  322. ProjectActionSupport.getInstance().fireActionPerformed(actionEvents.toArray(new ProjectActionEvent[actionEvents.size()]));
  323. }
  324. });
  325. }
  326. }
  327. };
  328. ConfigurationDescriptorProvider.recordActionMetrics(command, pd); //NOI18N
  329. runActionWorker(activeConf.getDevelopmentHost().getExecutionEnvironment(), actionWorker);
  330. }
  331. private static void runActionWorker(ExecutionEnvironment exeEnv, CancellableTask actionWorker) {
  332. ServerRecord record = ServerList.get(exeEnv);
  333. assert record != null;
  334. invokeLongAction(record, actionWorker);
  335. }
  336. public void invokeCustomAction(final MakeConfigurationDescriptor pd, final MakeConfiguration conf, final ProjectActionHandler customProjectActionHandler) {
  337. CancellableTask actionWorker = new CancellableTask() {
  338. @Override
  339. protected void runImpl() {
  340. ArrayList<ProjectActionEvent> actionEvents = new ArrayList<ProjectActionEvent>();
  341. addAction(actionEvents, pd, conf, MakeActionProvider.COMMAND_CUSTOM_ACTION, null, cancelled);
  342. ProjectActionSupport.getInstance().fireActionPerformed(
  343. actionEvents.toArray(new ProjectActionEvent[actionEvents.size()]),
  344. customProjectActionHandler);
  345. }
  346. };
  347. runActionWorker(conf.getDevelopmentHost().getExecutionEnvironment(), actionWorker);
  348. }
  349. private static void invokeLongAction(final ServerRecord record, final CancellableTask actionWorker) {
  350. CancellableTask wrapper;
  351. if (!record.isDeleted() && record.isOnline()) {
  352. wrapper = actionWorker;
  353. } else {
  354. String message;
  355. if (record.isDeleted()) {
  356. message = MessageFormat.format(getString("ERR_RequestingDeletedConnection"), record.getDisplayName());
  357. int res = JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(), message, getString("DLG_TITLE_DeletedConnection"), JOptionPane.YES_NO_OPTION);
  358. if (res == JOptionPane.YES_OPTION) {
  359. ServerList.addServer(record.getExecutionEnvironment(), record.getDisplayName(), record.getSyncFactory(), false, true);
  360. } else {
  361. return;
  362. }
  363. }
  364. // start validation phase
  365. wrapper = new CancellableTask() {
  366. @Override
  367. public boolean cancel() {
  368. return actionWorker.cancel();
  369. }
  370. @Override
  371. public void runImpl() {
  372. try {
  373. if (!ConnectionManager.getInstance().isConnectedTo(record.getExecutionEnvironment())) {
  374. ConnectionManager.getInstance().connectTo(record.getExecutionEnvironment());
  375. }
  376. record.validate(true);
  377. // initialize compiler sets for remote host if needed
  378. CompilerSetManager csm = CompilerSetManager.get(record.getExecutionEnvironment());
  379. csm.initialize(true, true, null);
  380. } catch (CancellationException ex) {
  381. cancel();
  382. } catch (Exception e) {
  383. e.printStackTrace(System.err);
  384. final String message = MessageFormat.format(getString("ERR_Cant_Connect"), record.getDisplayName()); //NOI18N
  385. final String title = getString("DLG_TITLE_Cant_Connect"); //NOI18N
  386. SwingUtilities.invokeLater(new Runnable() {
  387. @Override
  388. public void run() {
  389. JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
  390. message, title, JOptionPane.ERROR_MESSAGE);
  391. }
  392. });
  393. }
  394. if (record.isOnline()) {
  395. actionWorker.run();
  396. }
  397. }
  398. };
  399. }
  400. Frame mainWindow = WindowManager.getDefault().getMainWindow();
  401. String msg = NbBundle.getMessage(MakeActionProvider.class, "MSG_Validate_Host", record.getDisplayName());
  402. String title = NbBundle.getMessage(MakeActionProvider.class, "DLG_TITLE_Validate_Host");
  403. ModalMessageDlg.runLongTask(mainWindow, wrapper, null, wrapper, title, msg);
  404. }
  405. private void addAction(ArrayList<ProjectActionEvent> actionEvents,
  406. MakeConfigurationDescriptor pd, MakeConfiguration conf, String command, Lookup context,
  407. CanceledState cancelled) throws IllegalArgumentException {
  408. if (cancelled.isCanceled()) {
  409. return;
  410. }
  411. AtomicBoolean validated = new AtomicBoolean(false);
  412. lastValidation = false;
  413. String[] targetNames = getTargetNames(command);
  414. if (targetNames == null || targetNames.length == 0) {
  415. return;
  416. }
  417. for (int i = 0; i < targetNames.length; i++) {
  418. final String targetName = targetNames[i];
  419. List<String> tail = new ArrayList<String>();
  420. for (int j = i + 1; j < targetNames.length; j++) {
  421. tail.add(targetNames[j]);
  422. }
  423. List<String> delegate = validateStep(targetName, tail);
  424. if (delegate != null) {
  425. for (String target : delegate) {
  426. if (!addTarget(target, actionEvents, pd, conf, context, cancelled, validated)) {
  427. break;
  428. }
  429. }
  430. } else {
  431. if (!addTarget(targetName, actionEvents, pd, conf, context, cancelled, validated)) {
  432. break;
  433. }
  434. }
  435. }
  436. }
  437. private boolean addTarget(String targetName, ArrayList<ProjectActionEvent> actionEvents,
  438. MakeConfigurationDescriptor pd, MakeConfiguration conf, Lookup context, CanceledState cancelled, AtomicBoolean validated) throws IllegalArgumentException {
  439. if (cancelled.isCanceled()) {
  440. return false; // getPlatformInfo() might be costly for remote host
  441. }
  442. if (targetName.equals(SAVE_STEP)) {
  443. return onSaveStep();
  444. } else if (targetName.equals(VALIDATE_TOOLCHAIN)) {
  445. return onValidateToolchainStep(pd, conf, cancelled, validated);
  446. } else if (targetName.equals(BUILD_STEP)) {
  447. return onBuildStep(actionEvents, pd, conf, ProjectActionEvent.PredefinedType.BUILD);
  448. } else if (targetName.equals(BUILD_TESTS_STEP)) {
  449. return onBuildStep(actionEvents, pd, conf, ProjectActionEvent.PredefinedType.BUILD_TESTS);
  450. } else if (targetName.equals(BUILD_PACKAGE_STEP)) {
  451. return onBuildPackageStep(actionEvents, conf, ProjectActionEvent.PredefinedType.BUILD);
  452. } else if (targetName.equals(CLEAN_STEP)) {
  453. return onCleanStep(actionEvents, pd, conf, ProjectActionEvent.PredefinedType.CLEAN);
  454. } else if (targetName.equals(COMPILE_SINGLE_STEP)) {
  455. return onCompileSingleStep(actionEvents, pd, conf, context, ProjectActionEvent.PredefinedType.BUILD);
  456. } else if (targetName.equals(RUN_STEP)) {
  457. return onRunStep(actionEvents, pd, conf, cancelled, validated, context, ProjectActionEvent.PredefinedType.RUN);
  458. } else if (targetName.equals(TEST_STEP)) {
  459. return onRunStep(actionEvents, pd, conf, cancelled, validated, context, ProjectActionEvent.PredefinedType.TEST);
  460. } else if (targetName.equals(TEST_SINGLE_STEP)) {
  461. return onTestSingleStep(actionEvents, pd, conf, context, ProjectActionEvent.PredefinedType.TEST);
  462. } else if (targetName.equals(RUN_SINGLE_STEP) || targetName.equals(DEBUG_SINGLE_STEP)) {
  463. return onRunSingleStep(conf, actionEvents, context, ProjectActionEvent.PredefinedType.RUN);
  464. } else if (targetName.equals(DEBUG_STEP)) {
  465. return onRunStep(actionEvents, pd, conf, cancelled, validated, context, ProjectActionEvent.PredefinedType.DEBUG);
  466. } else if (targetName.equals(DEBUG_TEST_STEP)) {
  467. return onRunStep(actionEvents, pd, conf, cancelled, validated, context, ProjectActionEvent.PredefinedType.DEBUG_TEST);
  468. } else if (targetName.equals(DEBUG_STEPINTO_STEP)) {
  469. return onRunStep(actionEvents, pd, conf, cancelled, validated, context, ProjectActionEvent.PredefinedType.DEBUG_STEPINTO);
  470. } else if (targetName.equals(DEBUG_STEPINTO_TEST_STEP)) {
  471. return onRunStep(actionEvents, pd, conf, cancelled, validated, context, ProjectActionEvent.PredefinedType.DEBUG_STEPINTO_TEST);
  472. } else if (targetName.equals(CUSTOM_ACTION_STEP)) {
  473. return onCustomActionStep(actionEvents, conf, context, ProjectActionEvent.PredefinedType.CUSTOM_ACTION);
  474. }
  475. return onExtendedStep(actionEvents, conf, context, targetName);
  476. }
  477. private boolean onSaveStep() {
  478. // Save all files and projects
  479. if (MakeOptions.getInstance().getSave()) {
  480. LifecycleManager.getDefault().saveAll();
  481. }
  482. if (!ProjectSupport.saveAllProjects(getString("NeedToSaveAllText"))) {// NOI18N
  483. return false;
  484. }
  485. return true;
  486. }
  487. private boolean onRunStep(ArrayList<ProjectActionEvent> actionEvents, MakeConfigurationDescriptor pd, MakeConfiguration conf, CanceledState cancelled, AtomicBoolean validated, Lookup context, Type actionEvent) {
  488. PlatformInfo pi = conf.getPlatformInfo();
  489. validated.set(true);
  490. Folder targetFolder = context.lookup(Folder.class);
  491. if (targetFolder == null) {
  492. Node node = context.lookup(Node.class);
  493. if (node != null) {
  494. targetFolder = (Folder) node.getValue("Folder"); // NOI18N
  495. }
  496. }
  497. if (targetFolder != null) { // DEBUG TEST
  498. String path = ""; // NOI18N
  499. if (targetFolder.isTest()) {
  500. CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
  501. if (compilerSet != null) {
  502. path = targetFolder.getFolderConfiguration(conf).getLinkerConfiguration().getOutputValue();
  503. path = conf.expandMacros(path);
  504. path = CndPathUtilitities.toAbsolutePath(conf.getBaseDir(), path);
  505. conf = conf.clone(); // Replacing output path with test output path
  506. StringConfiguration sc = new StringConfiguration(null, "OutputPath"); // NOI18N
  507. sc.setValue(path);
  508. conf.getLinkerConfiguration().setOutput(sc);
  509. }
  510. }
  511. RunProfile runProfile = createRunProfile(conf, cancelled);
  512. if (runProfile == null) {
  513. if (cancelled.isCanceled()) {
  514. return false; // getEnv() might be costly for remote host
  515. }
  516. }
  517. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, path, conf, runProfile, false);
  518. actionEvents.add(projectActionEvent);
  519. } else if (actionEvent == ProjectActionEvent.PredefinedType.TEST) { // RUN TEST
  520. if (conf.isCompileConfiguration() && !validateProject(conf)) {
  521. return true;
  522. }
  523. MakeArtifact makeArtifact = new MakeArtifact(pd, conf);
  524. String buildCommand;
  525. buildCommand = makeArtifact.getBuildCommand(getMakeCommand(pd, conf), "test"); // NOI18N
  526. String args = "";
  527. int index = getArgsIndex(buildCommand);
  528. if (index > 0) {
  529. args = buildCommand.substring(index + 1);
  530. buildCommand = removeQuotes(buildCommand.substring(0, index));
  531. }
  532. RunProfile profile = new RunProfile(makeArtifact.getWorkingDirectory(), conf.getDevelopmentHost().getBuildPlatform(), conf);
  533. profile.setArgs(args);
  534. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, buildCommand, conf, profile, true);
  535. actionEvents.add(projectActionEvent);
  536. } else if (conf.isMakefileConfiguration()) { // RUN UNMANAGED
  537. String path;
  538. if (actionEvent == ProjectActionEvent.PredefinedType.RUN) {
  539. path = conf.getMakefileConfiguration().getOutput().getValue();
  540. if (path.length() > 0 && !CndPathUtilitities.isPathAbsolute(path)) {
  541. // make path relative to run working directory
  542. // path here should always be in unix style, see issue 149404
  543. path = conf.getMakefileConfiguration().getAbsOutput();
  544. path = CndPathUtilitities.toRelativePath(conf.getProfile().getRunDirectory(), path);
  545. }
  546. } else {
  547. // Always absolute
  548. path = conf.getMakefileConfiguration().getAbsOutput();
  549. path = CndPathUtilitities.normalizeSlashes(path);
  550. }
  551. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, path, conf, null, false);
  552. actionEvents.add(projectActionEvent);
  553. } else if (conf.isLibraryConfiguration()) {
  554. String path;
  555. if (actionEvent == ProjectActionEvent.PredefinedType.RUN) {
  556. path = conf.getProfile().getRunCommand().getValue();
  557. if (path.length() > 0 && !CndPathUtilitities.isPathAbsolute(path)) {
  558. // make path relative to run working directory
  559. // path here should always be in unix style, see issue 149404
  560. path = conf.getMakefileConfiguration().getAbsOutput();
  561. path = CndPathUtilitities.toRelativePath(conf.getProfile().getRunDirectory(), path);
  562. }
  563. } else {
  564. // Always absolute
  565. path = conf.getMakefileConfiguration().getAbsOutput();
  566. path = CndPathUtilitities.normalizeSlashes(path);
  567. }
  568. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, path, conf, null, false);
  569. actionEvents.add(projectActionEvent);
  570. } else if (conf.isApplicationConfiguration()) { // RUN MANAGED
  571. RunProfile runProfile = createRunProfile(conf, cancelled);
  572. if (runProfile == null) {
  573. if (cancelled.isCanceled()) {
  574. return false; // getEnv() might be costly for remote host
  575. }
  576. }
  577. MakeArtifact makeArtifact = new MakeArtifact(pd, conf);
  578. String path;
  579. if (actionEvent == ProjectActionEvent.PredefinedType.RUN) {
  580. // naturalize if relative
  581. path = makeArtifact.getOutput();
  582. //TODO: we also need remote aware CndPathUtilitities..........
  583. if (!CndPathUtilitities.isPathAbsolute(path)) {
  584. // make path relative to run working directory
  585. path = makeArtifact.getWorkingDirectory() + "/" + path; // NOI18N
  586. path = CndPathUtilitities.naturalizeSlashes(path);
  587. path = CndPathUtilitities.toRelativePath(conf.getProfile().getRunDirectory(), path);
  588. path = CndPathUtilitities.naturalizeSlashes(path);
  589. }
  590. } else {
  591. // Always absolute
  592. path = CndPathUtilitities.toAbsolutePath(conf.getBaseDir(), makeArtifact.getOutput());
  593. }
  594. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, path, conf, runProfile, false, context);
  595. actionEvents.add(projectActionEvent);
  596. } else {
  597. assert false;
  598. }
  599. return true;
  600. }
  601. private static RunProfile createRunProfile(MakeConfiguration conf, CanceledState cancelled) {
  602. RunProfile runProfile = null;
  603. PlatformInfo pi = conf.getPlatformInfo();
  604. int platform = conf.getDevelopmentHost().getBuildPlatform();
  605. if (platform == PlatformTypes.PLATFORM_WINDOWS) {
  606. // On Windows we need to add paths to dynamic libraries from subprojects to PATH
  607. runProfile = conf.getProfile().clone(conf);
  608. Set<String> subProjectOutputLocations = conf.getSubProjectOutputLocations();
  609. StringBuilder path = new StringBuilder();
  610. // Add paths from subprojetcs
  611. Iterator<String> iter = subProjectOutputLocations.iterator();
  612. while (iter.hasNext()) {
  613. String location = CndPathUtilitities.naturalizeSlashes(iter.next());
  614. if (path.length() > 0) {
  615. path.append(';');
  616. }
  617. path.append(location);
  618. }
  619. // Add paths from -L option
  620. List<String> list = conf.getLinkerConfiguration().getAdditionalLibs().getValue();
  621. iter = list.iterator();
  622. while (iter.hasNext()) {
  623. String location = CndPathUtilitities.naturalizeSlashes(iter.next());
  624. if (path.length() > 0) {
  625. path.append(';');
  626. }
  627. path.append(location);
  628. }
  629. String userPath = runProfile.getEnvironment().getenv(pi.getPathName());
  630. if (userPath == null) {
  631. if (cancelled.isCanceled()) {
  632. return null; // getEnv() might be costly for remote host
  633. }
  634. userPath = HostInfoProvider.getEnv(conf.getDevelopmentHost().getExecutionEnvironment()).get(pi.getPathName());
  635. }
  636. if (userPath != null && !userPath.isEmpty()) {
  637. if (path.length() > 0) {
  638. path.append(';');
  639. }
  640. path.append(userPath);
  641. }
  642. runProfile.getEnvironment().putenv(pi.getPathName(), path.toString());
  643. } else if (platform == PlatformTypes.PLATFORM_MACOSX) {
  644. // On Mac OS X we need to add paths to dynamic libraries from subprojects to DYLD_LIBRARY_PATH
  645. StringBuilder path = new StringBuilder();
  646. Set<String> subProjectOutputLocations = conf.getSubProjectOutputLocations();
  647. // Add paths from subprojetcs
  648. Iterator<String> iter = subProjectOutputLocations.iterator();
  649. while (iter.hasNext()) {
  650. String location = CndPathUtilitities.naturalizeSlashes(iter.next());
  651. if (path.length() > 0) {
  652. path.append(":"); // NOI18N
  653. }
  654. path.append(location);
  655. }
  656. // Add paths from -L option
  657. List<String> list = conf.getLinkerConfiguration().getAdditionalLibs().getValue();
  658. iter = list.iterator();
  659. while (iter.hasNext()) {
  660. String location = CndPathUtilitities.naturalizeSlashes(iter.next());
  661. if (path.length() > 0) {
  662. path.append(":"); // NOI18N
  663. }
  664. path.append(location);
  665. }
  666. if (path.length() > 0) {
  667. runProfile = conf.getProfile().clone(conf);
  668. String extPath = runProfile.getEnvironment().getenv("DYLD_LIBRARY_PATH"); // NOI18N
  669. if (extPath == null) {
  670. if (cancelled.isCanceled()) {
  671. return null; // getEnv() might be costly for remote host
  672. }
  673. extPath = HostInfoProvider.getEnv(conf.getDevelopmentHost().getExecutionEnvironment()).get("DYLD_LIBRARY_PATH"); // NOI18N
  674. }
  675. if (extPath != null) {
  676. path.append(":").append(extPath); // NOI18N
  677. }
  678. runProfile.getEnvironment().putenv("DYLD_LIBRARY_PATH", path.toString()); // NOI18N
  679. }
  680. } else if (platform == PlatformTypes.PLATFORM_SOLARIS_INTEL || platform == PlatformTypes.PLATFORM_SOLARIS_SPARC || platform == PlatformTypes.PLATFORM_LINUX) {
  681. // Add paths from -L option
  682. StringBuilder path = new StringBuilder();
  683. List<String> list = conf.getLinkerConfiguration().getAdditionalLibs().getValue();
  684. Iterator<String> iter = list.iterator();
  685. while (iter.hasNext()) {
  686. String location = CndPathUtilitities.naturalizeSlashes(iter.next());
  687. if (path.length() > 0) {
  688. path.append(":"); // NOI18N
  689. }
  690. path.append(location);
  691. }
  692. if (path.length() > 0) {
  693. runProfile = conf.getProfile().clone(conf);
  694. String extPath = runProfile.getEnvironment().getenv("LD_LIBRARY_PATH"); // NOI18N
  695. if (extPath == null) {
  696. if (cancelled.isCanceled()) {
  697. return null; // NOI18N
  698. }
  699. extPath = HostInfoProvider.getEnv(conf.getDevelopmentHost().getExecutionEnvironment()).get("LD_LIBRARY_PATH"); // NOI18N
  700. }
  701. if (extPath != null) {
  702. path.append(":").append(extPath); // NOI18N
  703. }
  704. runProfile.getEnvironment().putenv("LD_LIBRARY_PATH", path.toString()); // NOI18N
  705. }
  706. // make sure OMP_NUM_THREADS is set to something reasonable
  707. // See 169981 for details
  708. String ont = HostInfoProvider.getEnv(conf.getDevelopmentHost().getExecutionEnvironment()).get("OMP_NUM_THREADS"); // NOI18N
  709. if (ont == null) {
  710. ont = conf.getProfile().getEnvironment().getenv("OMP_NUM_THREADS"); // NOI18N
  711. }
  712. if (ont == null) {
  713. if (runProfile == null) {
  714. runProfile = conf.getProfile().clone(conf);
  715. }
  716. runProfile.getEnvironment().putenv("OMP_NUM_THREADS", "2"); // NOI18N
  717. }
  718. }
  719. if (platform == PlatformTypes.PLATFORM_MACOSX || platform == PlatformTypes.PLATFORM_SOLARIS_INTEL || platform == PlatformTypes.PLATFORM_SOLARIS_SPARC || platform == PlatformTypes.PLATFORM_LINUX) {
  720. // Make sure DISPLAY variable has been set
  721. if (cancelled.isCanceled()) {
  722. return null; // getEnv() might be costly for remote host
  723. }
  724. if (conf.getDevelopmentHost().getExecutionEnvironment().isLocal()
  725. && HostInfoProvider.getEnv(conf.getDevelopmentHost().getExecutionEnvironment()).get("DISPLAY") == null && // NOI18N
  726. conf.getProfile().getEnvironment().getenv("DISPLAY") == null) {// NOI18N
  727. // DISPLAY hasn't been set
  728. if (runProfile == null) {
  729. runProfile = conf.getProfile().clone(conf);
  730. }
  731. runProfile.getEnvironment().putenv("DISPLAY", ":0.0"); // NOI18N
  732. }
  733. }
  734. return runProfile;
  735. }
  736. private boolean onRunSingleStep(MakeConfiguration conf, ArrayList<ProjectActionEvent> actionEvents, Lookup context, Type actionEvent) {
  737. // FIXUP: not sure this is used...
  738. if (conf.isMakefileConfiguration()) {
  739. DataObject d = context.lookup(DataObject.class);
  740. String path = CndFileUtils.toFile(d.getPrimaryFile()).getPath();
  741. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, path, conf, null, false);
  742. actionEvents.add(projectActionEvent);
  743. } else {
  744. assert false;
  745. }
  746. return true;
  747. }
  748. private boolean onBuildStep(ArrayList<ProjectActionEvent> actionEvents, MakeConfigurationDescriptor pd, MakeConfiguration conf, Type actionEvent) {
  749. if (conf.isCompileConfiguration() && !validateProject(conf)) {
  750. return true;
  751. }
  752. MakeArtifact makeArtifact = new MakeArtifact(pd, conf);
  753. String buildCommand;
  754. String makeCommand = getMakeCommand(pd, conf);
  755. if (actionEvent == ProjectActionEvent.PredefinedType.BUILD_TESTS) {
  756. buildCommand = makeArtifact.getBuildCommand(makeCommand, "build-tests"); // NOI18N
  757. } else {
  758. if (conf.getRemoteMode() == RemoteProject.Mode.REMOTE_SOURCES) {
  759. String buildCommandFromProjectProperties = conf.getMakefileConfiguration().getBuildCommand().getValue();
  760. buildCommand = makeArtifact.getBuildCommand(buildCommandFromProjectProperties, makeCommand, ""); // NOI18N
  761. } else {
  762. buildCommand = makeArtifact.getBuildCommand(makeCommand, ""); // NOI18N
  763. }
  764. }
  765. String args = "";
  766. int index = getArgsIndex(buildCommand);
  767. if (index > 0) {
  768. args = buildCommand.substring(index + 1);
  769. buildCommand = removeQuotes(buildCommand.substring(0, index));
  770. }
  771. RunProfile profile = new RunProfile(makeArtifact.getWorkingDirectory(), conf.getDevelopmentHost().getBuildPlatform(), conf);
  772. profile.setArgs(args);
  773. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, buildCommand, conf, profile, true);
  774. actionEvents.add(projectActionEvent);
  775. return true;
  776. }
  777. private boolean onBuildPackageStep(ArrayList<ProjectActionEvent> actionEvents, MakeConfiguration conf, Type actionEvent) {
  778. if (!validatePackaging(conf)) {
  779. actionEvents.clear();
  780. return true;
  781. }
  782. final String script = "nbproject/Package-" + conf.getName() + ".bash"; // NOI18N
  783. final RunProfile profile = new RunProfile(conf.getBaseDir(), conf.getDevelopmentHost().getBuildPlatform(), conf);
  784. String buildCommand = null;
  785. if (conf.getDevelopmentHost().getBuildPlatform() == PlatformTypes.PLATFORM_WINDOWS) {
  786. HostInfo hostInfo;
  787. try {
  788. hostInfo = HostInfoUtils.getHostInfo(conf.getDevelopmentHost().getExecutionEnvironment());
  789. buildCommand = hostInfo.getShell();
  790. } catch (IOException ex) {
  791. Exceptions.printStackTrace(ex);
  792. } catch (CancellationException ex) {
  793. Exceptions.printStackTrace(ex);
  794. }
  795. if (buildCommand == null) {
  796. buildCommand = "sh.exe"; // NOI18N
  797. }
  798. } else {
  799. buildCommand = "bash"; // NOI18N
  800. }
  801. if (conf.getPackagingConfiguration().getVerbose().getValue()) {
  802. profile.setArgs(new String[] {"-x", script}); // NOI18N
  803. } else {
  804. profile.setArgs(new String[] {script});
  805. }
  806. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, buildCommand, conf, profile, true);
  807. actionEvents.add(projectActionEvent);
  808. return true;
  809. }
  810. private boolean onCleanStep(ArrayList<ProjectActionEvent> actionEvents, MakeConfigurationDescriptor pd, MakeConfiguration conf, Type actionEvent) {
  811. MakeArtifact makeArtifact = new MakeArtifact(pd, conf);
  812. String buildCommand = makeArtifact.getCleanCommand(getMakeCommand(pd, conf), ""); // NOI18N
  813. String args = ""; // NOI18N
  814. int index = getArgsIndex(buildCommand);
  815. if (index > 0) {
  816. args = buildCommand.substring(index + 1);
  817. buildCommand = removeQuotes(buildCommand.substring(0, index));
  818. }
  819. RunProfile profile = new RunProfile(makeArtifact.getWorkingDirectory(), conf.getDevelopmentHost().getBuildPlatform(), conf);
  820. profile.setArgs(args);
  821. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, buildCommand, conf, profile, true);
  822. actionEvents.add(projectActionEvent);
  823. return true;
  824. }
  825. private boolean onExtendedStep(ArrayList<ProjectActionEvent> actionEvents, MakeConfiguration conf, Lookup context, final String extendedStep) {
  826. Type actionEvent = new MyType(extendedStep);
  827. ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, null, conf, null, true, context);
  828. actionEvents.add(projectActionEvent);
  829. return true;
  830. }
  831. private boolean onCompileSingleStep(ArrayList<ProjectActionEvent> actionEvents, MakeConfigurationDescriptor pd, MakeConfiguration conf, Lookup context, Type actionEvent) {
  832. Iterator<? extends Node> it = context.lookupAll(Node.class).iterator();
  833. while (it.hasNext()) {
  834. Node node = it.next();
  835. Item item = getNoteItem(node); // NOI18N
  836. if (item == null) {
  837. return false;
  838. }
  839. ItemConfiguration itemConfiguration = item.getItemConfiguration(conf); //ItemConfiguration)conf.getAuxObject(ItemConfiguration.getId(item.getPath()));
  840. if (itemConfiguration == null) {
  841. return false;
  842. }
  843. if (itemConfiguration.getExcluded().getValue()) {
  844. return false;
  845. }
  846. if (itemConfiguration.getTool() == PredefinedToolKind.CustomTool && !itemConfiguration.getCustomToolConfiguration().getModified()) {
  847. return false;
  848. }
  849. MakeArtifact makeArtifact = new MakeArtifact(pd, conf);
  850. String outputFile = getOutputFile(conf, item, itemConfiguration);
  851. if (conf.isMakefileConfiguration()) {
  852. return compileSingleUnmanage(actionEvents, conf, makeArtifact, context, actionEvent, item, itemConfiguration);
  853. } else {
  854. compileSingleManage(actionEvents, conf, makeArtifact, context, actionEvent, pd, outputFile);
  855. }
  856. }
  857. return true;
  858. }
  859. private String getOutputFile(MakeConfiguration conf, Item item, ItemConfiguration itemConfiguration) {
  860. String outputFile = null;
  861. if (itemConfiguration.getTool() == PredefinedToolKind.CCompiler) {
  862. CCompilerConfiguration cCompilerConfiguration = itemConfiguration.getCCompilerConfiguration();
  863. outputFile = cCompilerConfiguration.getOutputFile(item, conf, false);
  864. if(item.getFolder().isTest()) {
  865. outputFile = outputFile.replace(MakeConfiguration.OBJECTDIR_MACRO, "${TESTDIR}"); // NOI18N
  866. }
  867. } else if (itemConfiguration.getTool() == PredefinedToolKind.CCCompiler) {
  868. CCCompilerConfiguration ccCompilerConfiguration = itemConfiguration.getCCCompilerConfiguration();
  869. outputFile = ccCompilerConfiguration.getOutputFile(item, conf, false);
  870. if(item.getFolder().isTest()) {
  871. outputFile = outputFile.replace(MakeConfiguration.OBJECTDIR_MACRO, "${TESTDIR}"); // NOI18N
  872. }
  873. } else if (itemConfiguration.getTool() == PredefinedToolKind.FortranCompiler) {
  874. FortranCompilerConfiguration fortranCompilerConfiguration = itemConfiguration.getFortranCompilerConfiguration();
  875. outputFile = fortranCompilerConfiguration.getOutputFile(item, conf, false);
  876. if(item.getFolder().isTest()) {
  877. outputFile = outputFile.replace(MakeConfiguration.OBJECTDIR_MACRO, "${TESTDIR}"); // NOI18N
  878. }
  879. } else if (itemConfiguration.getTool() == PredefinedToolKind.Assembler) {
  880. AssemblerConfiguration assemblerConfiguration = itemConfiguration.getAssemblerConfiguration();
  881. outputFile = assemblerConfiguration.getOutputFile(item, conf, false);
  882. if(item.getFolder().isTest()) {
  883. outputFile = outputFile.replace(MakeConfiguration.OBJECTDIR_MACRO, "${TESTDIR}"); // NOI18N
  884. }
  885. } else if (itemConfiguration.getTool() == PredefinedToolKind.CustomTool) {
  886. CustomToolConfiguration customToolConfiguration = itemConfiguration.getCustomToolConfiguration();
  887. outputFile = customToolConfiguration.getOutputs().getValue();
  888. }
  889. return conf.expandMacros(outputFile);
  890. }
  891. private boolean compileSingleUnmanage(ArrayList<ProjectActionEvent> actionEvents, MakeConfiguration conf, MakeArtifact makeArtifact, Lookup context, Type actionEvent, Item item, ItemConfiguration itemConfiguration) {
  892. CompilerSet compilerSet = conf.getCompilerSet().getCompilerSet();
  893. AbstractCompiler ccCompiler = null;
  894. AllOptionsProvider optionProvider = null;
  895. if (itemConfiguration.getTool() == PredefinedToolKind.CCompiler) {
  896. ccCompiler = compilerSet == null ? null : (AbstractCompiler)compilerSet.getTool(PredefinedToolKind.CCompiler);
  897. optionProvider = itemConfiguration.getCCompilerConfiguration();
  898. } else if (itemConfiguration.getTool() == PredefinedToolKind.CCCompiler) {
  899. ccCompiler = compilerSet == null ? null : (AbstractCompiler)compilerSet.getTool(PredefinedToolKind.CCCompiler);
  900. optionProvider = itemConfiguration.getCCCompilerConfiguration();
  901. }
  902. if (ccCompiler == null) {
  903. return false;
  904. }
  905. AllOptionsProvider options = CompileOptionsProvider.getDefault().getOptions(item);
  906. if (options != null) {
  907. String compileLine = options.getAllOptions(ccCompiler);
  908. if (compileLine != null) {
  909. int hasPath = compileLin