8016601: Unable to build hsx24 on Windows using project creator and Visual Studio

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
This commit is contained in:
Daniel D. Daugherty 2013-08-08 09:21:30 -07:00
parent 27f8eea2ea
commit ae5b50414a
10 changed files with 212 additions and 83 deletions

View file

@ -142,6 +142,69 @@ class BuildConfig {
return rv;
}
// Returns true if the specified path refers to a relative alternate
// source file. RelativeAltSrcInclude is usually "src\closed".
public static boolean matchesRelativeAltSrcInclude(String path) {
String relativeAltSrcInclude =
getFieldString(null, "RelativeAltSrcInclude");
Vector<String> v = getFieldVector(null, "AltRelativeInclude");
for (String pathPart : v) {
if (path.contains(relativeAltSrcInclude + Util.sep + pathPart)) {
return true;
}
}
return false;
}
// Returns the relative alternate source file for the specified path.
// Null is returned if the specified path does not have a matching
// alternate source file.
public static String getMatchingRelativeAltSrcFile(String path) {
Vector<String> v = getFieldVector(null, "RelativeAltSrcFileList");
if (v == null) {
return null;
}
for (String pathPart : v) {
if (path.endsWith(pathPart)) {
String relativeAltSrcInclude =
getFieldString(null, "RelativeAltSrcInclude");
return relativeAltSrcInclude + Util.sep + pathPart;
}
}
return null;
}
// Returns true if the specified path has a matching alternate
// source file.
public static boolean matchesRelativeAltSrcFile(String path) {
return getMatchingRelativeAltSrcFile(path) != null;
}
// Track the specified alternate source file. The source file is
// tracked without the leading .*<sep><RelativeAltSrcFileList><sep>
// part to make matching regular source files easier.
public static void trackRelativeAltSrcFile(String path) {
String pattern = getFieldString(null, "RelativeAltSrcInclude") +
Util.sep;
int altSrcInd = path.indexOf(pattern);
if (altSrcInd == -1) {
// not an AltSrc path
return;
}
altSrcInd += pattern.length();
if (altSrcInd >= path.length()) {
// not a valid AltSrc path
return;
}
String altSrcFile = path.substring(altSrcInd);
Vector v = getFieldVector(null, "RelativeAltSrcFileList");
if (v == null || !v.contains(altSrcFile)) {
addFieldVector(null, "RelativeAltSrcFileList", altSrcFile);
}
}
void addTo(Hashtable ht, String key, String value) {
ht.put(expandFormat(key), expandFormat(value));
}
@ -272,8 +335,19 @@ class BuildConfig {
private Vector getSourceIncludes() {
Vector<String> rv = new Vector<String>();
Vector<String> ri = new Vector<String>();
String sourceBase = getFieldString(null, "SourceBase");
// add relative alternate source include values:
String relativeAltSrcInclude =
getFieldString(null, "RelativeAltSrcInclude");
Vector<String> asri = new Vector<String>();
collectRelevantVectors(asri, "AltRelativeInclude");
for (String f : asri) {
rv.add(sourceBase + Util.sep + relativeAltSrcInclude +
Util.sep + f);
}
Vector<String> ri = new Vector<String>();
collectRelevantVectors(ri, "RelativeInclude");
for (String f : ri) {
rv.add(sourceBase + Util.sep + f);
@ -541,35 +615,6 @@ class TieredProductConfig extends ProductConfig {
}
}
class CoreDebugConfig extends GenericDebugNonKernelConfig {
String getOptFlag() {
return getCI().getNoOptFlag();
}
CoreDebugConfig() {
initNames("core", "debug", "jvm.dll");
init(getIncludes(), getDefines());
}
}
class CoreFastDebugConfig extends GenericDebugNonKernelConfig {
String getOptFlag() {
return getCI().getOptFlag();
}
CoreFastDebugConfig() {
initNames("core", "fastdebug", "jvm.dll");
init(getIncludes(), getDefines());
}
}
class CoreProductConfig extends ProductConfig {
CoreProductConfig() {
initNames("core", "product", "jvm.dll");
init(getIncludes(), getDefines());
}
}
abstract class CompilerInterface {
abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir);

View file

@ -1,3 +1,27 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
import static java.nio.file.FileVisitResult.CONTINUE;
import java.io.IOException;
@ -21,6 +45,8 @@ public class FileTreeCreatorVC10 extends FileTreeCreator {
boolean usePch = false;
boolean disablePch = false;
boolean useIgnore = false;
boolean isAltSrc = false; // only needed as a debugging crumb
boolean isReplacedByAltSrc = false;
String fileName = file.getFileName().toString();
// TODO hideFile
@ -30,6 +56,26 @@ public class FileTreeCreatorVC10 extends FileTreeCreator {
usePch = true;
}
String fileLoc = vcProjLocation.relativize(file).toString();
// isAltSrc and isReplacedByAltSrc applies to all configs for a file
if (BuildConfig.matchesRelativeAltSrcInclude(
file.toAbsolutePath().toString())) {
// current file is an alternate source file so track it
isAltSrc = true;
BuildConfig.trackRelativeAltSrcFile(
file.toAbsolutePath().toString());
} else if (BuildConfig.matchesRelativeAltSrcFile(
file.toAbsolutePath().toString())) {
// current file is a regular file that matches an alternate
// source file so yack about replacing the regular file
isReplacedByAltSrc = true;
System.out.println("INFO: alternate source file '" +
BuildConfig.getMatchingRelativeAltSrcFile(
file.toAbsolutePath().toString()) +
"' replaces '" + fileLoc + "'");
}
for (BuildConfig cfg : allConfigs) {
if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {
useIgnore = true;
@ -58,9 +104,8 @@ public class FileTreeCreatorVC10 extends FileTreeCreator {
}
String tagName = wg.getFileTagFromSuffix(fileName);
String fileLoc = vcProjLocation.relativize(file).toString();
if (!useIgnore && !disablePch && !usePch) {
if (!useIgnore && !disablePch && !usePch && !isReplacedByAltSrc) {
wg.tag(tagName, new String[] { "Include", fileLoc});
} else {
wg.startTag(
@ -78,6 +123,11 @@ public class FileTreeCreatorVC10 extends FileTreeCreator {
if (disablePch) {
wg.tag("PrecompiledHeader", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
}
if (isReplacedByAltSrc) {
wg.tagData("ExcludedFromBuild", "true", "Condition",
"'$(Configuration)|$(Platform)'=='" +
cfg.get("Name") + "'");
}
}
wg.endTag();
}
@ -137,6 +187,4 @@ public class FileTreeCreatorVC10 extends FileTreeCreator {
public void writeFileTree() throws IOException {
Files.walkFileTree(this.startDir, this);
}
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -39,10 +39,15 @@ public class ProjectCreator {
+ "jvm.dll; no trailing slash>");
System.err.println(" If any of the above are specified, "
+ "they must all be.");
System.err.println(" Note: if '-altRelativeInclude' option below is "
+ "used, then the '-relativeAltSrcInclude' option must be used "
+ "to specify the alternate source dir, e.g., 'src\\closed'");
System.err.println(" Additional, optional arguments, which can be "
+ "specified multiple times:");
System.err.println(" -absoluteInclude <string containing absolute "
+ "path to include directory>");
System.err.println(" -altRelativeInclude <string containing "
+ "alternate include directory relative to -envVar>");
System.err.println(" -relativeInclude <string containing include "
+ "directory relative to -envVar>");
System.err.println(" -define <preprocessor flag to be #defined "

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -140,10 +140,17 @@ public abstract class WinGammaPlatform {
"already exist>");
System.err.println(" If any of the above are specified, "+
"they must all be.");
System.err.println(" Note: if '-altRelativeInclude' option below " +
"is used, then the '-relativeAltSrcInclude' " +
"option must be used to specify the alternate " +
"source dir, e.g., 'src\\closed'");
System.err.println(" Additional, optional arguments, which can be " +
"specified multiple times:");
System.err.println(" -absoluteInclude <string containing absolute " +
"path to include directory>");
System.err.println(" -altRelativeInclude <string containing " +
"alternate include directory relative to " +
"-sourceBase>");
System.err.println(" -relativeInclude <string containing include " +
"directory relative to -sourceBase>");
System.err.println(" -define <preprocessor flag to be #defined " +
@ -343,6 +350,12 @@ public abstract class WinGammaPlatform {
HsArgHandler.VECTOR
),
new HsArgRule("-altRelativeInclude",
"AltRelativeInclude",
null,
HsArgHandler.VECTOR
),
new HsArgRule("-relativeInclude",
"RelativeInclude",
null,
@ -355,6 +368,12 @@ public abstract class WinGammaPlatform {
HsArgHandler.VECTOR
),
new HsArgRule("-relativeAltSrcInclude",
"RelativeAltSrcInclude",
null,
HsArgHandler.STRING
),
new HsArgRule("-relativeSrcInclude",
"RelativeSrcInclude",
null,
@ -560,10 +579,6 @@ public abstract class WinGammaPlatform {
allConfigs.add(new TieredFastDebugConfig());
allConfigs.add(new TieredProductConfig());
allConfigs.add(new CoreDebugConfig());
allConfigs.add(new CoreFastDebugConfig());
allConfigs.add(new CoreProductConfig());
return allConfigs;
}

View file

@ -1,3 +1,27 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -24,7 +48,7 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
public void writeProjectFile(String projectFileName, String projectName,
Vector<BuildConfig> allConfigs) throws IOException {
System.out.println();
System.out.print(" Writing .vcxproj file: " + projectFileName);
System.out.println(" Writing .vcxproj file: " + projectFileName);
String projDir = Util.normalize(new File(projectFileName).getParent());
@ -114,7 +138,7 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
endTag();
printWriter.close();
System.out.println(" Done.");
System.out.println(" Done writing .vcxproj file.");
writeFilterFile(projectFileName, projectName, allConfigs, projDir);
writeUserFile(projectFileName, allConfigs);