src/share/tools/ProjectCreator/FileTreeCreatorVC7.java

Thu, 08 Aug 2013 09:21:30 -0700

author
dcubed
date
Thu, 08 Aug 2013 09:21:30 -0700
changeset 5500
31f3b1e1c5e5
parent 4112
1a9b9cfcef41
child 5507
bd0e82136b03
permissions
-rw-r--r--

8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
Summary: ProjectCreator tool is modified to support two new options: '-relativeAltSrcInclude' and '-altRelativeInclude' which prevents IDE linker errors. Also fixed some cmd line build linker warnings. Misc cleanups.
Reviewed-by: rdurbin, coleenp

neliasso@4112 1 import static java.nio.file.FileVisitResult.CONTINUE;
neliasso@4112 2
neliasso@4112 3 import java.io.IOException;
neliasso@4112 4 import java.nio.file.FileSystems;
neliasso@4112 5 import java.nio.file.FileVisitResult;
neliasso@4112 6 import java.nio.file.Files;
neliasso@4112 7 import java.nio.file.Path;
neliasso@4112 8 import java.nio.file.attribute.BasicFileAttributes;
neliasso@4112 9 import java.util.Stack;
neliasso@4112 10 import java.util.Vector;
neliasso@4112 11
neliasso@4112 12 public class FileTreeCreatorVC7 extends FileTreeCreator {
neliasso@4112 13
neliasso@4112 14 public FileTreeCreatorVC7(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) {
neliasso@4112 15 super(startDir, allConfigs, null);
neliasso@4112 16 }
neliasso@4112 17
neliasso@4112 18 @Override
neliasso@4112 19 public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
neliasso@4112 20 DirAttributes currentFileAttr = attributes.peek().clone();
neliasso@4112 21 boolean usePch = false;
neliasso@4112 22 boolean disablePch = false;
neliasso@4112 23 boolean useIgnore = false;
neliasso@4112 24 String fileName = file.getFileName().toString();
neliasso@4112 25
neliasso@4112 26 // usePch applies to all configs for a file.
neliasso@4112 27 if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) {
neliasso@4112 28 usePch = true;
neliasso@4112 29 }
neliasso@4112 30
neliasso@4112 31 for (BuildConfig cfg : allConfigs) {
neliasso@4112 32 if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {
neliasso@4112 33 useIgnore = true;
neliasso@4112 34 currentFileAttr.setIgnore(cfg);
neliasso@4112 35 } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) {
neliasso@4112 36 useIgnore = true;
neliasso@4112 37 currentFileAttr.setIgnore(cfg);
neliasso@4112 38 }
neliasso@4112 39
neliasso@4112 40 if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) {
neliasso@4112 41 disablePch = true;
neliasso@4112 42 currentFileAttr.setDisablePch(cfg);
neliasso@4112 43 }
neliasso@4112 44
neliasso@4112 45 Vector<String> rv = new Vector<String>();
neliasso@4112 46 cfg.collectRelevantVectors(rv, "AdditionalFile");
neliasso@4112 47 for(String addFile : rv) {
neliasso@4112 48 if (addFile.equals(fileName)) {
neliasso@4112 49 // supress any ignore
neliasso@4112 50 currentFileAttr.removeFromIgnored(cfg);
neliasso@4112 51 }
neliasso@4112 52 }
neliasso@4112 53 }
neliasso@4112 54
neliasso@4112 55 if (!useIgnore && !disablePch && !usePch) {
neliasso@4112 56 wg.tag("File", new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
neliasso@4112 57 } else {
neliasso@4112 58 wg.startTag(
neliasso@4112 59 "File",
neliasso@4112 60 new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
neliasso@4112 61
neliasso@4112 62 for (BuildConfig cfg : allConfigs) {
neliasso@4112 63 boolean ignore = currentFileAttr.hasIgnore(cfg);
neliasso@4112 64 String [] fileConfAttr;
neliasso@4112 65
neliasso@4112 66 if (ignore) {
neliasso@4112 67 fileConfAttr = new String[] {"Name", cfg.get("Name"), "ExcludedFromBuild", "TRUE" };
neliasso@4112 68 } else {
neliasso@4112 69 fileConfAttr = new String[] {"Name", cfg.get("Name")};
neliasso@4112 70 }
neliasso@4112 71
neliasso@4112 72 if (!disablePch && !usePch && !ignore) {
neliasso@4112 73 continue;
neliasso@4112 74 } else if (!disablePch && !usePch) {
neliasso@4112 75 wg.tag("FileConfiguration", fileConfAttr);
neliasso@4112 76 } else {
neliasso@4112 77 wg.startTag("FileConfiguration", fileConfAttr);
neliasso@4112 78 if (usePch) {
neliasso@4112 79 // usePch always applies to all configs, might not always be so.
neliasso@4112 80 wg.tag("Tool", new String[] {
neliasso@4112 81 "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
neliasso@4112 82 "1" });
neliasso@4112 83 assert(!disablePch);
neliasso@4112 84 }
neliasso@4112 85 if (disablePch) {
neliasso@4112 86 if (currentFileAttr.hasDisablePch(cfg)) {
neliasso@4112 87 wg.tag("Tool", new String[] {
neliasso@4112 88 "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
neliasso@4112 89 "0" });
neliasso@4112 90 }
neliasso@4112 91 assert(!usePch);
neliasso@4112 92 }
neliasso@4112 93 wg.endTag();
neliasso@4112 94 }
neliasso@4112 95 }
neliasso@4112 96 wg.endTag();
neliasso@4112 97 }
neliasso@4112 98
neliasso@4112 99 return CONTINUE;
neliasso@4112 100 }
neliasso@4112 101
neliasso@4112 102 @Override
neliasso@4112 103 public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)
neliasso@4112 104 throws IOException {
neliasso@4112 105 Boolean hide = false;
neliasso@4112 106 DirAttributes newAttr = attributes.peek().clone();
neliasso@4112 107
neliasso@4112 108 String rPath;
neliasso@4112 109 if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){
neliasso@4112 110 rPath = startDir.toString();
neliasso@4112 111 } else {
neliasso@4112 112 rPath = path.getFileName().toString();
neliasso@4112 113 }
neliasso@4112 114
neliasso@4112 115 // check per config ignorePaths!
neliasso@4112 116 for (BuildConfig cfg : allConfigs) {
neliasso@4112 117 if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) {
neliasso@4112 118 newAttr.setIgnore(cfg);
neliasso@4112 119 }
neliasso@4112 120
neliasso@4112 121 // Hide is always on all configs. And additional files are never hiddden
neliasso@4112 122 if (cfg.matchesHidePath(path.toAbsolutePath().toString())) {
neliasso@4112 123 hide = true;
neliasso@4112 124 break;
neliasso@4112 125 }
neliasso@4112 126 }
neliasso@4112 127
neliasso@4112 128 if (!hide) {
neliasso@4112 129 wg.startTag("Filter", new String[] {
neliasso@4112 130 "Name", rPath});
neliasso@4112 131
neliasso@4112 132 attributes.push(newAttr);
neliasso@4112 133 return super.preVisitDirectory(path, attrs);
neliasso@4112 134 } else {
neliasso@4112 135 return FileVisitResult.SKIP_SUBTREE;
neliasso@4112 136 }
neliasso@4112 137 }
neliasso@4112 138
neliasso@4112 139 @Override
neliasso@4112 140 public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
neliasso@4112 141 //end matching attributes set by ignorepath
neliasso@4112 142 wg.endTag();
neliasso@4112 143 attributes.pop();
neliasso@4112 144
neliasso@4112 145 return CONTINUE;
neliasso@4112 146 }
neliasso@4112 147
neliasso@4112 148 @Override
neliasso@4112 149 public FileVisitResult visitFileFailed(Path file, IOException exc) {
neliasso@4112 150 return CONTINUE;
neliasso@4112 151 }
neliasso@4112 152
neliasso@4112 153 public void writeFileTree() throws IOException {
neliasso@4112 154 Files.walkFileTree(this.startDir, this);
neliasso@4112 155 }
neliasso@4112 156 }

mercurial