PageRenderTime 28ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/projects/netbeans-7.3/cnd.toolchain/src/org/netbeans/modules/cnd/toolchain/compilerset/ToolchainManagerImpl.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 1161 lines | 1060 code | 44 blank | 57 comment | 325 complexity | 291c2585bf4cc8dd6bbfddaf1912a254 MD5 | raw file
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 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. * If you wish your version of this file to be governed by only the CDDL
  28. * or only the GPL Version 2, indicate your decision by adding
  29. * "[Contributor] elects to include this software in this distribution
  30. * under the [CDDL or GPL Version 2] license." If you do not indicate a
  31. * single choice of license, a recipient has the option to distribute
  32. * your version of this file under either the CDDL, the GPL Version 2 or
  33. * to extend the choice of license to its licensees as provided above.
  34. * However, if you add GPL Version 2 code and therefore, elected the GPL
  35. * Version 2 license, then the option applies only if the new code is
  36. * made subject to such option by the copyright holder.
  37. *
  38. * Contributor(s):
  39. *
  40. * Portions Copyrighted 2008 Sun Microsystems, Inc.
  41. */
  42. package org.netbeans.modules.cnd.toolchain.compilerset;
  43. import java.io.IOException;
  44. import java.io.InputStream;
  45. import java.io.OutputStream;
  46. import java.util.ArrayList;
  47. import java.util.HashMap;
  48. import java.util.HashSet;
  49. import java.util.List;
  50. import java.util.Map;
  51. import java.util.MissingResourceException;
  52. import java.util.ResourceBundle;
  53. import java.util.Set;
  54. import java.util.TreeMap;
  55. import java.util.logging.Level;
  56. import java.util.logging.Logger;
  57. import javax.xml.parsers.SAXParser;
  58. import javax.xml.parsers.SAXParserFactory;
  59. import org.netbeans.modules.cnd.api.toolchain.PlatformTypes;
  60. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.AlternativePath;
  61. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.BaseFolder;
  62. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.CMakeDescriptor;
  63. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.CompilerDescriptor;
  64. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.DebuggerDescriptor;
  65. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.LinkerDescriptor;
  66. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.MakeDescriptor;
  67. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.PredefinedMacro;
  68. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.QMakeDescriptor;
  69. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.ScannerDescriptor;
  70. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.ScannerPattern;
  71. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.ToolDescriptor;
  72. import org.netbeans.modules.cnd.api.toolchain.ToolchainManager.ToolchainDescriptor;
  73. import org.openide.filesystems.FileLock;
  74. import org.openide.filesystems.FileObject;
  75. import org.openide.filesystems.FileUtil;
  76. import org.openide.util.Exceptions;
  77. import org.openide.util.NbBundle;
  78. import org.openide.util.NbPreferences;
  79. import org.openide.util.Utilities;
  80. import org.openide.xml.XMLUtil;
  81. import org.w3c.dom.DOMException;
  82. import org.w3c.dom.Document;
  83. import org.w3c.dom.Element;
  84. import org.xml.sax.InputSource;
  85. import org.xml.sax.SAXException;
  86. import org.xml.sax.XMLReader;
  87. import org.xml.sax.helpers.DefaultHandler;
  88. /**
  89. *
  90. * @author Alexander Simon
  91. */
  92. @SuppressWarnings({"PackageVisibleInnerClass","PackageVisibleField"})
  93. public final class ToolchainManagerImpl {
  94. private static final Logger LOG = Logger.getLogger(ToolchainManagerImpl.class.getName());
  95. public static final boolean TRACE = Boolean.getBoolean("cnd.toolchain.personality.trace"); // NOI18N
  96. private static final boolean CREATE_SHADOW = Boolean.getBoolean("cnd.toolchain.personality.create_shadow"); // NOI18N
  97. public static final String SHADOW_KEY = "toolchain_shadow"; // NOI18N
  98. public static final String ROOT_FOLDER = "CND"; // NOI18N
  99. public static final String SHADOW_FOLDER = "ToolChain"; // NOI18N
  100. public static final String TOOLCHAIN_FOLDER = "ToolChains"; // NOI18N
  101. public static final String TOOL_FOLDER = "Tool"; // NOI18N
  102. private static final ToolchainManagerImpl manager = new ToolchainManagerImpl();
  103. private List<ToolchainDescriptor> descriptors = new ArrayList<ToolchainDescriptor>();
  104. public static ToolchainManagerImpl getImpl() {
  105. return manager;
  106. }
  107. private ToolchainManagerImpl() {
  108. if (NbPreferences.forModule(ToolchainManagerImpl.class).getBoolean(SHADOW_KEY, false)) {
  109. initToolchainManager();
  110. } else {
  111. initToolchainManager2();
  112. }
  113. }
  114. private void initToolchainManager() {
  115. try {
  116. Map<Integer, CompilerVendor> vendors = new TreeMap<Integer, CompilerVendor>();
  117. Map<String, String> cache = new HashMap<String, String>();
  118. FileObject folder = FileUtil.getConfigFile(ROOT_FOLDER+"/"+SHADOW_FOLDER); // NOI18N
  119. int indefinedID = Integer.MAX_VALUE / 2;
  120. if (folder != null && folder.isFolder()) {
  121. FileObject[] files = folder.getChildren();
  122. for (FileObject file : files) {
  123. Integer position = (Integer) file.getAttribute("position"); // NOI18N
  124. if (position == null || vendors.containsKey(position)) {
  125. position = indefinedID++;
  126. }
  127. String displayName = (String) file.getAttribute("displayName"); // NOI18N
  128. CompilerVendor v = new CompilerVendor(file.getNameExt(), position.intValue());
  129. if (read(file, files, v, new HashSet<FileObject>(), cache)) {
  130. if (displayName != null && !displayName.isEmpty()) {
  131. v.toolChainDisplay = displayName;
  132. }
  133. vendors.put(position, v);
  134. }
  135. }
  136. }
  137. for (CompilerVendor v : vendors.values()) {
  138. descriptors.add(new ToolchainDescriptorImpl(v));
  139. }
  140. } catch (Throwable e) {
  141. e.printStackTrace(System.err);
  142. }
  143. if (CREATE_SHADOW && !NbPreferences.forModule(ToolchainManagerImpl.class).getBoolean(SHADOW_KEY, false)) {
  144. try {
  145. writeToolchains();
  146. NbPreferences.forModule(ToolchainManagerImpl.class).putBoolean(SHADOW_KEY, true);
  147. } catch (IOException ex) {
  148. ex.printStackTrace(System.err);
  149. }
  150. }
  151. }
  152. private void initToolchainManager2() {
  153. try {
  154. Map<Integer, CompilerVendor> vendors = new TreeMap<Integer, CompilerVendor>();
  155. Map<String, String> cache = new HashMap<String, String>();
  156. FileObject folder = FileUtil.getConfigFile(ROOT_FOLDER+"/"+TOOLCHAIN_FOLDER); // NOI18N
  157. FileObject[] files = FileUtil.getConfigFile(ROOT_FOLDER+"/"+TOOL_FOLDER).getChildren(); // NOI18N
  158. int indefinedID = Integer.MAX_VALUE / 2;
  159. if (folder != null && folder.isFolder()) {
  160. for (FileObject file : folder.getChildren()) {
  161. Integer position = (Integer) file.getAttribute("position"); // NOI18N
  162. if (position == null || vendors.containsKey(position)) {
  163. position = indefinedID++;
  164. }
  165. String displayName = null;
  166. String bundleName = (String)file.getAttribute("SystemFileSystem.localizingBundle"); // NOI18N
  167. if (bundleName != null) {
  168. try {
  169. bundleName = Utilities.translate(bundleName);
  170. ResourceBundle bundle = NbBundle.getBundle(bundleName);
  171. if (bundle != null) {
  172. displayName = bundle.getString(file.getPath());
  173. }
  174. } catch (MissingResourceException ex) {
  175. ex.printStackTrace(System.err);
  176. }
  177. }
  178. CompilerVendor v = new CompilerVendor(file.getNameExt()+".xml", position.intValue()); // NOI18N
  179. if (read2(file, files, v, cache)) {
  180. if (displayName != null && !displayName.isEmpty()) {
  181. v.toolChainDisplay = displayName;
  182. }
  183. vendors.put(position, v);
  184. }
  185. }
  186. }
  187. for (CompilerVendor v : vendors.values()) {
  188. descriptors.add(new ToolchainDescriptorImpl(v));
  189. }
  190. } catch (Throwable e) {
  191. e.printStackTrace(System.err);
  192. }
  193. if (CREATE_SHADOW && !NbPreferences.forModule(ToolchainManagerImpl.class).getBoolean(SHADOW_KEY, false)) {
  194. try {
  195. writeToolchains();
  196. NbPreferences.forModule(ToolchainManagerImpl.class).putBoolean(SHADOW_KEY, true);
  197. } catch (IOException ex) {
  198. ex.printStackTrace(System.err);
  199. }
  200. }
  201. }
  202. /**
  203. * available in package for testing only
  204. */
  205. public void reinitToolchainManager() {
  206. try {
  207. writeToolchains();
  208. NbPreferences.forModule(ToolchainManagerImpl.class).putBoolean(SHADOW_KEY, true);
  209. } catch (IOException ex) {
  210. ex.printStackTrace(System.err);
  211. }
  212. descriptors.clear();
  213. initToolchainManager();
  214. }
  215. public ToolchainDescriptor getToolchain(String name, int platform) {
  216. for (ToolchainDescriptor d : descriptors) {
  217. if (name.equals(d.getName()) && (ToolUtils.isPlatforSupported(platform, d)
  218. || ToolUtils.isPlatforSupported(PlatformTypes.PLATFORM_NONE, d))) {
  219. return d;
  220. }
  221. }
  222. for (ToolchainDescriptor d : descriptors) {
  223. if (ToolUtils.isPlatforSupported(PlatformTypes.PLATFORM_NONE, d)) {
  224. return d;
  225. }
  226. }
  227. return null;
  228. }
  229. public List<ToolchainDescriptor> getAllToolchains() {
  230. return new ArrayList<ToolchainDescriptor>(descriptors);
  231. }
  232. public List<ToolchainDescriptor> getToolchains(int platform) {
  233. List<ToolchainDescriptor> res = new ArrayList<ToolchainDescriptor>();
  234. for (ToolchainDescriptor d : descriptors) {
  235. if (ToolUtils.isPlatforSupported(platform, d)) {
  236. res.add(d);
  237. }
  238. }
  239. return res;
  240. }
  241. private boolean read(FileObject file, FileObject[] files, CompilerVendor v, Set<FileObject> antiloop, Map<String, String> cache) {
  242. if (antiloop.contains(file)) {
  243. LOG.log(Level.INFO, "Recursive inclusion of file {0}", file.getNameExt()); // NOI18N
  244. return false;
  245. }
  246. antiloop.add(file);
  247. String originalFile = (String) file.getAttribute("originalFile"); // NOI18N
  248. if (originalFile != null) {
  249. file = FileUtil.getConfigFile(originalFile);
  250. }
  251. String baseName = (String) file.getAttribute("extends"); // NOI18N
  252. if (baseName != null && baseName.length() > 0) {
  253. boolean find = false;
  254. for (FileObject base : files) {
  255. if (baseName.equals(base.getNameExt())) {
  256. if (!read(base, files, v, antiloop, cache)) {
  257. LOG.log(Level.INFO, "Cannot read base file {0}", base.getNameExt()); // NOI18N
  258. return false;
  259. }
  260. find = true;
  261. }
  262. }
  263. if (!find) {
  264. LOG.log(Level.INFO, "Cannot find base file {0}", baseName); // NOI18N
  265. }
  266. }
  267. try {
  268. read(file.getInputStream(), v, cache);
  269. return true;
  270. } catch (IOException ex) {
  271. ex.printStackTrace(System.err);
  272. }
  273. return false;
  274. }
  275. private boolean read2(FileObject file, FileObject[] files, CompilerVendor v, Map<String, String> cache) {
  276. for (FileObject fo : file.getChildren()){
  277. read(fo, files, v, new HashSet<FileObject>(), cache);
  278. }
  279. return true;
  280. }
  281. private boolean read(InputStream inputStream, CompilerVendor v, Map<String, String> cache) {
  282. SAXParserFactory spf = SAXParserFactory.newInstance();
  283. spf.setValidating(false);
  284. XMLReader xmlReader;
  285. try {
  286. SAXParser saxParser = spf.newSAXParser();
  287. xmlReader = saxParser.getXMLReader();
  288. } catch (Exception ex) {
  289. ex.printStackTrace(System.err);
  290. return false;
  291. }
  292. SAXHandler handler = new SAXHandler(v, cache);
  293. xmlReader.setContentHandler(handler);
  294. try {
  295. InputSource source = new InputSource(inputStream);
  296. xmlReader.parse(source);
  297. } catch (Exception ex) {
  298. ex.printStackTrace(System.err);
  299. return false;
  300. }
  301. return true;
  302. }
  303. private String unsplit(String[] array) {
  304. if (array == null) {
  305. return ""; // NOI18N
  306. }
  307. StringBuilder buf = new StringBuilder();
  308. for (String s : array) {
  309. if (buf.length() > 0) {
  310. buf.append(',');
  311. }
  312. buf.append(s);
  313. }
  314. return buf.toString();
  315. }
  316. /**
  317. * available in package for testing only
  318. */
  319. /*test*/public void writeToolchains() throws IOException {
  320. FileObject folder = FileUtil.getConfigFile(ROOT_FOLDER);
  321. FileObject shadow = folder.getFileObject(SHADOW_FOLDER);
  322. if (shadow == null) {
  323. shadow = folder.createFolder(SHADOW_FOLDER);
  324. }
  325. if (shadow != null && shadow.isFolder()) {
  326. for (ToolchainDescriptor descriptor : descriptors) {
  327. String name = descriptor.getFileName();
  328. FileObject file = shadow.getFileObject(name);
  329. if (file == null) {
  330. file = shadow.createData(name);
  331. }
  332. writeDescriptor(descriptor, file);
  333. ToolchainDescriptorImpl impl = (ToolchainDescriptorImpl) descriptor;
  334. file.setAttribute("position", Integer.valueOf(impl.v.position)); // NOI18N
  335. file.setAttribute("extends", ""); // NOI18N
  336. file.setAttribute("displayName", impl.v.toolChainDisplay); // NOI18N
  337. }
  338. }
  339. }
  340. private void writeDescriptor(ToolchainDescriptor descriptor, FileObject file) throws DOMException {
  341. //System.err.println("Found file " + file.getNameExt()); // NOI18N
  342. Document doc = XMLUtil.createDocument("toolchaindefinition", "http://www.netbeans.org/ns/cnd-toolchain-definition/1", null, null); // NOI18N
  343. Element root = doc.getDocumentElement();
  344. Element element;
  345. element = doc.createElement("toolchain"); // NOI18N
  346. element.setAttribute("name", descriptor.getName()); // NOI18N
  347. element.setAttribute("display", descriptor.getDisplayName()); // NOI18N
  348. element.setAttribute("family", unsplit(descriptor.getFamily())); // NOI18N
  349. if (descriptor.getQmakeSpec() != null) {
  350. element.setAttribute("qmakespec", descriptor.getQmakeSpec()); // NOI18N
  351. }
  352. if (descriptor.isAbstract()) {
  353. element.setAttribute("abstract", "true"); // NOI18N
  354. }
  355. if (!descriptor.isAutoDetected()) {
  356. element.setAttribute("auto_detected", "false"); // NOI18N
  357. }
  358. if (descriptor.getAliases().length > 0) {
  359. element.setAttribute("aliases", unsplit(descriptor.getAliases())); // NOI18N
  360. }
  361. if (descriptor.getSubsitute() != null) {
  362. element.setAttribute("subtitute", descriptor.getSubsitute()); // NOI18N
  363. }
  364. root.appendChild(element);
  365. if (descriptor.getUpdateCenterUrl() != null && descriptor.getModuleID() != null) {
  366. element = doc.createElement("download"); // NOI18N
  367. element.setAttribute("uc_url", descriptor.getUpdateCenterUrl()); // NOI18N
  368. element.setAttribute("module_id", descriptor.getModuleID()); // NOI18N
  369. element.setAttribute("uc_display", descriptor.getUpdateCenterDisplayName()); // NOI18N
  370. element.setAttribute("upgrade_url", descriptor.getUpgradeUrl()); // NOI18N
  371. root.appendChild(element);
  372. }
  373. element = doc.createElement("platforms"); // NOI18N
  374. element.setAttribute("stringvalue", unsplit(descriptor.getPlatforms())); // NOI18N
  375. root.appendChild(element);
  376. if (descriptor.getDriveLetterPrefix() != null) {
  377. element = doc.createElement("drive_letter_prefix"); // NOI18N
  378. element.setAttribute("stringvalue", descriptor.getDriveLetterPrefix()); // NOI18N
  379. root.appendChild(element);
  380. }
  381. if (descriptor.getMakefileWriter() != null) {
  382. element = doc.createElement("makefile_writer"); // NOI18N
  383. element.setAttribute("class", descriptor.getMakefileWriter()); // NOI18N
  384. root.appendChild(element);
  385. }
  386. if (descriptor.getBaseFolders() != null) {
  387. element = doc.createElement("base_folders"); // NOI18N
  388. root.appendChild(element);
  389. for (BaseFolder info : descriptor.getBaseFolders()) {
  390. Element p = doc.createElement("base_folder"); // NOI18N
  391. if (info.getFolderKey() != null) {
  392. p.setAttribute("regestry", info.getFolderKey()); // NOI18N
  393. }
  394. if (info.getFolderPattern() != null) {
  395. p.setAttribute("pattern", info.getFolderPattern()); // NOI18N
  396. }
  397. if (info.getFolderPathPattern() != null) {
  398. p.setAttribute("path_patern", info.getFolderPathPattern()); // NOI18N
  399. }
  400. if (info.getFolderSuffix() != null) {
  401. p.setAttribute("suffix", info.getFolderSuffix()); // NOI18N
  402. }
  403. element.appendChild(p);
  404. }
  405. }
  406. if (descriptor.getCommandFolders() != null) {
  407. element = doc.createElement("command_folders"); // NOI18N
  408. root.appendChild(element);
  409. for (BaseFolder info : descriptor.getCommandFolders()) {
  410. Element p = doc.createElement("command_folder"); // NOI18N
  411. if (info.getFolderKey() != null) {
  412. p.setAttribute("regestry", info.getFolderKey()); // NOI18N
  413. }
  414. if (info.getFolderPattern() != null) {
  415. p.setAttribute("pattern", info.getFolderPattern()); // NOI18N
  416. }
  417. if (info.getFolderPathPattern() != null) {
  418. p.setAttribute("path_patern", info.getFolderPathPattern()); // NOI18N
  419. }
  420. if (info.getFolderSuffix() != null) {
  421. p.setAttribute("suffix", info.getFolderSuffix()); // NOI18N
  422. }
  423. element.appendChild(p);
  424. }
  425. }
  426. if (descriptor.getDefaultLocations() != null) {
  427. element = doc.createElement("default_locations"); // NOI18N
  428. root.appendChild(element);
  429. for (Map.Entry<String, List<String>> e : descriptor.getDefaultLocations().entrySet()) {
  430. for (String st : e.getValue()) {
  431. Element p = doc.createElement("platform"); // NOI18N
  432. p.setAttribute("os", e.getKey()); // NOI18N
  433. p.setAttribute("directory", st); // NOI18N
  434. element.appendChild(p);
  435. }
  436. }
  437. }
  438. CompilerDescriptor compiler;
  439. compiler = descriptor.getC();
  440. if (compiler != null) {
  441. element = doc.createElement("c"); // NOI18N
  442. writeCompiler(doc, element, compiler);
  443. root.appendChild(element);
  444. }
  445. compiler = descriptor.getCpp();
  446. if (compiler != null) {
  447. element = doc.createElement("cpp"); // NOI18N
  448. writeCompiler(doc, element, compiler);
  449. root.appendChild(element);
  450. }
  451. compiler = descriptor.getFortran();
  452. if (compiler != null) {
  453. element = doc.createElement("fortran"); // NOI18N
  454. writeCompiler(doc, element, compiler);
  455. root.appendChild(element);
  456. }
  457. compiler = descriptor.getAssembler();
  458. if (compiler != null) {
  459. element = doc.createElement("assembler"); // NOI18N
  460. writeCompiler(doc, element, compiler);
  461. root.appendChild(element);
  462. }
  463. ScannerDescriptor scanner = descriptor.getScanner();
  464. if (scanner != null) {
  465. element = doc.createElement("scanner"); // NOI18N
  466. element.setAttribute("id", scanner.getID()); // NOI18N
  467. writeScanner(doc, element, scanner);
  468. root.appendChild(element);
  469. }
  470. LinkerDescriptor linker = descriptor.getLinker();
  471. if (linker != null) {
  472. element = doc.createElement("linker"); // NOI18N
  473. writeLinker(doc, element, linker);
  474. root.appendChild(element);
  475. }
  476. MakeDescriptor make = descriptor.getMake();
  477. if (make != null) {
  478. element = doc.createElement("make"); // NOI18N
  479. writeMake(doc, element, make);
  480. root.appendChild(element);
  481. }
  482. DebuggerDescriptor debugger = descriptor.getDebugger();
  483. if (debugger != null) {
  484. element = doc.createElement("debugger"); // NOI18N
  485. element.setAttribute("id", debugger.getID()); // NOI18N
  486. writeDebugger(doc, element, debugger);
  487. root.appendChild(element);
  488. }
  489. QMakeDescriptor qmake = descriptor.getQMake();
  490. if (qmake != null) {
  491. element = doc.createElement("qmake"); // NOI18N
  492. writeQMake(doc, element, qmake);
  493. root.appendChild(element);
  494. }
  495. CMakeDescriptor cmake = descriptor.getCMake();
  496. if (cmake != null) {
  497. element = doc.createElement("cmake"); // NOI18N
  498. writeCMake(doc, element, cmake);
  499. root.appendChild(element);
  500. }
  501. try {
  502. FileLock lock = file.lock();
  503. try {
  504. OutputStream os = file.getOutputStream(lock);
  505. try {
  506. XMLUtil.write(doc, os, "UTF-8"); // NOI18N
  507. } finally {
  508. os.close();
  509. }
  510. } finally {
  511. lock.releaseLock();
  512. }
  513. } catch (IOException ex) {
  514. Exceptions.printStackTrace(ex);
  515. }
  516. }
  517. private void writeCompiler(Document doc, Element element, CompilerDescriptor compiler) {
  518. Element e;
  519. e = doc.createElement("compiler"); // NOI18N
  520. e.setAttribute("name", unsplit(compiler.getNames())); // NOI18N
  521. if (compiler.skipSearch()) {
  522. e.setAttribute("skip", "true"); // NOI18N
  523. }
  524. element.appendChild(e);
  525. if (compiler.getPathPattern() != null ||
  526. compiler.getExistFolder() != null) {
  527. e = doc.createElement("recognizer"); // NOI18N
  528. if (compiler.getPathPattern() != null) {
  529. e.setAttribute("pattern", compiler.getPathPattern()); // NOI18N
  530. }
  531. if (compiler.getExistFolder() != null) {
  532. e.setAttribute("or_exist_folder", compiler.getExistFolder()); // NOI18N
  533. }
  534. element.appendChild(e);
  535. }
  536. if (compiler.getVersionFlags() != null ||
  537. compiler.getVersionPattern() != null) {
  538. e = doc.createElement("version"); // NOI18N
  539. if (compiler.getVersionFlags() != null) {
  540. e.setAttribute("flags", compiler.getVersionFlags()); // NOI18N
  541. }
  542. if (compiler.getVersionPattern() != null) {
  543. e.setAttribute("pattern", compiler.getVersionPattern()); // NOI18N
  544. }
  545. if (compiler.getFingerPrintFlags() != null) {
  546. e.setAttribute("fingerprint_flags", compiler.getFingerPrintFlags()); // NOI18N
  547. }
  548. if (compiler.getFingerPrintPattern() != null) {
  549. e.setAttribute("fingerprint_pattern", compiler.getFingerPrintPattern()); // NOI18N
  550. }
  551. element.appendChild(e);
  552. }
  553. writeAlternativePath(doc, element, compiler);
  554. if (compiler.getIncludeFlags() != null ||
  555. compiler.getIncludeParser() != null ||
  556. compiler.getRemoveIncludePathPrefix() != null ||
  557. compiler.getRemoveIncludeOutputPrefix() != null) {
  558. e = doc.createElement("system_include_paths"); // NOI18N
  559. if (compiler.getIncludeFlags() != null) {
  560. e.setAttribute("flags", compiler.getIncludeFlags()); // NOI18N
  561. }
  562. if (compiler.getIncludeParser() != null) {
  563. e.setAttribute("parser", compiler.getIncludeParser()); // NOI18N
  564. }
  565. if (compiler.getRemoveIncludePathPrefix() != null) {
  566. e.setAttribute("remove_in_path", compiler.getRemoveIncludePathPrefix()); // NOI18N
  567. }
  568. if (compiler.getRemoveIncludeOutputPrefix() != null) {
  569. e.setAttribute("remove_in_output", compiler.getRemoveIncludeOutputPrefix()); // NOI18N
  570. }
  571. element.appendChild(e);
  572. }
  573. if (compiler.getMacroFlags() != null ||
  574. compiler.getMacroParser() != null ||
  575. compiler.getPredefinedMacros() != null) {
  576. e = doc.createElement("system_macros"); // NOI18N
  577. if (compiler.getMacroFlags() != null) {
  578. e.setAttribute("flags", compiler.getMacroFlags()); // NOI18N
  579. }
  580. if (compiler.getMacroParser() != null) {
  581. e.setAttribute("parser", compiler.getMacroParser()); // NOI18N
  582. }
  583. element.appendChild(e);
  584. if (compiler.getPredefinedMacros() != null) {
  585. for(PredefinedMacro p : compiler.getPredefinedMacros()){
  586. Element ee = doc.createElement("macro"); // NOI18N
  587. ee.setAttribute("stringvalue", p.getMacro()); // NOI18N
  588. if (p.getFlags() != null) {
  589. ee.setAttribute("flags", p.getFlags()); // NOI18N
  590. }
  591. if (p.isHidden()) {
  592. ee.setAttribute("hide", "true"); // NOI18N
  593. }
  594. e.appendChild(ee);
  595. }
  596. }
  597. }
  598. if (compiler.getUserIncludeFlag() != null) {
  599. e = doc.createElement("user_include"); // NOI18N
  600. e.setAttribute("flags", compiler.getUserIncludeFlag()); // NOI18N
  601. element.appendChild(e);
  602. }
  603. if (compiler.getUserMacroFlag() != null) {
  604. e = doc.createElement("user_macro"); // NOI18N
  605. e.setAttribute("flags", compiler.getUserMacroFlag()); // NOI18N
  606. element.appendChild(e);
  607. }
  608. writeDevelopmentMode(doc, element, compiler);
  609. writeWarningLevel(doc, element, compiler);
  610. writeArchitecture(doc, element, compiler);
  611. if (compiler.getStripFlag() != null) {
  612. e = doc.createElement("strip"); // NOI18N
  613. e.setAttribute("flags", compiler.getStripFlag()); // NOI18N
  614. element.appendChild(e);
  615. }
  616. writeMultithreading(doc, element, compiler);
  617. writeStandard(doc, element, compiler);
  618. writeLanguageExtension(doc, element, compiler);
  619. writeCppStandard(doc, element, compiler);
  620. writeCStandard(doc, element, compiler);
  621. writeLibrary(doc, element, compiler);
  622. if (compiler.getOutputObjectFileFlags() != null) {
  623. e = doc.createElement("output_object_file"); // NOI18N
  624. e.setAttribute("flags", compiler.getOutputObjectFileFlags()); // NOI18N
  625. element.appendChild(e);
  626. }
  627. if (compiler.getDependencyGenerationFlags() != null) {
  628. e = doc.createElement("dependency_generation"); // NOI18N
  629. e.setAttribute("flags", compiler.getDependencyGenerationFlags()); // NOI18N
  630. element.appendChild(e);
  631. }
  632. if (compiler.getPrecompiledHeaderFlags() != null ||
  633. compiler.getPrecompiledHeaderSuffix() != null) {
  634. e = doc.createElement("precompiled_header"); // NOI18N
  635. if (compiler.getPrecompiledHeaderFlags() != null) {
  636. e.setAttribute("flags", compiler.getPrecompiledHeaderFlags()); // NOI18N
  637. }
  638. if (compiler.getPrecompiledHeaderSuffix() != null) {
  639. e.setAttribute("suffix", compiler.getPrecompiledHeaderSuffix()); // NOI18N
  640. }
  641. if (compiler.getPrecompiledHeaderSuffixAppend()) {
  642. e.setAttribute("append", "true"); // NOI18N
  643. }
  644. element.appendChild(e);
  645. }
  646. }
  647. private void writeDevelopmentMode(Document doc, Element element, CompilerDescriptor compiler) {
  648. String[] flags = compiler.getDevelopmentModeFlags();
  649. if (flags == null) {
  650. return;
  651. }
  652. int def = 0;
  653. if (compiler instanceof CompilerDescriptorImpl) {
  654. def = ((CompilerDescriptorImpl) compiler).tool.developmentMode.default_selection;
  655. }
  656. Element e = doc.createElement("development_mode"); // NOI18N
  657. element.appendChild(e);
  658. Element c;
  659. String[] names = new String[]{"fast_build", "debug", "performance_debug", // NOI18N
  660. "test_coverage", "diagnosable_release", "release", // NOI18N
  661. "performance_release"}; // NOI18N
  662. for (int i = 0; i < flags.length; i++) {
  663. c = doc.createElement(names[i]);
  664. c.setAttribute("flags", flags[i]); // NOI18N
  665. if (def == i) {
  666. c.setAttribute("default", "true"); // NOI18N
  667. }
  668. e.appendChild(c);
  669. }
  670. }
  671. private void writeWarningLevel(Document doc, Element element, CompilerDescriptor compiler) {
  672. String[] flags = compiler.getWarningLevelFlags();
  673. if (flags == null) {
  674. return;
  675. }
  676. int def = 0;
  677. if (compiler instanceof CompilerDescriptorImpl) {
  678. def = ((CompilerDescriptorImpl) compiler).tool.warningLevel.default_selection;
  679. }
  680. Element e = doc.createElement("warning_level"); // NOI18N
  681. element.appendChild(e);
  682. Element c;
  683. String[] names = new String[]{"no_warnings", "default", "more_warnings", // NOI18N
  684. "warning2error"}; // NOI18N
  685. for (int i = 0; i < flags.length; i++) {
  686. c = doc.createElement(names[i]);
  687. c.setAttribute("flags", flags[i]); // NOI18N
  688. if (def == i) {
  689. c.setAttribute("default", "true"); // NOI18N
  690. }
  691. e.appendChild(c);
  692. }
  693. }
  694. private void writeArchitecture(Document doc, Element element, CompilerDescriptor compiler) {
  695. String[] flags = compiler.getArchitectureFlags();
  696. if (flags == null) {
  697. return;
  698. }
  699. int def = 0;
  700. if (compiler instanceof CompilerDescriptorImpl) {
  701. def = ((CompilerDescriptorImpl) compiler).tool.architecture.default_selection;
  702. }
  703. Element e = doc.createElement("architecture"); // NOI18N
  704. element.appendChild(e);
  705. Element c;
  706. String[] names = new String[]{"default", "bits_32", "bits_64"}; // NOI18N
  707. for (int i = 0; i < flags.length; i++) {
  708. c = doc.createElement(names[i]);
  709. c.setAttribute("flags", flags[i]); // NOI18N
  710. if (def == i) {
  711. c.setAttribute("default", "true"); // NOI18N
  712. }
  713. e.appendChild(c);
  714. }
  715. }
  716. private void writeMultithreading(Document doc, Element element, CompilerDescriptor compiler) {
  717. String[] flags = compiler.getMultithreadingFlags();
  718. if (flags == null) {
  719. return;
  720. }
  721. int def = 0;
  722. if (compiler instanceof CompilerDescriptorImpl) {
  723. def = ((CompilerDescriptorImpl) compiler).tool.multithreading.default_selection;
  724. }
  725. Element e = doc.createElement("multithreading"); // NOI18N
  726. element.appendChild(e);
  727. Element c;
  728. String[] names = new String[]{"none", "safe", "automatic", "open_mp"}; // NOI18N
  729. for (int i = 0; i < flags.length; i++) {
  730. c = doc.createElement(names[i]);
  731. c.setAttribute("flags", flags[i]); // NOI18N
  732. if (def == i) {
  733. c.setAttribute("default", "true"); // NOI18N
  734. }
  735. e.appendChild(c);
  736. }
  737. }
  738. private void writeStandard(Document doc, Element element, CompilerDescriptor compiler) {
  739. String[] flags = compiler.getStandardFlags();
  740. if (flags == null) {
  741. return;
  742. }
  743. int def = 0;
  744. if (compiler instanceof CompilerDescriptorImpl) {
  745. def = ((CompilerDescriptorImpl) compiler).tool.standard.default_selection;
  746. }
  747. Element e = doc.createElement("standard"); // NOI18N
  748. element.appendChild(e);
  749. Element c;
  750. String[] names = new String[]{"old", "legacy", "default", "modern"}; // NOI18N
  751. for (int i = 0; i < flags.length; i++) {
  752. c = doc.createElement(names[i]);
  753. c.setAttribute("flags", flags[i]); // NOI18N
  754. if (def == i) {
  755. c.setAttribute("default", "true"); // NOI18N
  756. }
  757. e.appendChild(c);
  758. }
  759. }
  760. private void writeLanguageExtension(Document doc, Element element, CompilerDescriptor compiler) {
  761. String[] flags = compiler.getLanguageExtensionFlags();
  762. if (flags == null) {
  763. return;
  764. }
  765. int def = 0;
  766. if (compiler instanceof CompilerDescriptorImpl) {
  767. def = ((CompilerDescriptorImpl) compiler).tool.languageExtension.default_selection;
  768. }
  769. Element e = doc.createElement("language_extension"); // NOI18N
  770. element.appendChild(e);
  771. Element c;
  772. String[] names = new String[]{"none", "default", "all"}; // NOI18N
  773. for (int i = 0; i < flags.length; i++) {
  774. c = doc.createElement(names[i]);
  775. c.setAttribute("flags", flags[i]); // NOI18N
  776. if (def == i) {
  777. c.setAttribute("default", "true"); // NOI18N
  778. }
  779. e.appendChild(c);
  780. }
  781. }
  782. private void writeCppStandard(Document doc, Element element, CompilerDescriptor compiler) {
  783. String[] flags = compiler.getCppStandardFlags();
  784. if (flags == null) {
  785. return;
  786. }
  787. int def = 0;
  788. if (compiler instanceof CompilerDescriptorImpl) {
  789. def = ((CompilerDescriptorImpl) compiler).tool.cppStandard.default_selection;
  790. }
  791. Element e = doc.createElement("cpp_standard"); // NOI18N
  792. element.appendChild(e);
  793. Element c;
  794. String[] names = new String[]{"default", "cpp98", "cpp11"}; // NOI18N
  795. for (int i = 0; i < flags.length; i++) {
  796. c = doc.createElement(names[i]);
  797. c.setAttribute("flags", flags[i]); // NOI18N
  798. if (def == i) {
  799. c.setAttribute("default", "true"); // NOI18N
  800. }
  801. e.appendChild(c);
  802. }
  803. }
  804. private void writeCStandard(Document doc, Element element, CompilerDescriptor compiler) {
  805. String[] flags = compiler.getCStandardFlags();
  806. if (flags == null) {
  807. return;
  808. }
  809. int def = 0;
  810. if (compiler instanceof CompilerDescriptorImpl) {
  811. def = ((CompilerDescriptorImpl) compiler).tool.cStandard.default_selection;
  812. }
  813. Element e = doc.createElement("c_standard"); // NOI18N
  814. element.appendChild(e);
  815. Element c;
  816. String[] names = new String[]{"default", "c89", "c99"}; // NOI18N
  817. for (int i = 0; i < flags.length; i++) {
  818. c = doc.createElement(names[i]);
  819. c.setAttribute("flags", flags[i]); // NOI18N
  820. if (def == i) {
  821. c.setAttribute("default", "true"); // NOI18N
  822. }
  823. e.appendChild(c);
  824. }
  825. }
  826. private void writeLibrary(Document doc, Element element, CompilerDescriptor compiler) {
  827. String[] flags = compiler.getLibraryFlags();
  828. if (flags == null) {
  829. return;
  830. }
  831. int def = 0;
  832. if (compiler instanceof CompilerDescriptorImpl) {
  833. def = ((CompilerDescriptorImpl) compiler).tool.library.default_selection;
  834. }
  835. Element e = doc.createElement("library"); // NOI18N
  836. element.appendChild(e);
  837. Element c;
  838. String[] names = new String[]{"none", "runtime", "classic", // NOI18N
  839. "binary_standard", "conforming_standard"}; // NOI18N
  840. for (int i = 0; i < flags.length; i++) {
  841. c = doc.createElement(names[i]);
  842. c.setAttribute("flags", flags[i]); // NOI18N
  843. if (def == i) {
  844. c.setAttribute("default", "true"); // NOI18N
  845. }
  846. e.appendChild(c);
  847. }
  848. }
  849. private void writeScanner(Document doc, Element element, ScannerDescriptor scanner) {
  850. Element c;
  851. for (ScannerPattern pattern : scanner.getPatterns()) {
  852. c = doc.createElement("error"); // NOI18N
  853. c.setAttribute("pattern", pattern.getPattern()); // NOI18N
  854. if (pattern.getSeverity() != null) {
  855. c.setAttribute("severity", pattern.getSeverity()); // NOI18N
  856. }
  857. if (pattern.getLanguage() != null) {
  858. c.setAttribute("language", pattern.getLanguage()); // NOI18N
  859. }
  860. element.appendChild(c);
  861. }
  862. if (scanner.getStackHeaderPattern() != null) {
  863. c = doc.createElement("stack_header"); // NOI18N
  864. c.setAttribute("pattern", scanner.getStackHeaderPattern()); // NOI18N
  865. element.appendChild(c);
  866. }
  867. if (scanner.getStackNextPattern() != null) {
  868. c = doc.createElement("stack_next"); // NOI18N
  869. c.setAttribute("pattern", scanner.getStackNextPattern()); // NOI18N
  870. element.appendChild(c);
  871. }
  872. if (scanner.getEnterDirectoryPattern() != null) {
  873. c = doc.createElement("enter_directory"); // NOI18N
  874. c.setAttribute("pattern", scanner.getEnterDirectoryPattern()); // NOI18N
  875. element.appendChild(c);
  876. }
  877. if (scanner.getChangeDirectoryPattern() != null) {
  878. c = doc.createElement("change_directory"); // NOI18N
  879. c.setAttribute("pattern", scanner.getChangeDirectoryPattern()); // NOI18N
  880. element.appendChild(c);
  881. }
  882. if (scanner.getMakeAllInDirectoryPattern() != null) {
  883. c = doc.createElement("making_all_in_directory"); // NOI18N
  884. c.setAttribute("pattern", scanner.getMakeAllInDirectoryPattern()); // NOI18N
  885. element.appendChild(c);
  886. }
  887. if (scanner.getLeaveDirectoryPattern() != null) {
  888. c = doc.createElement("leave_directory"); // NOI18N
  889. c.setAttribute("pattern", scanner.getLeaveDirectoryPattern()); // NOI18N
  890. element.appendChild(c);
  891. }
  892. for (String pattern : scanner.getFilterOutPatterns()) {
  893. c = doc.createElement("filter_out"); // NOI18N
  894. c.setAttribute("pattern", pattern); // NOI18N
  895. element.appendChild(c);
  896. }
  897. }
  898. private void writeLinker(Document doc, Element element, LinkerDescriptor linker) {
  899. Element c;
  900. if (linker.getLibraryPrefix() != null) {
  901. c = doc.createElement("library_prefix"); // NOI18N
  902. c.setAttribute("stringvalue", linker.getLibraryPrefix()); // NOI18N
  903. element.appendChild(c);
  904. }
  905. if (linker.getLibrarySearchFlag() != null) {
  906. c = doc.createElement("library_search"); // NOI18N
  907. c.setAttribute("flags", linker.getLibrarySearchFlag()); // NOI18N
  908. element.appendChild(c);
  909. }
  910. if (linker.getDynamicLibrarySearchFlag() != null) {
  911. c = doc.createElement("dynamic_library_search"); // NOI18N
  912. c.setAttribute("flags", linker.getDynamicLibrarySearchFlag()); // NOI18N
  913. element.appendChild(c);
  914. }
  915. if (linker.getLibraryFlag() != null) {
  916. c = doc.createElement("library_flag"); // NOI18N
  917. c.setAttribute("flags", linker.getLibraryFlag()); // NOI18N
  918. element.appendChild(c);
  919. }
  920. if (linker.getPICFlag() != null) {
  921. c = doc.createElement("PIC"); // NOI18N
  922. c.setAttribute("flags", linker.getPICFlag()); // NOI18N
  923. element.appendChild(c);
  924. }
  925. if (linker.getStaticLibraryFlag() != null) {
  926. c = doc.createElement("static_library"); // NOI18N
  927. c.setAttribute("flags", linker.getStaticLibraryFlag()); // NOI18N
  928. element.appendChild(c);
  929. }
  930. if (linker.getDynamicLibraryFlag() != null) {
  931. c = doc.createElement("dynamic_library"); // NOI18N
  932. c.setAttribute("flags", linker.getDynamicLibraryFlag()); // NOI18N
  933. element.appendChild(c);
  934. }
  935. if (linker.getDynamicLibraryBasicFlag() != null) {
  936. c = doc.createElement("dynamic_library_basic"); // NOI18N
  937. c.setAttribute("flags", linker.getDynamicLibraryBasicFlag()); // NOI18N
  938. element.appendChild(c);
  939. }
  940. if (linker.getOutputFileFlag() != null) {
  941. c = doc.createElement("output_file"); // NOI18N
  942. c.setAttribute("flags", linker.getOutputFileFlag()); // NOI18N
  943. element.appendChild(c);
  944. }
  945. if (linker.getStripFlag() != null) {
  946. c = doc.createElement("strip_flag"); // NOI18N
  947. c.setAttribute("flags", linker.getStripFlag()); // NOI18N
  948. element.appendChild(c);
  949. }
  950. if (linker.getPreferredCompiler() != null) {
  951. c = doc.createElement("preferred_compiler"); // NOI18N
  952. c.setAttribute("compiler", linker.getPreferredCompiler()); // NOI18N
  953. element.appendChild(c);
  954. }
  955. }
  956. private void writeMake(Document doc, Element element, MakeDescriptor make) {
  957. Element c;
  958. c = doc.createElement("tool"); // NOI18N
  959. c.setAttribute("name", unsplit(make.getNames())); // NOI18N
  960. if (make.skipSearch()) {
  961. c.setAttribute("skip", "true"); // NOI18N
  962. }
  963. element.appendChild(c);
  964. if (make.getVersionFlags() != null ||
  965. make.getVersionPattern() != null) {
  966. c = doc.createElement("version"); // NOI18N
  967. if (make.getVersionFlags() != null) {
  968. c.setAttribute("flags", make.getVersionFlags()); // NOI18N
  969. }
  970. if (make.getVersionPattern() != null) {
  971. c.setAttribute("pattern", make.getVersionPattern()); // NOI18N
  972. }
  973. element.appendChild(c);
  974. }
  975. writeAlternativePath(doc, element, make);
  976. if (make.getDependencySupportCode() != null) {
  977. c = doc.createElement("dependency_support"); // NOI18N
  978. c.setAttribute("code", make.getDependencySupportCode()); // NOI18N
  979. element.appendChild(c);
  980. }
  981. }
  982. private void writeDebugger(Document doc, Element element, DebuggerDescriptor debugger) {
  983. Element c;
  984. c = doc.createElement("tool"); // NOI18N
  985. c.setAttribute("name", unsplit(debugger.getNames())); // NOI18N
  986. if (debugger.skipSearch()) {
  987. c.setAttribute("skip", "true"); // NOI18N
  988. }
  989. element.appendChild(c);
  990. if (debugger.getVersionFlags() != null ||
  991. debugger.getVersionPattern() != null) {
  992. c = doc.createElement("version"); // NOI18N
  993. if (debugger.getVersionFlags() != null) {
  994. c.setAttribute("flags", debugger.getVersionFlags()); // NOI18N
  995. }
  996. if (debugger.getVersionPattern() != null) {
  997. c.setAttribute("pattern", debugger.getVersionPattern()); // NOI18N
  998. }
  999. element.appendChild(c);
  1000. }
  1001. writeAlternativePath(doc, element, debugger);
  1002. }
  1003. private void writeQMake(Document doc, Element element, QMakeDescriptor qmake) {
  1004. Element c;
  1005. c = doc.createElement("tool"); // NOI18N
  1006. c.setAttribute("name", unsplit(qmake.getNames())); // NOI18N
  1007. if (qmake.skipSearch()) {
  1008. c.setAttribute("skip", "true"); // NOI18N
  1009. }
  1010. element.appendChild(c);
  1011. if (qmake.getVersionFlags() != null ||
  1012. qmake.getVersionPattern() != null) {
  1013. c = doc.createElement("version"); // NOI18N
  1014. if (qmake.getVersionFlags() != null) {
  1015. c.setAttribute("flags", qmake.getVersionFlags()); // NOI18N
  1016. }
  1017. if (qmake.getVersionPattern() != null) {
  1018. c.setAttribute("pattern", qmake.getVersionPattern()); // NOI18N
  1019. }
  1020. element.appendChild(c);
  1021. }
  1022. writeAlternativePath(doc, element, qmake);
  1023. }
  1024. private void writeCMake(Document doc, Element element, CMakeDescriptor cmake) {
  1025. Element c;
  1026. c = doc.createElement("tool"); // NOI18N
  1027. c.setAttribute("name", unsplit(cmake.getNames())); // NOI18N
  1028. if (cmake.skipSearch()) {
  1029. c.setAttribute("skip", "true"); // NOI18N
  1030. }
  1031. element.appendChild(c);
  1032. if (cmake.getVersionFlags() != null ||
  1033. cmake.getVersionPattern() != null) {
  1034. c = doc.createElement("version"); // NOI18N
  1035. if (cmake.getVersionFlags() != null) {
  1036. c.setAttribute("flags", cmake.getVersionFlags()); // NOI18N
  1037. }
  1038. if (cmake.getVersionPattern() != null) {
  1039. c.setAttribute("pattern", cmake.getVersionPattern()); // NOI18N
  1040. }
  1041. element.appendChild(c);
  1042. }
  1043. writeAlternativePath(doc, element, cmake);
  1044. }
  1045. private void writeAlternativePath(Document doc, Element element, ToolDescriptor tool){
  1046. AlternativePath[] paths = tool.getAlternativePath();
  1047. if (paths != null) {
  1048. Element c = doc.createElement("alternative_path"); // NOI18N
  1049. element.appendChild(c);
  1050. for(AlternativePath path : paths){
  1051. Element p = doc.createElement("path"); // NOI18N
  1052. c.appendChild(p);
  1053. switch(path.getKind()){
  1054. case PATH:
  1055. p.setAttribute("directory", path.getPath()); // NOI18N
  1056. break;
  1057. case TOOL_FAMILY:
  1058. p.setAttribute("toolchain_family", path.getPath()); // NOI18N
  1059. break;
  1060. case TOOL_NAME:
  1061. p.setAttribute("toolchain_name", path.getPath()); // NOI18N
  1062. break;
  1063. }
  1064. }
  1065. }
  1066. }
  1067. /**
  1068. * class package-local for testing only
  1069. */
  1070. static final class CompilerVendor {
  1071. final String toolChainFileName;
  1072. final int position;
  1073. String toolChainName;
  1074. String toolChainDisplay;
  1075. Map<String, List<String>> default_locations;
  1076. String family;
  1077. String platforms;
  1078. String uc;
  1079. String ucName;
  1080. String upgrage;
  1081. String module;
  1082. String aliases;
  1083. String substitute;
  1084. boolean isAbstract;
  1085. boolean isAutoDetected;
  1086. String driveLetterPrefix;
  1087. List<FolderInfo> baseFolder;
  1088. List<FolderInfo> commandFolder;
  1089. String qmakespec;
  1090. String makefileWriter;
  1091. Compiler c = new Compiler();
  1092. Compiler cpp = new Compiler();
  1093. Compiler fortran = new Compiler();
  1094. Compiler assembler = new Compiler();
  1095. Scanner scanner = new Scanner();
  1096. Linker linker = new Linker();
  1097. Make make = new Make();
  1098. Debugger debugger = new Debugger();
  1099. QMake qmake = new QMake();
  1100. CMake cmake = new CMake();
  1101. private CompilerVendor(String fileName, int position) {
  1102. toolChainFileName = fileName;
  1103. this.position = position;
  1104. }
  1105. public boolean isValid() {
  1106. return toolChainName != null && toolChainName.length() > 0 &&
  1107. (c.isValid() || cpp.isValid() || fortran.isValid());
  1108. }
  1109. }
  1110. static final class FolderInfo {
  1111. String folderKey;
  1112. String folderPattern;
  1113. String folderSuffix;
  1114. String folderPathPattern;
  1115. }
  1116. /**
  1117. * class pa