OpenJDK / zgc / zgc
changeset 38247:6ff550a6307e
8156018: Hotspot visual studio project generation broken
Reviewed-by: mgronlun, ctornqvi
Contributed-by: magnus.ihse.bursie@oracle.com
author | erikj |
---|---|
date | Mon, 09 May 2016 13:22:39 +0200 |
parents | 250794c6f95f |
children | ccb245cf1fa6 |
files | hotspot/make/src/classes/build/tools/projectcreator/ArgsParser.java hotspot/make/src/classes/build/tools/projectcreator/BuildConfig.java hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreator.java hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreatorVC10.java hotspot/make/src/classes/build/tools/projectcreator/ProjectCreator.java hotspot/make/src/classes/build/tools/projectcreator/Util.java hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatform.java hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java hotspot/src/share/tools/ProjectCreator/ArgsParser.java hotspot/src/share/tools/ProjectCreator/BuildConfig.java hotspot/src/share/tools/ProjectCreator/FileTreeCreator.java hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java hotspot/src/share/tools/ProjectCreator/ProjectCreator.java hotspot/src/share/tools/ProjectCreator/Util.java hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java |
diffstat | 16 files changed, 2353 insertions(+), 2307 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/make/src/classes/build/tools/projectcreator/ArgsParser.java Mon May 09 13:22:39 2016 +0200 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2005, 2016, 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. + * + */ + +package build.tools.projectcreator; + +class ArgIterator { + String[] args; + int i; + ArgIterator(String[] args) { + this.args = args; + this.i = 0; + } + String get() { return args[i]; } + boolean hasMore() { return args != null && i < args.length; } + boolean next() { return ++i < args.length; } +} + +abstract class ArgHandler { + public abstract void handle(ArgIterator it); + +} + +class ArgRule { + String arg; + ArgHandler handler; + ArgRule(String arg, ArgHandler handler) { + this.arg = arg; + this.handler = handler; + } + + boolean process(ArgIterator it) { + if (match(it.get(), arg)) { + handler.handle(it); + return true; + } + return false; + } + boolean match(String rule_pattern, String arg) { + return arg.equals(rule_pattern); + } +} + +class ArgsParser { + ArgsParser(String[] args, + ArgRule[] rules, + ArgHandler defaulter) { + ArgIterator ai = new ArgIterator(args); + while (ai.hasMore()) { + boolean processed = false; + for (int i=0; i<rules.length; i++) { + processed |= rules[i].process(ai); + if (processed) { + break; + } + } + if (!processed) { + if (defaulter != null) { + defaulter.handle(ai); + } else { + System.err.println("ERROR: unparsed \""+ai.get()+"\""); + ai.next(); + } + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/make/src/classes/build/tools/projectcreator/BuildConfig.java Mon May 09 13:22:39 2016 +0200 @@ -0,0 +1,624 @@ +/* + * Copyright (c) 2005, 2016, 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. + * + */ + +package build.tools.projectcreator; + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; + +class BuildConfig { + @SuppressWarnings("rawtypes") + Hashtable vars; + Vector<String> basicNames, basicPaths; + String[] context; + + static CompilerInterface ci; + static CompilerInterface getCI() { + if (ci == null) { + String comp = (String)getField(null, "CompilerVersion"); + try { + ci = (CompilerInterface)Class.forName("build.tools.projectcreator.CompilerInterface" + comp).newInstance(); + } catch (Exception cnfe) { + System.err.println("Cannot find support for compiler " + comp); + throw new RuntimeException(cnfe.toString()); + } + } + return ci; + } + + @SuppressWarnings("rawtypes") + protected void initNames(String flavour, String build, String outDll) { + if (vars == null) vars = new Hashtable(); + + String flavourBuild = flavour + "_" + build; + String platformName = getFieldString(null, "PlatformName"); + System.out.println(); + System.out.println(flavourBuild); + + put("Name", getCI().makeCfgName(flavourBuild, platformName)); + put("Flavour", flavour); + put("Build", build); + put("PlatformName", platformName); + + // ones mentioned above were needed to expand format + String buildBase = expandFormat(getFieldString(null, "BuildBase")); + String sourceBase = getFieldString(null, "SourceBase"); + String buildSpace = getFieldString(null, "BuildSpace"); + String outDir = buildBase; + String jdkTargetRoot = getFieldString(null, "JdkTargetRoot"); + String makeBinary = getFieldString(null, "MakeBinary"); + String makeOutput = expandFormat(getFieldString(null, "MakeOutput")); + + put("Id", flavourBuild); + put("OutputDir", outDir); + put("SourceBase", sourceBase); + put("BuildBase", buildBase); + put("BuildSpace", buildSpace); + put("OutputDll", outDir + Util.sep + outDll); + put("JdkTargetRoot", jdkTargetRoot); + put("MakeBinary", makeBinary); + put("MakeOutput", makeOutput); + + context = new String [] {flavourBuild, flavour, build, null}; + } + + protected void init(Vector<String> includes, Vector<String> defines) { + initDefaultDefines(defines); + initDefaultCompilerFlags(includes); + initDefaultLinkerFlags(); + //handleDB(); + } + + + protected void initDefaultCompilerFlags(Vector<String> includes) { + Vector compilerFlags = new Vector(); + + compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"), + includes, + get("OutputDir"))); + + put("CompilerFlags", compilerFlags); + } + + protected void initDefaultLinkerFlags() { + Vector linkerFlags = new Vector(); + + linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll"), get("PlatformName"))); + + put("LinkerFlags", linkerFlags); + } + + public boolean matchesIgnoredPath(String path) { + Vector<String> rv = new Vector<String>(); + collectRelevantVectors(rv, "IgnorePath"); + for (String pathPart : rv) { + if (path.contains(pathPart)) { + return true; + } + } + return false; + } + + public boolean matchesHidePath(String path) { + Vector<String> rv = new Vector<String>(); + collectRelevantVectors(rv, "HidePath"); + for (String pathPart : rv) { + if (path.contains(Util.normalize(pathPart))) { + return true; + } + } + return false; + } + + public Vector<String> matchesAdditionalGeneratedPath(String fullPath) { + Vector<String> rv = new Vector<String>(); + Hashtable<String, String> v = (Hashtable<String, String>)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile"); + if (v != null) { + for (Enumeration<String> e=v.keys(); e.hasMoreElements(); ) { + String key = e.nextElement(); + String val = v.get(key); + + if (fullPath.endsWith(expandFormat(key))) { + rv.add(expandFormat(val)); + } + } + } + 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"); + if (v != null) { + 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)); + } + + void initDefaultDefines(Vector defines) { + Vector sysDefines = new Vector(); + sysDefines.add("WIN32"); + sysDefines.add("_WINDOWS"); + sysDefines.add("HOTSPOT_BUILD_USER=\\\""+System.getProperty("user.name")+"\\\""); + sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\""); + sysDefines.add("INCLUDE_TRACE=1"); + sysDefines.add("_JNI_IMPLEMENTATION_"); + if (vars.get("PlatformName").equals("Win32")) { + sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\""); + } else { + sysDefines.add("HOTSPOT_LIB_ARCH=\\\"amd64\\\""); + } + sysDefines.add("DEBUG_LEVEL=\\\"" + get("Build")+"\\\""); + sysDefines.addAll(defines); + + put("Define", sysDefines); + } + + String get(String key) { + return (String)vars.get(key); + } + + Vector getV(String key) { + return (Vector)vars.get(key); + } + + Object getO(String key) { + return vars.get(key); + } + + Hashtable getH(String key) { + return (Hashtable)vars.get(key); + } + + Object getFieldInContext(String field) { + for (int i=0; i<context.length; i++) { + Object rv = getField(context[i], field); + if (rv != null) { + return rv; + } + } + return null; + } + + Object lookupHashFieldInContext(String field, String key) { + for (int i=0; i<context.length; i++) { + Hashtable ht = (Hashtable)getField(context[i], field); + if (ht != null) { + Object rv = ht.get(key); + if (rv != null) { + return rv; + } + } + } + return null; + } + + void put(String key, String value) { + vars.put(key, value); + } + + void put(String key, Vector vvalue) { + vars.put(key, vvalue); + } + + void add(String key, Vector vvalue) { + getV(key).addAll(vvalue); + } + + String flavour() { + return get("Flavour"); + } + + String build() { + return get("Build"); + } + + Object getSpecificField(String field) { + return getField(get("Id"), field); + } + + void putSpecificField(String field, Object value) { + putField(get("Id"), field, value); + } + + void collectRelevantVectors(Vector rv, String field) { + for (String ctx : context) { + Vector<String> v = getFieldVector(ctx, field); + if (v != null) { + for (String val : v) { + rv.add(expandFormat(val).replace('/', '\\')); + } + } + } + } + + void collectRelevantHashes(Hashtable rv, String field) { + for (String ctx : context) { + Hashtable v = (Hashtable)getField(ctx, field); + if (v != null) { + for (Enumeration e=v.keys(); e.hasMoreElements(); ) { + String key = (String)e.nextElement(); + String val = (String)v.get(key); + addTo(rv, key, val); + } + } + } + } + + + Vector getDefines() { + Vector rv = new Vector(); + collectRelevantVectors(rv, "Define"); + return rv; + } + + Vector getIncludes() { + Vector rv = new Vector(); + collectRelevantVectors(rv, "AbsoluteInclude"); + rv.addAll(getSourceIncludes()); + return rv; + } + + private Vector getSourceIncludes() { + Vector<String> rv = 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); + } + return rv; + } + + static Hashtable cfgData = new Hashtable(); + static Hashtable globalData = new Hashtable(); + + static boolean appliesToTieredBuild(String cfg) { + return (cfg != null && + cfg.startsWith("server")); + } + + // Filters out the IgnoreFile and IgnorePaths since they are + // handled specially for tiered builds. + static boolean appliesToTieredBuild(String cfg, String key) { + return (appliesToTieredBuild(cfg))&& (key != null && !key.startsWith("Ignore")); + } + + static String getTieredBuildCfg(String cfg) { + assert appliesToTieredBuild(cfg) : "illegal configuration " + cfg; + return "server"; + } + + static Object getField(String cfg, String field) { + if (cfg == null) { + return globalData.get(field); + } + + Hashtable ht = (Hashtable)cfgData.get(cfg); + return ht == null ? null : ht.get(field); + } + + static String getFieldString(String cfg, String field) { + return (String)getField(cfg, field); + } + + static Vector getFieldVector(String cfg, String field) { + return (Vector)getField(cfg, field); + } + + static void putField(String cfg, String field, Object value) { + putFieldImpl(cfg, field, value); + if (appliesToTieredBuild(cfg, field)) { + putFieldImpl(getTieredBuildCfg(cfg), field, value); + } + } + + private static void putFieldImpl(String cfg, String field, Object value) { + if (cfg == null) { + globalData.put(field, value); + return; + } + + Hashtable ht = (Hashtable)cfgData.get(cfg); + if (ht == null) { + ht = new Hashtable(); + cfgData.put(cfg, ht); + } + + ht.put(field, value); + } + + static Object getFieldHash(String cfg, String field, String name) { + Hashtable ht = (Hashtable)getField(cfg, field); + + return ht == null ? null : ht.get(name); + } + + static void putFieldHash(String cfg, String field, String name, Object val) { + putFieldHashImpl(cfg, field, name, val); + if (appliesToTieredBuild(cfg, field)) { + putFieldHashImpl(getTieredBuildCfg(cfg), field, name, val); + } + } + + private static void putFieldHashImpl(String cfg, String field, String name, Object val) { + Hashtable ht = (Hashtable)getField(cfg, field); + + if (ht == null) { + ht = new Hashtable(); + putFieldImpl(cfg, field, ht); + } + + ht.put(name, val); + } + + static void addFieldVector(String cfg, String field, String element) { + addFieldVectorImpl(cfg, field, element); + if (appliesToTieredBuild(cfg, field)) { + addFieldVectorImpl(getTieredBuildCfg(cfg), field, element); + } + } + + private static void addFieldVectorImpl(String cfg, String field, String element) { + Vector v = (Vector)getField(cfg, field); + + if (v == null) { + v = new Vector(); + putFieldImpl(cfg, field, v); + } + + v.add(element); + } + + String expandFormat(String format) { + if (format == null) { + return null; + } + + if (format.indexOf('%') == -1) { + return format; + } + + StringBuffer sb = new StringBuffer(); + int len = format.length(); + for (int i=0; i<len; i++) { + char ch = format.charAt(i); + if (ch == '%') { + char ch1 = format.charAt(i+1); + switch (ch1) { + case '%': + sb.append(ch1); + break; + case 'b': + sb.append(build()); + break; + case 'f': + sb.append(flavour()); + break; + default: + sb.append(ch); + sb.append(ch1); + } + i++; + } else { + sb.append(ch); + } + } + + return sb.toString(); + } +} + +abstract class GenericDebugConfig extends BuildConfig { + abstract String getOptFlag(); + + protected void init(Vector includes, Vector defines) { + defines.add("_DEBUG"); + defines.add("ASSERT"); + + super.init(includes, defines); + + getV("CompilerFlags").addAll(getCI().getDebugCompilerFlags(getOptFlag(), get("PlatformName"))); + getV("LinkerFlags").addAll(getCI().getDebugLinkerFlags()); + } +} + +abstract class GenericDebugNonKernelConfig extends GenericDebugConfig { + protected void init(Vector includes, Vector defines) { + super.init(includes, defines); + if (get("PlatformName").equals("Win32")) { + getCI().getAdditionalNonKernelLinkerFlags(getV("LinkerFlags")); + } + } +} + +class C1DebugConfig extends GenericDebugNonKernelConfig { + String getOptFlag() { + return getCI().getNoOptFlag(); + } + + C1DebugConfig() { + initNames("client", "debug", "jvm.dll"); + init(getIncludes(), getDefines()); + } +} + +class C1FastDebugConfig extends GenericDebugNonKernelConfig { + String getOptFlag() { + return getCI().getOptFlag(); + } + + C1FastDebugConfig() { + initNames("client", "fastdebug", "jvm.dll"); + init(getIncludes(), getDefines()); + } +} + +class TieredDebugConfig extends GenericDebugNonKernelConfig { + String getOptFlag() { + return getCI().getNoOptFlag(); + } + + TieredDebugConfig() { + initNames("server", "debug", "jvm.dll"); + init(getIncludes(), getDefines()); + } +} + +class TieredFastDebugConfig extends GenericDebugNonKernelConfig { + String getOptFlag() { + return getCI().getOptFlag(); + } + + TieredFastDebugConfig() { + initNames("server", "fastdebug", "jvm.dll"); + init(getIncludes(), getDefines()); + } +} + +abstract class ProductConfig extends BuildConfig { + protected void init(Vector includes, Vector defines) { + defines.add("NDEBUG"); + defines.add("PRODUCT"); + + super.init(includes, defines); + + getV("CompilerFlags").addAll(getCI().getProductCompilerFlags()); + getV("LinkerFlags").addAll(getCI().getProductLinkerFlags()); + } +} + +class C1ProductConfig extends ProductConfig { + C1ProductConfig() { + initNames("client", "product", "jvm.dll"); + init(getIncludes(), getDefines()); + } +} + +class TieredProductConfig extends ProductConfig { + TieredProductConfig() { + initNames("server", "product", "jvm.dll"); + init(getIncludes(), getDefines()); + } +} + + +abstract class CompilerInterface { + abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir); + abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName); + abstract Vector getDebugCompilerFlags(String opt, String platformName); + abstract Vector getDebugLinkerFlags(); + abstract void getAdditionalNonKernelLinkerFlags(Vector rv); + abstract Vector getProductCompilerFlags(); + abstract Vector getProductLinkerFlags(); + abstract String getOptFlag(); + abstract String getNoOptFlag(); + abstract String makeCfgName(String flavourBuild, String platformName); + + void addAttr(Vector receiver, String attr, String value) { + receiver.add(attr); receiver.add(value); + } + void extAttr(Vector receiver, String attr, String value) { + int attr_pos=receiver.indexOf(attr) ; + if ( attr_pos == -1) { + // If attr IS NOT present in the Vector - add it + receiver.add(attr); receiver.add(value); + } else { + // If attr IS present in the Vector - append value to it + receiver.set(attr_pos+1,receiver.get(attr_pos+1)+value); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreator.java Mon May 09 13:22:39 2016 +0200 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2012, 2016, 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. + * + */ + +package build.tools.projectcreator; + +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.util.HashSet; +import java.util.Stack; +import java.util.Vector; + +public class FileTreeCreator extends SimpleFileVisitor<Path> +{ + Path vcProjLocation; + Path startDir; + final int startDirLength; + Stack<DirAttributes> attributes = new Stack<DirAttributes>(); + Vector<BuildConfig> allConfigs; + WinGammaPlatform wg; + WinGammaPlatformVC10 wg10; + + public FileTreeCreator(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) { + super(); + this.wg = wg; + if (wg instanceof WinGammaPlatformVC10) { + wg10 = (WinGammaPlatformVC10)wg; + } + this.allConfigs = allConfigs; + this.startDir = startDir; + startDirLength = startDir.toAbsolutePath().toString().length(); + vcProjLocation = FileSystems.getDefault().getPath(allConfigs.firstElement().get("BuildSpace")); + attributes.push(new DirAttributes()); + } + + public class DirAttributes { + + private HashSet<BuildConfig> ignores; + private HashSet<BuildConfig> disablePch; + + public DirAttributes() { + ignores = new HashSet<BuildConfig>(); + disablePch = new HashSet<BuildConfig>(); + } + + public DirAttributes(HashSet<BuildConfig> excludes2, HashSet<BuildConfig> disablePch2) { + ignores = excludes2; + disablePch = disablePch2; + } + + @SuppressWarnings("unchecked") + public DirAttributes clone() { + return new DirAttributes((HashSet<BuildConfig>)this.ignores.clone(), (HashSet<BuildConfig>)this.disablePch.clone()); + } + + public void setIgnore(BuildConfig conf) { + ignores.add(conf); + } + + public boolean hasIgnore(BuildConfig cfg) { + return ignores.contains(cfg); + } + + public void removeFromIgnored(BuildConfig cfg) { + ignores.remove(cfg); + } + + public void setDisablePch(BuildConfig conf) { + disablePch.add(conf); + } + + public boolean hasDisablePch(BuildConfig cfg) { + return disablePch.contains(cfg); + } + + public void removeFromDisablePch(BuildConfig cfg) { + disablePch.remove(cfg); + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreatorVC10.java Mon May 09 13:22:39 2016 +0200 @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2012, 2016, 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. + * + */ + +package build.tools.projectcreator; + +import static java.nio.file.FileVisitResult.CONTINUE; + +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Stack; +import java.util.Vector; + +public class FileTreeCreatorVC10 extends FileTreeCreator { + + public FileTreeCreatorVC10(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) { + super(startDir, allConfigs, wg); + } + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attr) { + DirAttributes currentFileAttr = attributes.peek().clone(); + 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 + + // usePch applies to all configs for a file. + if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) { + 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; + currentFileAttr.setIgnore(cfg); + } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) { + useIgnore = true; + currentFileAttr.setIgnore(cfg); + } + + if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) { + disablePch = true; + currentFileAttr.setDisablePch(cfg); + } + + Vector<String> rv = new Vector<String>(); + cfg.collectRelevantVectors(rv, "AdditionalFile"); + for(String addFile : rv) { + if (addFile.equals(fileName)) { + // supress any ignore + // TODO - may need some adjustments + if (file.toAbsolutePath().toString().contains(cfg.get("Flavour"))) { + currentFileAttr.removeFromIgnored(cfg); + } + } + } + } + + String tagName = wg10.getFileTagFromSuffix(fileName); + + if (!useIgnore && !disablePch && !usePch && !isReplacedByAltSrc) { + wg.tag(tagName, new String[] { "Include", fileLoc}); + } else { + wg.startTag( + tagName, + new String[] { "Include", fileLoc}); + + for (BuildConfig cfg : allConfigs) { + boolean ignore = currentFileAttr.hasIgnore(cfg); + if (ignore) { + wg.tagData("ExcludedFromBuild", "true", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); + } + if (usePch) { + wg.tagData("PrecompiledHeader", "Create", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); + } + 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(); + } + + String filter = startDir.relativize(file.getParent().toAbsolutePath()).toString(); + wg10.addFilterDependency(fileLoc, filter); + + return CONTINUE; + } + + @Override + public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) + throws IOException { + Boolean hide = false; + // TODO remove attrs, if path is matched in this dir, then it is too in every subdir. + // And we will check anyway + DirAttributes newAttr = attributes.peek().clone(); + + // check per config ignorePaths! + for (BuildConfig cfg : allConfigs) { + if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { + newAttr.setIgnore(cfg); + } + + // Hide is always on all configs. And additional files are never hiddden + if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { + hide = true; + break; + } + } + + if (!hide) { + String name = startDir.relativize(path.toAbsolutePath()).toString(); + if (!"".equals(name)) { + wg10.addFilter(name); + } + + attributes.push(newAttr); + return super.preVisitDirectory(path, attrs); + } else { + return FileVisitResult.SKIP_SUBTREE; + } + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) { + //end matching attributes set by ignorepath + attributes.pop(); + return CONTINUE; + } + + @Override + public FileVisitResult visitFileFailed(Path file, IOException exc) { + return CONTINUE; + } + + public void writeFileTree() throws IOException { + Files.walkFileTree(this.startDir, this); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/make/src/classes/build/tools/projectcreator/ProjectCreator.java Mon May 09 13:22:39 2016 +0200 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 1999, 2016, 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. + * + */ + +package build.tools.projectcreator; + +public class ProjectCreator { + + public static void usage() { + System.out.println("ProjectCreator options:"); + System.err.println("WinGammaPlatform platform-specific options:"); + System.err.println(" -sourceBase <path to directory (workspace) " + + "containing source files; no trailing slash>"); + System.err.println(" -dspFileName <full pathname to which .dsp file " + + "will be written; all parent directories must " + + "already exist>"); + System.err.println(" -envVar <environment variable to be inserted " + + "into .dsp file, substituting for path given in " + + "-sourceBase. Example: HotSpotWorkSpace>"); + System.err.println(" -dllLoc <path to directory in which to put " + + "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 " + + "(note: doesn't yet support " + "#define (flag) (value))>"); + System.err.println(" -perFileLine <file> <line>"); + System.err.println(" -conditionalPerFileLine <file> <line for " + + "release build> <line for debug build>"); + System.err.println(" (NOTE: To work around a bug in nmake, where " + + "you can't have a '#' character in a quoted " + + "string, all of the lines outputted have \"#\"" + "prepended)"); + System.err.println(" -startAt <subdir of sourceBase>"); + System.err.println(" -ignoreFile <file which won't be able to be " + + "found in the sourceBase because it's generated " + "later>"); + System.err.println(" -additionalFile <file not in database but " + + "which should show up in .dsp file>"); + System.err + .println(" -additionalGeneratedFile <environment variable of " + + "generated file's location> <relative path to " + + "directory containing file; no trailing slash> " + + "<name of file generated later in the build process>"); + System.err.println(" -prelink <build> <desc> <cmds>:"); + System.err + .println(" Generate a set of prelink commands for the given BUILD"); + System.err + .println(" (\"Debug\" or \"Release\"). The prelink description and commands"); + System.err.println(" are both quoted strings."); + System.err.println(" Default includes: \".\""); + System.err + .println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\""); + } + + public static void main(String[] args) { + try { + if (args.length < 3) { + usage(); + System.exit(1); + } + + String platformName = args[0]; + Class platformClass = Class.forName(platformName); + WinGammaPlatform platform = (WinGammaPlatform) platformClass + .newInstance(); + + String[] platformArgs = new String[args.length - 1]; + System.arraycopy(args, 1, platformArgs, 0, platformArgs.length); + + // Allow the platform to write platform-specific files + platform.createVcproj(platformArgs); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/make/src/classes/build/tools/projectcreator/Util.java Mon May 09 13:22:39 2016 +0200 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2005, 2016, 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. + * + */ + +package build.tools.projectcreator; + +import java.util.*; +import java.io.File; + +public class Util { + + static String join(String padder, Vector<String> v) { + return join(padder, v, false); + } + + static String join(String padder, Vector<String> v, boolean quoted) { + StringBuffer sb = new StringBuffer(); + + for (Iterator<String> iter = v.iterator(); iter.hasNext(); ) { + if (quoted) { + sb.append('"'); + } + sb.append(iter.next()); + if (quoted) { + sb.append('"'); + } + if (iter.hasNext()) sb.append(padder); + } + + return sb.toString(); + } + + + static String prefixed_join(String padder, Vector<String> v, boolean quoted) { + StringBuffer sb = new StringBuffer(); + + for (Iterator<String> iter = v.iterator(); iter.hasNext(); ) { + sb.append(padder); + + if (quoted) { + sb.append('"'); + } + sb.append((String)iter.next()); + if (quoted) { + sb.append('"'); + } + } + + return sb.toString(); + } + + + static String normalize(String file) { + file = file.replace('\\', '/'); + if (file.length() > 2) { + if (file.charAt(1) == ':' && file.charAt(2) == '/') { + // convert drive letter to uppercase + String drive = file.substring(0, 1).toUpperCase(); + return drive + file.substring(1); + } + } + return file; + } + + static String sep = File.separator; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatform.java Mon May 09 13:22:39 2016 +0200 @@ -0,0 +1,685 @@ +/* + * Copyright (c) 1999, 2016, 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. + * + */ + +package build.tools.projectcreator; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Stack; +import java.util.Vector; + +abstract class HsArgHandler extends ArgHandler { + static final int STRING = 1; + static final int VECTOR = 2; + static final int HASH = 3; + + boolean nextNotKey(ArgIterator it) { + if (it.next()) { + String s = it.get(); + return (s.length() == 0) || (s.charAt(0) != '-'); + } else { + return false; + } + } + + void empty(String key, String message) { + if (key != null) { + System.err.println("** Error: empty " + key); + } + if (message != null) { + System.err.println(message); + } + WinGammaPlatform.usage(); + } + + static String getCfg(String val) { + int under = val.indexOf('_'); + int len = val.length(); + if (under != -1 && under < len - 1) { + return val.substring(under+1, len); + } else { + return null; + } + } +} + +class ArgRuleSpecific extends ArgRule { + ArgRuleSpecific(String arg, ArgHandler handler) { + super(arg, handler); + } + + boolean match(String rulePattern, String arg) { + return rulePattern.startsWith(arg); + } +} + + +class SpecificHsArgHandler extends HsArgHandler { + + String message, argKey, valKey; + int type; + + public void handle(ArgIterator it) { + String cfg = getCfg(it.get()); + if (nextNotKey(it)) { + String val = it.get(); + switch (type) { + case VECTOR: + BuildConfig.addFieldVector(cfg, valKey, val); + break; + case HASH: + BuildConfig.putFieldHash(cfg, valKey, val, "1"); + break; + case STRING: + BuildConfig.putField(cfg, valKey, val); + break; + default: + empty(valKey, "Unknown type: "+type); + } + it.next(); + + } else { + empty(argKey, message); + } + } + + SpecificHsArgHandler(String argKey, String valKey, String message, int type) { + this.argKey = argKey; + this.valKey = valKey; + this.message = message; + this.type = type; + } +} + + +class HsArgRule extends ArgRuleSpecific { + + HsArgRule(String argKey, String valKey, String message, int type) { + super(argKey, new SpecificHsArgHandler(argKey, valKey, message, type)); + } + +} + +public abstract class WinGammaPlatform { + + public boolean fileNameStringEquality(String s1, String s2) { + return s1.equalsIgnoreCase(s2); + } + + static void usage() throws IllegalArgumentException { + System.err.println("WinGammaPlatform platform-specific options:"); + System.err.println(" -sourceBase <path to directory (workspace) " + + "containing source files; no trailing slash>"); + System.err.println(" -projectFileName <full pathname to which project file " + + "will be written; all parent directories must " + + "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 " + + "(note: doesn't yet support " + + "#define (flag) (value))>"); + System.err.println(" -startAt <subdir of sourceBase>"); + System.err.println(" -additionalFile <file not in database but " + + "which should show up in project file>"); + System.err.println(" -additionalGeneratedFile <absolute path to " + + "directory containing file; no trailing slash> " + + "<name of file generated later in the build process>"); + throw new IllegalArgumentException(); + } + + + public void addPerFileLine(Hashtable table, + String fileName, + String line) { + Vector v = (Vector) table.get(fileName); + if (v != null) { + v.add(line); + } else { + v = new Vector(); + v.add(line); + table.put(fileName, v); + } + } + + protected static class PerFileCondData { + public String releaseString; + public String debugString; + } + + protected void addConditionalPerFileLine(Hashtable table, + String fileName, + String releaseLine, + String debugLine) { + PerFileCondData data = new PerFileCondData(); + data.releaseString = releaseLine; + data.debugString = debugLine; + Vector v = (Vector) table.get(fileName); + if (v != null) { + v.add(data); + } else { + v = new Vector(); + v.add(data); + table.put(fileName, v); + } + } + + protected static class PrelinkCommandData { + String description; + String commands; + } + + protected void addPrelinkCommand(Hashtable table, + String build, + String description, + String commands) { + PrelinkCommandData data = new PrelinkCommandData(); + data.description = description; + data.commands = commands; + table.put(build, data); + } + + public boolean findString(Vector v, String s) { + for (Iterator iter = v.iterator(); iter.hasNext(); ) { + if (((String) iter.next()).equals(s)) { + return true; + } + } + + return false; + } + + String getProjectName(String fullPath, String extension) + throws IllegalArgumentException, IOException { + File file = new File(fullPath).getCanonicalFile(); + fullPath = file.getCanonicalPath(); + String parent = file.getParent(); + + if (!fullPath.endsWith(extension)) { + throw new IllegalArgumentException("project file name \"" + + fullPath + + "\" does not end in "+extension); + } + + if ((parent != null) && + (!fullPath.startsWith(parent))) { + throw new RuntimeException( + "Internal error: parent of file name \"" + parent + + "\" does not match file name \"" + fullPath + "\"" + ); + } + + int len = parent.length(); + if (!parent.endsWith(Util.sep)) { + len += Util.sep.length(); + } + + int end = fullPath.length() - extension.length(); + + if (len == end) { + throw new RuntimeException( + "Internal error: file name was empty" + ); + } + + return fullPath.substring(len, end); + } + + protected abstract String getProjectExt(); + + public void createVcproj(String[] args) + throws IllegalArgumentException, IOException { + + parseArguments(args); + + String projectFileName = BuildConfig.getFieldString(null, "ProjectFileName"); + String ext = getProjectExt(); + + String projectName = getProjectName(projectFileName, ext); + + writeProjectFile(projectFileName, projectName, createAllConfigs(BuildConfig.getFieldString(null, "PlatformName"))); + } + + protected void writePrologue(String[] args) { + System.err.println("WinGammaPlatform platform-specific arguments:"); + for (int i = 0; i < args.length; i++) { + System.err.print(args[i] + " "); + } + System.err.println(); + } + + + void parseArguments(String[] args) { + new ArgsParser(args, + new ArgRule[] + { + new ArgRule("-sourceBase", + new HsArgHandler() { + public void handle(ArgIterator it) { + String cfg = getCfg(it.get()); + if (nextNotKey(it)) { + String sb = (String) it.get(); + if (sb.endsWith(Util.sep)) { + sb = sb.substring(0, sb.length() - 1); + } + BuildConfig.putField(cfg, "SourceBase", sb); + it.next(); + } else { + empty("-sourceBase", null); + } + } + } + ), + + new HsArgRule("-buildBase", + "BuildBase", + " (Did you set the HotSpotBuildSpace environment variable?)", + HsArgHandler.STRING + ), + + new HsArgRule("-buildSpace", + "BuildSpace", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-makeBinary", + "MakeBinary", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-makeOutput", + "MakeOutput", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-platformName", + "PlatformName", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-projectFileName", + "ProjectFileName", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-jdkTargetRoot", + "JdkTargetRoot", + " (Did you set the HotSpotJDKDist environment variable?)", + HsArgHandler.STRING + ), + + new HsArgRule("-compiler", + "CompilerVersion", + " (Did you set the VcVersion correctly?)", + HsArgHandler.STRING + ), + + new HsArgRule("-absoluteInclude", + "AbsoluteInclude", + null, + HsArgHandler.VECTOR + ), + + new HsArgRule("-altRelativeInclude", + "AltRelativeInclude", + null, + HsArgHandler.VECTOR + ), + + new HsArgRule("-relativeInclude", + "RelativeInclude", + null, + HsArgHandler.VECTOR + ), + + new HsArgRule("-absoluteSrcInclude", + "AbsoluteSrcInclude", + null, + HsArgHandler.VECTOR + ), + + new HsArgRule("-relativeAltSrcInclude", + "RelativeAltSrcInclude", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-relativeSrcInclude", + "RelativeSrcInclude", + null, + HsArgHandler.VECTOR + ), + + new HsArgRule("-define", + "Define", + null, + HsArgHandler.VECTOR + ), + + new HsArgRule("-useToGeneratePch", + "UseToGeneratePch", + null, + HsArgHandler.STRING + ), + + new ArgRuleSpecific("-perFileLine", + new HsArgHandler() { + public void handle(ArgIterator it) { + String cfg = getCfg(it.get()); + if (nextNotKey(it)) { + String fileName = it.get(); + if (nextNotKey(it)) { + String line = it.get(); + BuildConfig.putFieldHash(cfg, "PerFileLine", fileName, line); + it.next(); + return; + } + } + empty(null, "** Error: wrong number of args to -perFileLine"); + } + } + ), + + new ArgRuleSpecific("-conditionalPerFileLine", + new HsArgHandler() { + public void handle(ArgIterator it) { + String cfg = getCfg(it.get()); + if (nextNotKey(it)) { + String fileName = it.get(); + if (nextNotKey(it)) { + String productLine = it.get(); + if (nextNotKey(it)) { + String debugLine = it.get(); + BuildConfig.putFieldHash(cfg+"_debug", "CondPerFileLine", + fileName, debugLine); + BuildConfig.putFieldHash(cfg+"_product", "CondPerFileLine", + fileName, productLine); + it.next(); + return; + } + } + } + + empty(null, "** Error: wrong number of args to -conditionalPerFileLine"); + } + } + ), + + new HsArgRule("-disablePch", + "DisablePch", + null, + HsArgHandler.HASH + ), + + new ArgRule("-startAt", + new HsArgHandler() { + public void handle(ArgIterator it) { + if (BuildConfig.getField(null, "StartAt") != null) { + empty(null, "** Error: multiple -startAt"); + } + if (nextNotKey(it)) { + BuildConfig.putField(null, "StartAt", it.get()); + it.next(); + } else { + empty("-startAt", null); + } + } + } + ), + + new HsArgRule("-ignoreFile", + "IgnoreFile", + null, + HsArgHandler.HASH + ), + + new HsArgRule("-ignorePath", + "IgnorePath", + null, + HsArgHandler.VECTOR + ), + + new HsArgRule("-hidePath", + "HidePath", + null, + HsArgHandler.VECTOR + ), + + new HsArgRule("-additionalFile", + "AdditionalFile", + null, + HsArgHandler.VECTOR + ), + + new ArgRuleSpecific("-additionalGeneratedFile", + new HsArgHandler() { + public void handle(ArgIterator it) { + String cfg = getCfg(it.get()); + if (nextNotKey(it)) { + String dir = it.get(); + if (nextNotKey(it)) { + String fileName = it.get(); + BuildConfig.putFieldHash(cfg, "AdditionalGeneratedFile", + Util.normalize(dir + Util.sep + fileName), + fileName); + it.next(); + return; + } + } + empty(null, "** Error: wrong number of args to -additionalGeneratedFile"); + } + } + ), + + new ArgRule("-prelink", + new HsArgHandler() { + public void handle(ArgIterator it) { + if (nextNotKey(it)) { + if (nextNotKey(it)) { + String description = it.get(); + if (nextNotKey(it)) { + String command = it.get(); + BuildConfig.putField(null, "PrelinkDescription", description); + BuildConfig.putField(null, "PrelinkCommand", command); + it.next(); + return; + } + } + } + + empty(null, "** Error: wrong number of args to -prelink"); + } + } + ), + + new ArgRule("-postbuild", + new HsArgHandler() { + public void handle(ArgIterator it) { + if (nextNotKey(it)) { + if (nextNotKey(it)) { + String description = it.get(); + if (nextNotKey(it)) { + String command = it.get(); + BuildConfig.putField(null, "PostbuildDescription", description); + BuildConfig.putField(null, "PostbuildCommand", command); + it.next(); + return; + } + } + } + + empty(null, "** Error: wrong number of args to -postbuild"); + } + } + ), + }, + new ArgHandler() { + public void handle(ArgIterator it) { + + throw new RuntimeException("Arg Parser: unrecognized option "+it.get()); + } + } + ); + if (BuildConfig.getField(null, "SourceBase") == null || + BuildConfig.getField(null, "BuildBase") == null || + BuildConfig.getField(null, "ProjectFileName") == null || + BuildConfig.getField(null, "CompilerVersion") == null) { + usage(); + } + + BuildConfig.putField(null, "PlatformObject", this); + } + + Vector createAllConfigs(String platform) { + Vector allConfigs = new Vector(); + + allConfigs.add(new C1DebugConfig()); + allConfigs.add(new C1FastDebugConfig()); + allConfigs.add(new C1ProductConfig()); + + allConfigs.add(new TieredDebugConfig()); + allConfigs.add(new TieredFastDebugConfig()); + allConfigs.add(new TieredProductConfig()); + + return allConfigs; + } + + PrintWriter printWriter; + + public void writeProjectFile(String projectFileName, String projectName, + Vector<BuildConfig> allConfigs) throws IOException { + throw new RuntimeException("use compiler version specific version"); + } + + int indent; + private Stack<String> tagStack = new Stack<String>(); + + private void startTagPrim(String name, String[] attrs, boolean close) { + startTagPrim(name, attrs, close, true); + } + + private void startTagPrim(String name, String[] attrs, boolean close, + boolean newline) { + doIndent(); + printWriter.print("<" + name); + indent++; + + if (attrs != null && attrs.length > 0) { + for (int i = 0; i < attrs.length; i += 2) { + printWriter.print(" " + attrs[i] + "=\"" + attrs[i + 1] + "\""); + if (i < attrs.length - 2) { + } + } + } + + if (close) { + indent--; + printWriter.print(" />"); + } else { + // TODO push tag name, and change endTag to pop and print. + tagStack.push(name); + printWriter.print(">"); + } + if (newline) { + printWriter.println(); + } + } + + void startTag(String name, String... attrs) { + startTagPrim(name, attrs, false); + } + + void startTagV(String name, Vector attrs) { + String s[] = new String[attrs.size()]; + for (int i = 0; i < attrs.size(); i++) { + s[i] = (String) attrs.elementAt(i); + } + startTagPrim(name, s, false); + } + + void endTag() { + String name = tagStack.pop(); + indent--; + doIndent(); + printWriter.println("</" + name + ">"); + } + + private void endTagNoIndent() { + String name = tagStack.pop(); + indent--; + printWriter.println("</" + name + ">"); + } + + void tag(String name, String... attrs) { + startTagPrim(name, attrs, true); + } + + void tagData(String name, String data) { + startTagPrim(name, null, false, false); + printWriter.print(data); + endTagNoIndent(); + } + + void tagData(String name, String data, String... attrs) { + startTagPrim(name, attrs, false, false); + printWriter.print(data); + endTagNoIndent(); + } + + void tagV(String name, Vector attrs) { + String s[] = new String[attrs.size()]; + for (int i = 0; i < attrs.size(); i++) { + s[i] = (String) attrs.elementAt(i); + } + startTagPrim(name, s, true); + } + + void doIndent() { + for (int i = 0; i < indent; i++) { + printWriter.print(" "); + } + } + + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java Mon May 09 13:22:39 2016 +0200 @@ -0,0 +1,471 @@ +/* + * Copyright (c) 2011, 2016, 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. + * + */ + +package build.tools.projectcreator; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.file.FileSystems; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.UUID; +import java.util.Vector; + +public class WinGammaPlatformVC10 extends WinGammaPlatform { + + + LinkedList <String>filters = new LinkedList<String>(); + LinkedList <String[]>filterDeps = new LinkedList<String[]>(); + + @Override + protected String getProjectExt() { + return ".vcxproj"; + } + + @Override + public void writeProjectFile(String projectFileName, String projectName, + Vector<BuildConfig> allConfigs) throws IOException { + System.out.println(); + System.out.println(" Writing .vcxproj file: " + projectFileName); + + String projDir = Util.normalize(new File(projectFileName).getParent()); + + printWriter = new PrintWriter(projectFileName, "UTF-8"); + printWriter.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); + startTag("Project", + "DefaultTargets", "Build", + "ToolsVersion", "4.0", + "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); + startTag("ItemGroup", + "Label", "ProjectConfigurations"); + for (BuildConfig cfg : allConfigs) { + startTag("ProjectConfiguration", + "Include", cfg.get("Name")); + tagData("Configuration", cfg.get("Id")); + tagData("Platform", cfg.get("PlatformName")); + endTag(); + } + endTag(); + + startTag("PropertyGroup", "Label", "Globals"); + tagData("ProjectGuid", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}"); + tagData("Keyword", "MakeFileProj"); + tag("SccProjectName"); + tag("SccLocalPath"); + endTag(); + + tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); + + for (BuildConfig cfg : allConfigs) { + startTag(cfg, "PropertyGroup", "Label", "Configuration"); + tagData("ConfigurationType", "Makefile"); + tagData("UseDebugLibraries", "true"); + endTag(); + } + + tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); + startTag("ImportGroup", "Label", "ExtensionSettings"); + endTag(); + for (BuildConfig cfg : allConfigs) { + startTag(cfg, "ImportGroup", "Label", "PropertySheets"); + tag("Import", + "Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props", + "Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')", + "Label", "LocalAppDataPlatform"); + endTag(); + } + + tag("PropertyGroup", "Label", "UserMacros"); + + startTag("PropertyGroup"); + tagData("_ProjectFileVersion", "10.0.30319.1"); + for (BuildConfig cfg : allConfigs) { + tagData(cfg, "OutDir", cfg.get("OutputDir") + Util.sep); + tagData(cfg, "IntDir", cfg.get("OutputDir") + Util.sep); + tagData(cfg, "LinkIncremental", "false"); + } + for (BuildConfig cfg : allConfigs) { + tagData(cfg, "CodeAnalysisRuleSet", "AllRules.ruleset"); + tag(cfg, "CodeAnalysisRules"); + tag(cfg, "CodeAnalysisRuleAssemblies"); + } + for (BuildConfig cfg : allConfigs) { + tagData(cfg, "NMakeBuildCommandLine", cfg.get("MakeBinary") + " -f ../../Makefile import-hotspot LOG=info"); + tagData(cfg, "NMakeReBuildCommandLine", cfg.get("MakeBinary") + " -f ../../Makefile clean-hotspot import-hotspot LOG=info"); + tagData(cfg, "NMakeCleanCommandLine", cfg.get("MakeBinary") + " -f ../../Makefile clean-hotspot LOG=info"); + tagData(cfg, "NMakeOutput", cfg.get("MakeOutput") + Util.sep + "jvm.dll"); + tagData(cfg, "NMakePreprocessorDefinitions", Util.join(";", cfg.getDefines())); + tagData(cfg, "NMakeIncludeSearchPath", Util.join(";", cfg.getIncludes())); + } + endTag(); + + for (BuildConfig cfg : allConfigs) { + startTag(cfg, "ItemDefinitionGroup"); + startTag("ClCompile"); + tagV(cfg.getV("CompilerFlags")); + endTag(); + + startTag("Link"); + tagV(cfg.getV("LinkerFlags")); + endTag(); + + endTag(); + } + + writeFiles(allConfigs, projDir); + + tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); + startTag("ImportGroup", "Label", "ExtensionTargets"); + endTag(); + + endTag(); + printWriter.close(); + System.out.println(" Done writing .vcxproj file."); + + writeFilterFile(projectFileName, projectName, allConfigs, projDir); + writeUserFile(projectFileName, allConfigs); + } + + + private void writeUserFile(String projectFileName, Vector<BuildConfig> allConfigs) throws FileNotFoundException, UnsupportedEncodingException { + String userFileName = projectFileName + ".user"; + if (new File(userFileName).exists()) { + return; + } + System.out.print(" Writing .vcxproj.user file: " + userFileName); + printWriter = new PrintWriter(userFileName, "UTF-8"); + + printWriter.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); + startTag("Project", + "ToolsVersion", "4.0", + "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); + + for (BuildConfig cfg : allConfigs) { + startTag(cfg, "PropertyGroup"); + tagData("LocalDebuggerCommand", cfg.get("JdkTargetRoot") + "\\bin\\java.exe"); + // Since we run "make hotspot-import", we get the correct jvm.dll by java.exe. + // The '-XX:+PauseAtExit' option + // causes the VM to wait for key press before exiting; this + // allows any stdout or stderr messages to be seen before + // the cmdtool exits. + tagData("LocalDebuggerCommandArguments", + "-XX:+UnlockDiagnosticVMOptions -XX:+PauseAtExit"); + tagData("LocalDebuggerEnvironment", "JAVA_HOME=" + cfg.get("JdkTargetRoot")); + endTag(); + } + + endTag(); + printWriter.close(); + System.out.println(" Done."); + } + + public void addFilter(String rPath) { + filters.add(rPath); + } + + public void addFilterDependency(String fileLoc, String filter) { + filterDeps.add(new String[] {fileLoc, filter}); + } + + private void writeFilterFile(String projectFileName, String projectName, + Vector<BuildConfig> allConfigs, String base) throws FileNotFoundException, UnsupportedEncodingException { + String filterFileName = projectFileName + ".filters"; + System.out.print(" Writing .vcxproj.filters file: " + filterFileName); + printWriter = new PrintWriter(filterFileName, "UTF-8"); + + printWriter.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); + startTag("Project", + "ToolsVersion", "4.0", + "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); + + startTag("ItemGroup"); + for (String filter : filters) { + startTag("Filter", "Include",filter); + UUID uuid = UUID.randomUUID(); + tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); + endTag(); + } + endTag(); + + //TODO - do I need to split cpp and hpp files? + + // then all files + startTag("ItemGroup"); + for (String[] dep : filterDeps) { + String tagName = getFileTagFromSuffix(dep[0]); + + startTag(tagName, "Include", dep[0]); + tagData("Filter", dep[1]); + endTag(); + } + endTag(); + + endTag(); + printWriter.close(); + System.out.println(" Done."); + } + + public String getFileTagFromSuffix(String fileName) { + if (fileName.endsWith(".cpp")) { + return"ClCompile"; + } else if (fileName.endsWith(".c")) { + return "ClCompile"; + } else if (fileName.endsWith(".hpp")) { + return"ClInclude"; + } else if (fileName.endsWith(".h")) { + return "ClInclude"; + } else { + return"None"; + } + } + + void writeFiles(Vector<BuildConfig> allConfigs, String projDir) { + // This code assummes there are no config specific includes. + startTag("ItemGroup"); + + String sourceBase = BuildConfig.getFieldString(null, "SourceBase"); + + // Use first config for all global absolute includes. + BuildConfig baseConfig = allConfigs.firstElement(); + Vector<String> rv = new Vector<String>(); + + // Then use first config for all relative includes + Vector<String> ri = new Vector<String>(); + baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude"); + for (String f : ri) { + rv.add(sourceBase + Util.sep + f); + } + + baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude"); + + handleIncludes(rv, allConfigs); + + endTag(); + } + + // Will visit file tree for each include + private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) { + for (String path : includes) { + FileTreeCreatorVC10 ftc = new FileTreeCreatorVC10(FileSystems.getDefault().getPath(path) , allConfigs, this); + try { + ftc.writeFileTree(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + String buildCond(BuildConfig cfg) { + return "'$(Configuration)|$(Platform)'=='"+cfg.get("Name")+"'"; + } + + void tagV(Vector<String> v) { + Iterator<String> i = v.iterator(); + while(i.hasNext()) { + String name = i.next(); + String data = i.next(); + tagData(name, data); + } + } + + void tagData(BuildConfig cfg, String name, String data) { + tagData(name, data, "Condition", buildCond(cfg)); + } + + void tag(BuildConfig cfg, String name, String... attrs) { + String[] ss = new String[attrs.length + 2]; + ss[0] = "Condition"; + ss[1] = buildCond(cfg); + System.arraycopy(attrs, 0, ss, 2, attrs.length); + + tag(name, ss); + } + + void startTag(BuildConfig cfg, String name, String... attrs) { + String[] ss = new String[attrs.length + 2]; + ss[0] = "Condition"; + ss[1] = buildCond(cfg); + System.arraycopy(attrs, 0, ss, 2, attrs.length); + + startTag(name, ss); + } + +} + +class CompilerInterfaceVC10 extends CompilerInterface { + + @Override + Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) { + Vector rv = new Vector(); + + addAttr(rv, "AdditionalIncludeDirectories", Util.join(";", includes)); + addAttr(rv, "PreprocessorDefinitions", + Util.join(";", defines).replace("\\\"", "\"")); + addAttr(rv, "PrecompiledHeaderFile", "precompiled.hpp"); + addAttr(rv, "PrecompiledHeaderOutputFile", outDir+Util.sep+"vm.pch"); + addAttr(rv, "AssemblerListingLocation", outDir); + addAttr(rv, "ObjectFileName", outDir+Util.sep); + addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb"); + // Set /nologo option + addAttr(rv, "SuppressStartupBanner", "true"); + // Surpass the default /Tc or /Tp. + addAttr(rv, "CompileAs", "Default"); + // Set /W3 option. + addAttr(rv, "WarningLevel", "Level3"); + // Set /WX option, + addAttr(rv, "TreatWarningAsError", "true"); + // Set /GS option + addAttr(rv, "BufferSecurityCheck", "false"); + // Set /Zi option. + addAttr(rv, "DebugInformationFormat", "ProgramDatabase"); + // Set /Yu option. + addAttr(rv, "PrecompiledHeader", "Use"); + // Set /EHsc- option + addAttr(rv, "ExceptionHandling", ""); + + addAttr(rv, "MultiProcessorCompilation", "true"); + + return rv; + } + + @Override + Vector getDebugCompilerFlags(String opt, String platformName) { + Vector rv = new Vector(); + + // Set /On option + addAttr(rv, "Optimization", opt); + // Set /MD option. + addAttr(rv, "RuntimeLibrary", "MultiThreadedDLL"); + // Set /Oy- option + addAttr(rv, "OmitFramePointers", "false"); + // Set /homeparams for x64 debug builds + if(platformName.equals("x64")) { + addAttr(rv, "AdditionalOptions", "/homeparams"); + } + + return rv; + } + + @Override + Vector getProductCompilerFlags() { + Vector rv = new Vector(); + + // Set /O2 option. + addAttr(rv, "Optimization", "MaxSpeed"); + // Set /Oy- option + addAttr(rv, "OmitFramePointers", "false"); + // Set /Ob option. 1 is expandOnlyInline + addAttr(rv, "InlineFunctionExpansion", "OnlyExplicitInline"); + // Set /GF option. + addAttr(rv, "StringPooling", "true"); + // Set /MD option. 2 is rtMultiThreadedDLL + addAttr(rv, "RuntimeLibrary", "MultiThreadedDLL"); + // Set /Gy option + addAttr(rv, "FunctionLevelLinking", "true"); + + return rv; + } + + @Override + Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) { + Vector rv = new Vector(); + + if(platformName.equals("Win32")) { + addAttr(rv, "AdditionalOptions", + "/export:JNI_GetDefaultJavaVMInitArgs " + + "/export:JNI_CreateJavaVM " + + "/export:JVM_FindClassFromBootLoader "+ + "/export:JNI_GetCreatedJavaVMs "+ + "/export:jio_snprintf /export:jio_printf "+ + "/export:jio_fprintf /export:jio_vfprintf "+ + "/export:jio_vsnprintf "+ + "/export:JVM_GetVersionInfo "+ + "/export:JVM_InitAgentProperties"); + } + addAttr(rv, "AdditionalDependencies", "kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;Wsock32.lib;winmm.lib;psapi.lib;version.lib"); + addAttr(rv, "OutputFile", outDll); + addAttr(rv, "SuppressStartupBanner", "true"); + addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def"); + addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb"); + addAttr(rv, "SubSystem", "Windows"); + addAttr(rv, "BaseAddress", "0x8000000"); + addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib"); + + if(platformName.equals("Win32")) { + addAttr(rv, "TargetMachine", "MachineX86"); + } else { + addAttr(rv, "TargetMachine", "MachineX64"); + } + + // We always want the /DEBUG option to get full symbol information in the pdb files + addAttr(rv, "GenerateDebugInformation", "true"); + + return rv; + } + + @Override + Vector getDebugLinkerFlags() { + Vector rv = new Vector(); + + // Empty now that /DEBUG option is used by all configs + + return rv; + } + + @Override + Vector getProductLinkerFlags() { + Vector rv = new Vector(); + + // Set /OPT:REF option. + addAttr(rv, "OptimizeReferences", "true"); + // Set /OPT:ICF option. + addAttr(rv, "EnableCOMDATFolding", "true"); + + return rv; + } + + @Override + void getAdditionalNonKernelLinkerFlags(Vector rv) { + extAttr(rv, "AdditionalOptions", " /export:AsyncGetCallTrace"); + } + + @Override + String getOptFlag() { + return "MaxSpeed"; + } + + @Override + String getNoOptFlag() { + return "Disabled"; + } + + @Override + String makeCfgName(String flavourBuild, String platform) { + return flavourBuild + "|" + platform; + } + +}
--- a/hotspot/src/share/tools/ProjectCreator/ArgsParser.java Thu Aug 06 22:07:30 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2005, 2010, 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. - * - */ - -class ArgIterator { - String[] args; - int i; - ArgIterator(String[] args) { - this.args = args; - this.i = 0; - } - String get() { return args[i]; } - boolean hasMore() { return args != null && i < args.length; } - boolean next() { return ++i < args.length; } -} - -abstract class ArgHandler { - public abstract void handle(ArgIterator it); - -} - -class ArgRule { - String arg; - ArgHandler handler; - ArgRule(String arg, ArgHandler handler) { - this.arg = arg; - this.handler = handler; - } - - boolean process(ArgIterator it) { - if (match(it.get(), arg)) { - handler.handle(it); - return true; - } - return false; - } - boolean match(String rule_pattern, String arg) { - return arg.equals(rule_pattern); - } -} - -class ArgsParser { - ArgsParser(String[] args, - ArgRule[] rules, - ArgHandler defaulter) { - ArgIterator ai = new ArgIterator(args); - while (ai.hasMore()) { - boolean processed = false; - for (int i=0; i<rules.length; i++) { - processed |= rules[i].process(ai); - if (processed) { - break; - } - } - if (!processed) { - if (defaulter != null) { - defaulter.handle(ai); - } else { - System.err.println("ERROR: unparsed \""+ai.get()+"\""); - ai.next(); - } - } - } - } -}
--- a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java Thu Aug 06 22:07:30 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,617 +0,0 @@ -/* - * Copyright (c) 2005, 2015, 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.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; - -class BuildConfig { - @SuppressWarnings("rawtypes") - Hashtable vars; - Vector<String> basicNames, basicPaths; - String[] context; - - static CompilerInterface ci; - static CompilerInterface getCI() { - if (ci == null) { - String comp = (String)getField(null, "CompilerVersion"); - try { - ci = (CompilerInterface)Class.forName("CompilerInterface" + comp).newInstance(); - } catch (Exception cnfe) { - System.err.println("Cannot find support for compiler " + comp); - throw new RuntimeException(cnfe.toString()); - } - } - return ci; - } - - @SuppressWarnings("rawtypes") - protected void initNames(String flavour, String build, String outDll) { - if (vars == null) vars = new Hashtable(); - - String flavourBuild = flavour + "_" + build; - String platformName = getFieldString(null, "PlatformName"); - System.out.println(); - System.out.println(flavourBuild); - - put("Name", getCI().makeCfgName(flavourBuild, platformName)); - put("Flavour", flavour); - put("Build", build); - put("PlatformName", platformName); - - // ones mentioned above were needed to expand format - String buildBase = expandFormat(getFieldString(null, "BuildBase")); - String sourceBase = getFieldString(null, "SourceBase"); - String buildSpace = getFieldString(null, "BuildSpace"); - String outDir = buildBase; - String jdkTargetRoot = getFieldString(null, "JdkTargetRoot"); - - put("Id", flavourBuild); - put("OutputDir", outDir); - put("SourceBase", sourceBase); - put("BuildBase", buildBase); - put("BuildSpace", buildSpace); - put("OutputDll", outDir + Util.sep + outDll); - put("JdkTargetRoot", jdkTargetRoot); - - context = new String [] {flavourBuild, flavour, build, null}; - } - - protected void init(Vector<String> includes, Vector<String> defines) { - initDefaultDefines(defines); - initDefaultCompilerFlags(includes); - initDefaultLinkerFlags(); - //handleDB(); - } - - - protected void initDefaultCompilerFlags(Vector<String> includes) { - Vector compilerFlags = new Vector(); - - compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"), - includes, - get("OutputDir"))); - - put("CompilerFlags", compilerFlags); - } - - protected void initDefaultLinkerFlags() { - Vector linkerFlags = new Vector(); - - linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll"), get("PlatformName"))); - - put("LinkerFlags", linkerFlags); - } - - public boolean matchesIgnoredPath(String path) { - Vector<String> rv = new Vector<String>(); - collectRelevantVectors(rv, "IgnorePath"); - for (String pathPart : rv) { - if (path.contains(pathPart)) { - return true; - } - } - return false; - } - - public boolean matchesHidePath(String path) { - Vector<String> rv = new Vector<String>(); - collectRelevantVectors(rv, "HidePath"); - for (String pathPart : rv) { - if (path.contains(Util.normalize(pathPart))) { - return true; - } - } - return false; - } - - public Vector<String> matchesAdditionalGeneratedPath(String fullPath) { - Vector<String> rv = new Vector<String>(); - Hashtable<String, String> v = (Hashtable<String, String>)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile"); - if (v != null) { - for (Enumeration<String> e=v.keys(); e.hasMoreElements(); ) { - String key = e.nextElement(); - String val = v.get(key); - - if (fullPath.endsWith(expandFormat(key))) { - rv.add(expandFormat(val)); - } - } - } - 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)); - } - - void initDefaultDefines(Vector defines) { - Vector sysDefines = new Vector(); - sysDefines.add("WIN32"); - sysDefines.add("_WINDOWS"); - sysDefines.add("HOTSPOT_BUILD_USER=\\\""+System.getProperty("user.name")+"\\\""); - sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\""); - sysDefines.add("INCLUDE_TRACE=1"); - sysDefines.add("_JNI_IMPLEMENTATION_"); - if (vars.get("PlatformName").equals("Win32")) { - sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\""); - } else { - sysDefines.add("HOTSPOT_LIB_ARCH=\\\"amd64\\\""); - } - sysDefines.add("DEBUG_LEVEL=\\\"" + get("Build")+"\\\""); - sysDefines.addAll(defines); - - put("Define", sysDefines); - } - - String get(String key) { - return (String)vars.get(key); - } - - Vector getV(String key) { - return (Vector)vars.get(key); - } - - Object getO(String key) { - return vars.get(key); - } - - Hashtable getH(String key) { - return (Hashtable)vars.get(key); - } - - Object getFieldInContext(String field) { - for (int i=0; i<context.length; i++) { - Object rv = getField(context[i], field); - if (rv != null) { - return rv; - } - } - return null; - } - - Object lookupHashFieldInContext(String field, String key) { - for (int i=0; i<context.length; i++) { - Hashtable ht = (Hashtable)getField(context[i], field); - if (ht != null) { - Object rv = ht.get(key); - if (rv != null) { - return rv; - } - } - } - return null; - } - - void put(String key, String value) { - vars.put(key, value); - } - - void put(String key, Vector vvalue) { - vars.put(key, vvalue); - } - - void add(String key, Vector vvalue) { - getV(key).addAll(vvalue); - } - - String flavour() { - return get("Flavour"); - } - - String build() { - return get("Build"); - } - - Object getSpecificField(String field) { - return getField(get("Id"), field); - } - - void putSpecificField(String field, Object value) { - putField(get("Id"), field, value); - } - - void collectRelevantVectors(Vector rv, String field) { - for (String ctx : context) { - Vector<String> v = getFieldVector(ctx, field); - if (v != null) { - for (String val : v) { - rv.add(expandFormat(val).replace('/', '\\')); - } - } - } - } - - void collectRelevantHashes(Hashtable rv, String field) { - for (String ctx : context) { - Hashtable v = (Hashtable)getField(ctx, field); - if (v != null) { - for (Enumeration e=v.keys(); e.hasMoreElements(); ) { - String key = (String)e.nextElement(); - String val = (String)v.get(key); - addTo(rv, key, val); - } - } - } - } - - - Vector getDefines() { - Vector rv = new Vector(); - collectRelevantVectors(rv, "Define"); - return rv; - } - - Vector getIncludes() { - Vector rv = new Vector(); - collectRelevantVectors(rv, "AbsoluteInclude"); - rv.addAll(getSourceIncludes()); - return rv; - } - - private Vector getSourceIncludes() { - Vector<String> rv = 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); - } - return rv; - } - - static Hashtable cfgData = new Hashtable(); - static Hashtable globalData = new Hashtable(); - - static boolean appliesToTieredBuild(String cfg) { - return (cfg != null && - (cfg.startsWith("compiler1") || - cfg.startsWith("compiler2"))); - } - - // Filters out the IgnoreFile and IgnorePaths since they are - // handled specially for tiered builds. - static boolean appliesToTieredBuild(String cfg, String key) { - return (appliesToTieredBuild(cfg))&& (key != null && !key.startsWith("Ignore")); - } - - static String getTieredBuildCfg(String cfg) { - assert appliesToTieredBuild(cfg) : "illegal configuration " + cfg; - return "tiered" + cfg.substring(9); - } - - static Object getField(String cfg, String field) { - if (cfg == null) { - return globalData.get(field); - } - - Hashtable ht = (Hashtable)cfgData.get(cfg); - return ht == null ? null : ht.get(field); - } - - static String getFieldString(String cfg, String field) { - return (String)getField(cfg, field); - } - - static Vector getFieldVector(String cfg, String field) { - return (Vector)getField(cfg, field); - } - - static void putField(String cfg, String field, Object value) { - putFieldImpl(cfg, field, value); - if (appliesToTieredBuild(cfg, field)) { - putFieldImpl(getTieredBuildCfg(cfg), field, value); - } - } - - private static void putFieldImpl(String cfg, String field, Object value) { - if (cfg == null) { - globalData.put(field, value); - return; - } - - Hashtable ht = (Hashtable)cfgData.get(cfg); - if (ht == null) { - ht = new Hashtable(); - cfgData.put(cfg, ht); - } - - ht.put(field, value); - } - - static Object getFieldHash(String cfg, String field, String name) { - Hashtable ht = (Hashtable)getField(cfg, field); - - return ht == null ? null : ht.get(name); - } - - static void putFieldHash(String cfg, String field, String name, Object val) { - putFieldHashImpl(cfg, field, name, val); - if (appliesToTieredBuild(cfg, field)) { - putFieldHashImpl(getTieredBuildCfg(cfg), field, name, val); - } - } - - private static void putFieldHashImpl(String cfg, String field, String name, Object val) { - Hashtable ht = (Hashtable)getField(cfg, field); - - if (ht == null) { - ht = new Hashtable(); - putFieldImpl(cfg, field, ht); - } - - ht.put(name, val); - } - - static void addFieldVector(String cfg, String field, String element) { - addFieldVectorImpl(cfg, field, element); - if (appliesToTieredBuild(cfg, field)) { - addFieldVectorImpl(getTieredBuildCfg(cfg), field, element); - } - } - - private static void addFieldVectorImpl(String cfg, String field, String element) { - Vector v = (Vector)getField(cfg, field); - - if (v == null) { - v = new Vector(); - putFieldImpl(cfg, field, v); - } - - v.add(element); - } - - String expandFormat(String format) { - if (format == null) { - return null; - } - - if (format.indexOf('%') == -1) { - return format; - } - - StringBuffer sb = new StringBuffer(); - int len = format.length(); - for (int i=0; i<len; i++) { - char ch = format.charAt(i); - if (ch == '%') { - char ch1 = format.charAt(i+1); - switch (ch1) { - case '%': - sb.append(ch1); - break; - case 'b': - sb.append(build()); - break; - case 'f': - sb.append(flavour()); - break; - default: - sb.append(ch); - sb.append(ch1); - } - i++; - } else { - sb.append(ch); - } - } - - return sb.toString(); - } -} - -abstract class GenericDebugConfig extends BuildConfig { - abstract String getOptFlag(); - - protected void init(Vector includes, Vector defines) { - defines.add("_DEBUG"); - defines.add("ASSERT"); - - super.init(includes, defines); - - getV("CompilerFlags").addAll(getCI().getDebugCompilerFlags(getOptFlag(), get("PlatformName"))); - getV("LinkerFlags").addAll(getCI().getDebugLinkerFlags()); - } -} - -abstract class GenericDebugNonKernelConfig extends GenericDebugConfig { - protected void init(Vector includes, Vector defines) { - super.init(includes, defines); - if (get("PlatformName").equals("Win32")) { - getCI().getAdditionalNonKernelLinkerFlags(getV("LinkerFlags")); - } - } -} - -class C1DebugConfig extends GenericDebugNonKernelConfig { - String getOptFlag() { - return getCI().getNoOptFlag(); - } - - C1DebugConfig() { - initNames("compiler1", "debug", "jvm.dll"); - init(getIncludes(), getDefines()); - } -} - -class C1FastDebugConfig extends GenericDebugNonKernelConfig { - String getOptFlag() { - return getCI().getOptFlag(); - } - - C1FastDebugConfig() { - initNames("compiler1", "fastdebug", "jvm.dll"); - init(getIncludes(), getDefines()); - } -} - -class TieredDebugConfig extends GenericDebugNonKernelConfig { - String getOptFlag() { - return getCI().getNoOptFlag(); - } - - TieredDebugConfig() { - initNames("tiered", "debug", "jvm.dll"); - init(getIncludes(), getDefines()); - } -} - -class TieredFastDebugConfig extends GenericDebugNonKernelConfig { - String getOptFlag() { - return getCI().getOptFlag(); - } - - TieredFastDebugConfig() { - initNames("tiered", "fastdebug", "jvm.dll"); - init(getIncludes(), getDefines()); - } -} - -abstract class ProductConfig extends BuildConfig { - protected void init(Vector includes, Vector defines) { - defines.add("NDEBUG"); - defines.add("PRODUCT"); - - super.init(includes, defines); - - getV("CompilerFlags").addAll(getCI().getProductCompilerFlags()); - getV("LinkerFlags").addAll(getCI().getProductLinkerFlags()); - } -} - -class C1ProductConfig extends ProductConfig { - C1ProductConfig() { - initNames("compiler1", "product", "jvm.dll"); - init(getIncludes(), getDefines()); - } -} - -class TieredProductConfig extends ProductConfig { - TieredProductConfig() { - initNames("tiered", "product", "jvm.dll"); - init(getIncludes(), getDefines()); - } -} - - -abstract class CompilerInterface { - abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir); - abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName); - abstract Vector getDebugCompilerFlags(String opt, String platformName); - abstract Vector getDebugLinkerFlags(); - abstract void getAdditionalNonKernelLinkerFlags(Vector rv); - abstract Vector getProductCompilerFlags(); - abstract Vector getProductLinkerFlags(); - abstract String getOptFlag(); - abstract String getNoOptFlag(); - abstract String makeCfgName(String flavourBuild, String platformName); - - void addAttr(Vector receiver, String attr, String value) { - receiver.add(attr); receiver.add(value); - } - void extAttr(Vector receiver, String attr, String value) { - int attr_pos=receiver.indexOf(attr) ; - if ( attr_pos == -1) { - // If attr IS NOT present in the Vector - add it - receiver.add(attr); receiver.add(value); - } else { - // If attr IS present in the Vector - append value to it - receiver.set(attr_pos+1,receiver.get(attr_pos+1)+value); - } - } -}
--- a/hotspot/src/share/tools/ProjectCreator/FileTreeCreator.java Thu Aug 06 22:07:30 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -import java.nio.file.FileSystems; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.util.HashSet; -import java.util.Stack; -import java.util.Vector; - -public class FileTreeCreator extends SimpleFileVisitor<Path> -{ - Path vcProjLocation; - Path startDir; - final int startDirLength; - Stack<DirAttributes> attributes = new Stack<DirAttributes>(); - Vector<BuildConfig> allConfigs; - WinGammaPlatform wg; - WinGammaPlatformVC10 wg10; - - public FileTreeCreator(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) { - super(); - this.wg = wg; - if (wg instanceof WinGammaPlatformVC10) { - wg10 = (WinGammaPlatformVC10)wg; - } - this.allConfigs = allConfigs; - this.startDir = startDir; - startDirLength = startDir.toAbsolutePath().toString().length(); - vcProjLocation = FileSystems.getDefault().getPath(allConfigs.firstElement().get("BuildSpace")); - attributes.push(new DirAttributes()); - } - - public class DirAttributes { - - private HashSet<BuildConfig> ignores; - private HashSet<BuildConfig> disablePch; - - public DirAttributes() { - ignores = new HashSet<BuildConfig>(); - disablePch = new HashSet<BuildConfig>(); - } - - public DirAttributes(HashSet<BuildConfig> excludes2, HashSet<BuildConfig> disablePch2) { - ignores = excludes2; - disablePch = disablePch2; - } - - @SuppressWarnings("unchecked") - public DirAttributes clone() { - return new DirAttributes((HashSet<BuildConfig>)this.ignores.clone(), (HashSet<BuildConfig>)this.disablePch.clone()); - } - - public void setIgnore(BuildConfig conf) { - ignores.add(conf); - } - - public boolean hasIgnore(BuildConfig cfg) { - return ignores.contains(cfg); - } - - public void removeFromIgnored(BuildConfig cfg) { - ignores.remove(cfg); - } - - public void setDisablePch(BuildConfig conf) { - disablePch.add(conf); - } - - public boolean hasDisablePch(BuildConfig cfg) { - return disablePch.contains(cfg); - } - - public void removeFromDisablePch(BuildConfig cfg) { - disablePch.remove(cfg); - } - - } -}
--- a/hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java Thu Aug 06 22:07:30 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,190 +0,0 @@ -/* - * 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; -import java.nio.file.FileSystems; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.Stack; -import java.util.Vector; - -public class FileTreeCreatorVC10 extends FileTreeCreator { - - public FileTreeCreatorVC10(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) { - super(startDir, allConfigs, wg); - } - - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attr) { - DirAttributes currentFileAttr = attributes.peek().clone(); - 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 - - // usePch applies to all configs for a file. - if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) { - 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; - currentFileAttr.setIgnore(cfg); - } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) { - useIgnore = true; - currentFileAttr.setIgnore(cfg); - } - - if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) { - disablePch = true; - currentFileAttr.setDisablePch(cfg); - } - - Vector<String> rv = new Vector<String>(); - cfg.collectRelevantVectors(rv, "AdditionalFile"); - for(String addFile : rv) { - if (addFile.equals(fileName)) { - // supress any ignore - // TODO - may need some adjustments - if (file.toAbsolutePath().toString().contains(cfg.get("Flavour"))) { - currentFileAttr.removeFromIgnored(cfg); - } - } - } - } - - String tagName = wg10.getFileTagFromSuffix(fileName); - - if (!useIgnore && !disablePch && !usePch && !isReplacedByAltSrc) { - wg.tag(tagName, new String[] { "Include", fileLoc}); - } else { - wg.startTag( - tagName, - new String[] { "Include", fileLoc}); - - for (BuildConfig cfg : allConfigs) { - boolean ignore = currentFileAttr.hasIgnore(cfg); - if (ignore) { - wg.tagData("ExcludedFromBuild", "true", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); - } - if (usePch) { - wg.tagData("PrecompiledHeader", "Create", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); - } - 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(); - } - - String filter = startDir.relativize(file.getParent().toAbsolutePath()).toString(); - wg10.addFilterDependency(fileLoc, filter); - - return CONTINUE; - } - - @Override - public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) - throws IOException { - Boolean hide = false; - // TODO remove attrs, if path is matched in this dir, then it is too in every subdir. - // And we will check anyway - DirAttributes newAttr = attributes.peek().clone(); - - // check per config ignorePaths! - for (BuildConfig cfg : allConfigs) { - if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { - newAttr.setIgnore(cfg); - } - - // Hide is always on all configs. And additional files are never hiddden - if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { - hide = true; - break; - } - } - - if (!hide) { - String name = startDir.relativize(path.toAbsolutePath()).toString(); - if (!"".equals(name)) { - wg10.addFilter(name); - } - - attributes.push(newAttr); - return super.preVisitDirectory(path, attrs); - } else { - return FileVisitResult.SKIP_SUBTREE; - } - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) { - //end matching attributes set by ignorepath - attributes.pop(); - return CONTINUE; - } - - @Override - public FileVisitResult visitFileFailed(Path file, IOException exc) { - return CONTINUE; - } - - public void writeFileTree() throws IOException { - Files.walkFileTree(this.startDir, this); - } -}
--- a/hotspot/src/share/tools/ProjectCreator/ProjectCreator.java Thu Aug 06 22:07:30 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/* - * 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 - * 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. - * - */ - -public class ProjectCreator { - - public static void usage() { - System.out.println("ProjectCreator options:"); - System.err.println("WinGammaPlatform platform-specific options:"); - System.err.println(" -sourceBase <path to directory (workspace) " - + "containing source files; no trailing slash>"); - System.err.println(" -dspFileName <full pathname to which .dsp file " - + "will be written; all parent directories must " - + "already exist>"); - System.err.println(" -envVar <environment variable to be inserted " - + "into .dsp file, substituting for path given in " - + "-sourceBase. Example: HotSpotWorkSpace>"); - System.err.println(" -dllLoc <path to directory in which to put " - + "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 " - + "(note: doesn't yet support " + "#define (flag) (value))>"); - System.err.println(" -perFileLine <file> <line>"); - System.err.println(" -conditionalPerFileLine <file> <line for " - + "release build> <line for debug build>"); - System.err.println(" (NOTE: To work around a bug in nmake, where " - + "you can't have a '#' character in a quoted " - + "string, all of the lines outputted have \"#\"" + "prepended)"); - System.err.println(" -startAt <subdir of sourceBase>"); - System.err.println(" -ignoreFile <file which won't be able to be " - + "found in the sourceBase because it's generated " + "later>"); - System.err.println(" -additionalFile <file not in database but " - + "which should show up in .dsp file>"); - System.err - .println(" -additionalGeneratedFile <environment variable of " - + "generated file's location> <relative path to " - + "directory containing file; no trailing slash> " - + "<name of file generated later in the build process>"); - System.err.println(" -prelink <build> <desc> <cmds>:"); - System.err - .println(" Generate a set of prelink commands for the given BUILD"); - System.err - .println(" (\"Debug\" or \"Release\"). The prelink description and commands"); - System.err.println(" are both quoted strings."); - System.err.println(" Default includes: \".\""); - System.err - .println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\""); - } - - public static void main(String[] args) { - try { - if (args.length < 3) { - usage(); - System.exit(1); - } - - String platformName = args[0]; - Class platformClass = Class.forName(platformName); - WinGammaPlatform platform = (WinGammaPlatform) platformClass - .newInstance(); - - String[] platformArgs = new String[args.length - 1]; - System.arraycopy(args, 1, platformArgs, 0, platformArgs.length); - - // Allow the platform to write platform-specific files - platform.createVcproj(platformArgs); - } catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } - } -}
--- a/hotspot/src/share/tools/ProjectCreator/Util.java Thu Aug 06 22:07:30 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2005, 2012, 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.util.*; -import java.io.File; - -public class Util { - - static String join(String padder, Vector<String> v) { - return join(padder, v, false); - } - - static String join(String padder, Vector<String> v, boolean quoted) { - StringBuffer sb = new StringBuffer(); - - for (Iterator<String> iter = v.iterator(); iter.hasNext(); ) { - if (quoted) { - sb.append('"'); - } - sb.append(iter.next()); - if (quoted) { - sb.append('"'); - } - if (iter.hasNext()) sb.append(padder); - } - - return sb.toString(); - } - - - static String prefixed_join(String padder, Vector<String> v, boolean quoted) { - StringBuffer sb = new StringBuffer(); - - for (Iterator<String> iter = v.iterator(); iter.hasNext(); ) { - sb.append(padder); - - if (quoted) { - sb.append('"'); - } - sb.append((String)iter.next()); - if (quoted) { - sb.append('"'); - } - } - - return sb.toString(); - } - - - static String normalize(String file) { - file = file.replace('\\', '/'); - if (file.length() > 2) { - if (file.charAt(1) == ':' && file.charAt(2) == '/') { - // convert drive letter to uppercase - String drive = file.substring(0, 1).toUpperCase(); - return drive + file.substring(1); - } - } - return file; - } - - static String sep = File.separator; -}
--- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java Thu Aug 06 22:07:30 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,675 +0,0 @@ -/* - * Copyright (c) 1999, 2015, 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.IOException; -import java.io.PrintWriter; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Stack; -import java.util.Vector; - -abstract class HsArgHandler extends ArgHandler { - static final int STRING = 1; - static final int VECTOR = 2; - static final int HASH = 3; - - boolean nextNotKey(ArgIterator it) { - if (it.next()) { - String s = it.get(); - return (s.length() == 0) || (s.charAt(0) != '-'); - } else { - return false; - } - } - - void empty(String key, String message) { - if (key != null) { - System.err.println("** Error: empty " + key); - } - if (message != null) { - System.err.println(message); - } - WinGammaPlatform.usage(); - } - - static String getCfg(String val) { - int under = val.indexOf('_'); - int len = val.length(); - if (under != -1 && under < len - 1) { - return val.substring(under+1, len); - } else { - return null; - } - } -} - -class ArgRuleSpecific extends ArgRule { - ArgRuleSpecific(String arg, ArgHandler handler) { - super(arg, handler); - } - - boolean match(String rulePattern, String arg) { - return rulePattern.startsWith(arg); - } -} - - -class SpecificHsArgHandler extends HsArgHandler { - - String message, argKey, valKey; - int type; - - public void handle(ArgIterator it) { - String cfg = getCfg(it.get()); - if (nextNotKey(it)) { - String val = it.get(); - switch (type) { - case VECTOR: - BuildConfig.addFieldVector(cfg, valKey, val); - break; - case HASH: - BuildConfig.putFieldHash(cfg, valKey, val, "1"); - break; - case STRING: - BuildConfig.putField(cfg, valKey, val); - break; - default: - empty(valKey, "Unknown type: "+type); - } - it.next(); - - } else { - empty(argKey, message); - } - } - - SpecificHsArgHandler(String argKey, String valKey, String message, int type) { - this.argKey = argKey; - this.valKey = valKey; - this.message = message; - this.type = type; - } -} - - -class HsArgRule extends ArgRuleSpecific { - - HsArgRule(String argKey, String valKey, String message, int type) { - super(argKey, new SpecificHsArgHandler(argKey, valKey, message, type)); - } - -} - -public abstract class WinGammaPlatform { - - public boolean fileNameStringEquality(String s1, String s2) { - return s1.equalsIgnoreCase(s2); - } - - static void usage() throws IllegalArgumentException { - System.err.println("WinGammaPlatform platform-specific options:"); - System.err.println(" -sourceBase <path to directory (workspace) " + - "containing source files; no trailing slash>"); - System.err.println(" -projectFileName <full pathname to which project file " + - "will be written; all parent directories must " + - "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 " + - "(note: doesn't yet support " + - "#define (flag) (value))>"); - System.err.println(" -startAt <subdir of sourceBase>"); - System.err.println(" -additionalFile <file not in database but " + - "which should show up in project file>"); - System.err.println(" -additionalGeneratedFile <absolute path to " + - "directory containing file; no trailing slash> " + - "<name of file generated later in the build process>"); - throw new IllegalArgumentException(); - } - - - public void addPerFileLine(Hashtable table, - String fileName, - String line) { - Vector v = (Vector) table.get(fileName); - if (v != null) { - v.add(line); - } else { - v = new Vector(); - v.add(line); - table.put(fileName, v); - } - } - - protected static class PerFileCondData { - public String releaseString; - public String debugString; - } - - protected void addConditionalPerFileLine(Hashtable table, - String fileName, - String releaseLine, - String debugLine) { - PerFileCondData data = new PerFileCondData(); - data.releaseString = releaseLine; - data.debugString = debugLine; - Vector v = (Vector) table.get(fileName); - if (v != null) { - v.add(data); - } else { - v = new Vector(); - v.add(data); - table.put(fileName, v); - } - } - - protected static class PrelinkCommandData { - String description; - String commands; - } - - protected void addPrelinkCommand(Hashtable table, - String build, - String description, - String commands) { - PrelinkCommandData data = new PrelinkCommandData(); - data.description = description; - data.commands = commands; - table.put(build, data); - } - - public boolean findString(Vector v, String s) { - for (Iterator iter = v.iterator(); iter.hasNext(); ) { - if (((String) iter.next()).equals(s)) { - return true; - } - } - - return false; - } - - String getProjectName(String fullPath, String extension) - throws IllegalArgumentException, IOException { - File file = new File(fullPath).getCanonicalFile(); - fullPath = file.getCanonicalPath(); - String parent = file.getParent(); - - if (!fullPath.endsWith(extension)) { - throw new IllegalArgumentException("project file name \"" + - fullPath + - "\" does not end in "+extension); - } - - if ((parent != null) && - (!fullPath.startsWith(parent))) { - throw new RuntimeException( - "Internal error: parent of file name \"" + parent + - "\" does not match file name \"" + fullPath + "\"" - ); - } - - int len = parent.length(); - if (!parent.endsWith(Util.sep)) { - len += Util.sep.length(); - } - - int end = fullPath.length() - extension.length(); - - if (len == end) { - throw new RuntimeException( - "Internal error: file name was empty" - ); - } - - return fullPath.substring(len, end); - } - - protected abstract String getProjectExt(); - - public void createVcproj(String[] args) - throws IllegalArgumentException, IOException { - - parseArguments(args); - - String projectFileName = BuildConfig.getFieldString(null, "ProjectFileName"); - String ext = getProjectExt(); - - String projectName = getProjectName(projectFileName, ext); - - writeProjectFile(projectFileName, projectName, createAllConfigs(BuildConfig.getFieldString(null, "PlatformName"))); - } - - protected void writePrologue(String[] args) { - System.err.println("WinGammaPlatform platform-specific arguments:"); - for (int i = 0; i < args.length; i++) { - System.err.print(args[i] + " "); - } - System.err.println(); - } - - - void parseArguments(String[] args) { - new ArgsParser(args, - new ArgRule[] - { - new ArgRule("-sourceBase", - new HsArgHandler() { - public void handle(ArgIterator it) { - String cfg = getCfg(it.get()); - if (nextNotKey(it)) { - String sb = (String) it.get(); - if (sb.endsWith(Util.sep)) { - sb = sb.substring(0, sb.length() - 1); - } - BuildConfig.putField(cfg, "SourceBase", sb); - it.next(); - } else { - empty("-sourceBase", null); - } - } - } - ), - - new HsArgRule("-buildBase", - "BuildBase", - " (Did you set the HotSpotBuildSpace environment variable?)", - HsArgHandler.STRING - ), - - new HsArgRule("-buildSpace", - "BuildSpace", - null, - HsArgHandler.STRING - ), - - new HsArgRule("-platformName", - "PlatformName", - null, - HsArgHandler.STRING - ), - - new HsArgRule("-projectFileName", - "ProjectFileName", - null, - HsArgHandler.STRING - ), - - new HsArgRule("-jdkTargetRoot", - "JdkTargetRoot", - " (Did you set the HotSpotJDKDist environment variable?)", - HsArgHandler.STRING - ), - - new HsArgRule("-compiler", - "CompilerVersion", - " (Did you set the VcVersion correctly?)", - HsArgHandler.STRING - ), - - new HsArgRule("-absoluteInclude", - "AbsoluteInclude", - null, - HsArgHandler.VECTOR - ), - - new HsArgRule("-altRelativeInclude", - "AltRelativeInclude", - null, - HsArgHandler.VECTOR - ), - - new HsArgRule("-relativeInclude", - "RelativeInclude", - null, - HsArgHandler.VECTOR - ), - - new HsArgRule("-absoluteSrcInclude", - "AbsoluteSrcInclude", - null, - HsArgHandler.VECTOR - ), - - new HsArgRule("-relativeAltSrcInclude", - "RelativeAltSrcInclude", - null, - HsArgHandler.STRING - ), - - new HsArgRule("-relativeSrcInclude", - "RelativeSrcInclude", - null, - HsArgHandler.VECTOR - ), - - new HsArgRule("-define", - "Define", - null, - HsArgHandler.VECTOR - ), - - new HsArgRule("-useToGeneratePch", - "UseToGeneratePch", - null, - HsArgHandler.STRING - ), - - new ArgRuleSpecific("-perFileLine", - new HsArgHandler() { - public void handle(ArgIterator it) { - String cfg = getCfg(it.get()); - if (nextNotKey(it)) { - String fileName = it.get(); - if (nextNotKey(it)) { - String line = it.get(); - BuildConfig.putFieldHash(cfg, "PerFileLine", fileName, line); - it.next(); - return; - } - } - empty(null, "** Error: wrong number of args to -perFileLine"); - } - } - ), - - new ArgRuleSpecific("-conditionalPerFileLine", - new HsArgHandler() { - public void handle(ArgIterator it) { - String cfg = getCfg(it.get()); - if (nextNotKey(it)) { - String fileName = it.get(); - if (nextNotKey(it)) { - String productLine = it.get(); - if (nextNotKey(it)) { - String debugLine = it.get(); - BuildConfig.putFieldHash(cfg+"_debug", "CondPerFileLine", - fileName, debugLine); - BuildConfig.putFieldHash(cfg+"_product", "CondPerFileLine", - fileName, productLine); - it.next(); - return; - } - } - } - - empty(null, "** Error: wrong number of args to -conditionalPerFileLine"); - } - } - ), - - new HsArgRule("-disablePch", - "DisablePch", - null, - HsArgHandler.HASH - ), - - new ArgRule("-startAt", - new HsArgHandler() { - public void handle(ArgIterator it) { - if (BuildConfig.getField(null, "StartAt") != null) { - empty(null, "** Error: multiple -startAt"); - } - if (nextNotKey(it)) { - BuildConfig.putField(null, "StartAt", it.get()); - it.next(); - } else { - empty("-startAt", null); - } - } - } - ), - - new HsArgRule("-ignoreFile", - "IgnoreFile", - null, - HsArgHandler.HASH - ), - - new HsArgRule("-ignorePath", - "IgnorePath", - null, - HsArgHandler.VECTOR - ), - - new HsArgRule("-hidePath", - "HidePath", - null, - HsArgHandler.VECTOR - ), - - new HsArgRule("-additionalFile", - "AdditionalFile", - null, - HsArgHandler.VECTOR - ), - - new ArgRuleSpecific("-additionalGeneratedFile", - new HsArgHandler() { - public void handle(ArgIterator it) { - String cfg = getCfg(it.get()); - if (nextNotKey(it)) { - String dir = it.get(); - if (nextNotKey(it)) { - String fileName = it.get(); - BuildConfig.putFieldHash(cfg, "AdditionalGeneratedFile", - Util.normalize(dir + Util.sep + fileName), - fileName); - it.next(); - return; - } - } - empty(null, "** Error: wrong number of args to -additionalGeneratedFile"); - } - } - ), - - new ArgRule("-prelink", - new HsArgHandler() { - public void handle(ArgIterator it) { - if (nextNotKey(it)) { - if (nextNotKey(it)) { - String description = it.get(); - if (nextNotKey(it)) { - String command = it.get(); - BuildConfig.putField(null, "PrelinkDescription", description); - BuildConfig.putField(null, "PrelinkCommand", command); - it.next(); - return; - } - } - } - - empty(null, "** Error: wrong number of args to -prelink"); - } - } - ), - - new ArgRule("-postbuild", - new HsArgHandler() { - public void handle(ArgIterator it) { - if (nextNotKey(it)) { - if (nextNotKey(it)) { - String description = it.get(); - if (nextNotKey(it)) { - String command = it.get(); - BuildConfig.putField(null, "PostbuildDescription", description); - BuildConfig.putField(null, "PostbuildCommand", command); - it.next(); - return; - } - } - } - - empty(null, "** Error: wrong number of args to -postbuild"); - } - } - ), - }, - new ArgHandler() { - public void handle(ArgIterator it) { - - throw new RuntimeException("Arg Parser: unrecognized option "+it.get()); - } - } - ); - if (BuildConfig.getField(null, "SourceBase") == null || - BuildConfig.getField(null, "BuildBase") == null || - BuildConfig.getField(null, "ProjectFileName") == null || - BuildConfig.getField(null, "CompilerVersion") == null) { - usage(); - } - - if (BuildConfig.getField(null, "UseToGeneratePch") == null) { - throw new RuntimeException("ERROR: need to specify one file to compute PCH, with -useToGeneratePch flag"); - } - - BuildConfig.putField(null, "PlatformObject", this); - } - - Vector createAllConfigs(String platform) { - Vector allConfigs = new Vector(); - - allConfigs.add(new C1DebugConfig()); - allConfigs.add(new C1FastDebugConfig()); - allConfigs.add(new C1ProductConfig()); - - allConfigs.add(new TieredDebugConfig()); - allConfigs.add(new TieredFastDebugConfig()); - allConfigs.add(new TieredProductConfig()); - - return allConfigs; - } - - PrintWriter printWriter; - - public void writeProjectFile(String projectFileName, String projectName, - Vector<BuildConfig> allConfigs) throws IOException { - throw new RuntimeException("use compiler version specific version"); - } - - int indent; - private Stack<String> tagStack = new Stack<String>(); - - private void startTagPrim(String name, String[] attrs, boolean close) { - startTagPrim(name, attrs, close, true); - } - - private void startTagPrim(String name, String[] attrs, boolean close, - boolean newline) { - doIndent(); - printWriter.print("<" + name); - indent++; - - if (attrs != null && attrs.length > 0) { - for (int i = 0; i < attrs.length; i += 2) { - printWriter.print(" " + attrs[i] + "=\"" + attrs[i + 1] + "\""); - if (i < attrs.length - 2) { - } - } - } - - if (close) { - indent--; - printWriter.print(" />"); - } else { - // TODO push tag name, and change endTag to pop and print. - tagStack.push(name); - printWriter.print(">"); - } - if (newline) { - printWriter.println(); - } - } - - void startTag(String name, String... attrs) { - startTagPrim(name, attrs, false); - } - - void startTagV(String name, Vector attrs) { - String s[] = new String[attrs.size()]; - for (int i = 0; i < attrs.size(); i++) { - s[i] = (String) attrs.elementAt(i); - } - startTagPrim(name, s, false); - } - - void endTag() { - String name = tagStack.pop(); - indent--; - doIndent(); - printWriter.println("</" + name + ">"); - } - - private void endTagNoIndent() { - String name = tagStack.pop(); - indent--; - printWriter.println("</" + name + ">"); - } - - void tag(String name, String... attrs) { - startTagPrim(name, attrs, true); - } - - void tagData(String name, String data) { - startTagPrim(name, null, false, false); - printWriter.print(data); - endTagNoIndent(); - } - - void tagData(String name, String data, String... attrs) { - startTagPrim(name, attrs, false, false); - printWriter.print(data); - endTagNoIndent(); - } - - void tagV(String name, Vector attrs) { - String s[] = new String[attrs.size()]; - for (int i = 0; i < attrs.size(); i++) { - s[i] = (String) attrs.elementAt(i); - } - startTagPrim(name, s, true); - } - - void doIndent() { - for (int i = 0; i < indent; i++) { - printWriter.print(" "); - } - } - - -}
--- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java Thu Aug 06 22:07:30 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,476 +0,0 @@ -/* - * Copyright (c) 2011, 2015, 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; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.nio.file.FileSystems; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.UUID; -import java.util.Vector; - -public class WinGammaPlatformVC10 extends WinGammaPlatform { - - - LinkedList <String>filters = new LinkedList<String>(); - LinkedList <String[]>filterDeps = new LinkedList<String[]>(); - - @Override - protected String getProjectExt() { - return ".vcxproj"; - } - - @Override - public void writeProjectFile(String projectFileName, String projectName, - Vector<BuildConfig> allConfigs) throws IOException { - System.out.println(); - System.out.println(" Writing .vcxproj file: " + projectFileName); - - String projDir = Util.normalize(new File(projectFileName).getParent()); - - printWriter = new PrintWriter(projectFileName, "UTF-8"); - printWriter.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); - startTag("Project", - "DefaultTargets", "Build", - "ToolsVersion", "4.0", - "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); - startTag("ItemGroup", - "Label", "ProjectConfigurations"); - for (BuildConfig cfg : allConfigs) { - startTag("ProjectConfiguration", - "Include", cfg.get("Name")); - tagData("Configuration", cfg.get("Id")); - tagData("Platform", cfg.get("PlatformName")); - endTag(); - } - endTag(); - - startTag("PropertyGroup", "Label", "Globals"); - tagData("ProjectGuid", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}"); - tag("SccProjectName"); - tag("SccLocalPath"); - endTag(); - - tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); - - for (BuildConfig cfg : allConfigs) { - startTag(cfg, "PropertyGroup", "Label", "Configuration"); - tagData("ConfigurationType", "DynamicLibrary"); - tagData("UseOfMfc", "false"); - tagData("PlatformToolset", "v120"); - endTag(); - } - - tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); - startTag("ImportGroup", "Label", "ExtensionSettings"); - endTag(); - for (BuildConfig cfg : allConfigs) { - startTag(cfg, "ImportGroup", "Label", "PropertySheets"); - tag("Import", - "Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props", - "Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')", - "Label", "LocalAppDataPlatform"); - endTag(); - } - - tag("PropertyGroup", "Label", "UserMacros"); - - startTag("PropertyGroup"); - tagData("_ProjectFileVersion", "10.0.30319.1"); - for (BuildConfig cfg : allConfigs) { - tagData(cfg, "OutDir", cfg.get("OutputDir") + Util.sep); - tagData(cfg, "IntDir", cfg.get("OutputDir") + Util.sep); - tagData(cfg, "LinkIncremental", "false"); - } - for (BuildConfig cfg : allConfigs) { - tagData(cfg, "CodeAnalysisRuleSet", "AllRules.ruleset"); - tag(cfg, "CodeAnalysisRules"); - tag(cfg, "CodeAnalysisRuleAssemblies"); - } - endTag(); - - for (BuildConfig cfg : allConfigs) { - startTag(cfg, "ItemDefinitionGroup"); - startTag("ClCompile"); - tagV(cfg.getV("CompilerFlags")); - endTag(); - - startTag("Link"); - tagV(cfg.getV("LinkerFlags")); - endTag(); - - startTag("PreLinkEvent"); - tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription")); - tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n"))); - endTag(); - - endTag(); - } - - writeFiles(allConfigs, projDir); - - tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); - startTag("ImportGroup", "Label", "ExtensionTargets"); - endTag(); - - endTag(); - printWriter.close(); - System.out.println(" Done writing .vcxproj file."); - - writeFilterFile(projectFileName, projectName, allConfigs, projDir); - writeUserFile(projectFileName, allConfigs); - } - - - private void writeUserFile(String projectFileName, Vector<BuildConfig> allConfigs) throws FileNotFoundException, UnsupportedEncodingException { - String userFileName = projectFileName + ".user"; - if (new File(userFileName).exists()) { - return; - } - System.out.print(" Writing .vcxproj.user file: " + userFileName); - printWriter = new PrintWriter(userFileName, "UTF-8"); - - printWriter.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); - startTag("Project", - "ToolsVersion", "4.0", - "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); - - for (BuildConfig cfg : allConfigs) { - startTag(cfg, "PropertyGroup"); - tagData("LocalDebuggerCommand", cfg.get("JdkTargetRoot") + "\\bin\\java.exe"); - // The JVM loads some libraries using a path relative to - // itself because it expects to be in a JRE or a JDK. The java - // launcher's '-XXaltjvm=' option allows the JVM to be outside - // the JRE or JDK so '-Dsun.java.launcher.is_altjvm=true' - // forces a fake JAVA_HOME relative path to be used to - // find the other libraries. The '-XX:+PauseAtExit' option - // causes the VM to wait for key press before exiting; this - // allows any stdout or stderr messages to be seen before - // the cmdtool exits. - tagData("LocalDebuggerCommandArguments", "-XXaltjvm=$(TargetDir) " - + "-Dsun.java.launcher.is_altjvm=true " - + "-XX:+UnlockDiagnosticVMOptions -XX:+PauseAtExit"); - tagData("LocalDebuggerEnvironment", "JAVA_HOME=" + cfg.get("JdkTargetRoot")); - endTag(); - } - - endTag(); - printWriter.close(); - System.out.println(" Done."); - } - - public void addFilter(String rPath) { - filters.add(rPath); - } - - public void addFilterDependency(String fileLoc, String filter) { - filterDeps.add(new String[] {fileLoc, filter}); - } - - private void writeFilterFile(String projectFileName, String projectName, - Vector<BuildConfig> allConfigs, String base) throws FileNotFoundException, UnsupportedEncodingException { - String filterFileName = projectFileName + ".filters"; - System.out.print(" Writing .vcxproj.filters file: " + filterFileName); - printWriter = new PrintWriter(filterFileName, "UTF-8"); - - printWriter.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); - startTag("Project", - "ToolsVersion", "4.0", - "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); - - startTag("ItemGroup"); - for (String filter : filters) { - startTag("Filter", "Include",filter); - UUID uuid = UUID.randomUUID(); - tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); - endTag(); - } - startTag("Filter", "Include", "Resource Files"); - UUID uuid = UUID.randomUUID(); - tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); - tagData("Extensions", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"); - endTag(); - endTag(); - - //TODO - do I need to split cpp and hpp files? - - // then all files - startTag("ItemGroup"); - for (String[] dep : filterDeps) { - String tagName = getFileTagFromSuffix(dep[0]); - - startTag(tagName, "Include", dep[0]); - tagData("Filter", dep[1]); - endTag(); - } - endTag(); - - endTag(); - printWriter.close(); - System.out.println(" Done."); - } - - public String getFileTagFromSuffix(String fileName) { - if (fileName.endsWith(".cpp")) { - return"ClCompile"; - } else if (fileName.endsWith(".c")) { - return "ClCompile"; - } else if (fileName.endsWith(".hpp")) { - return"ClInclude"; - } else if (fileName.endsWith(".h")) { - return "ClInclude"; - } else { - return"None"; - } - } - - void writeFiles(Vector<BuildConfig> allConfigs, String projDir) { - // This code assummes there are no config specific includes. - startTag("ItemGroup"); - - String sourceBase = BuildConfig.getFieldString(null, "SourceBase"); - - // Use first config for all global absolute includes. - BuildConfig baseConfig = allConfigs.firstElement(); - Vector<String> rv = new Vector<String>(); - - // Then use first config for all relative includes - Vector<String> ri = new Vector<String>(); - baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude"); - for (String f : ri) { - rv.add(sourceBase + Util.sep + f); - } - - baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude"); - - handleIncludes(rv, allConfigs); - - endTag(); - } - - // Will visit file tree for each include - private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) { - for (String path : includes) { - FileTreeCreatorVC10 ftc = new FileTreeCreatorVC10(FileSystems.getDefault().getPath(path) , allConfigs, this); - try { - ftc.writeFileTree(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - String buildCond(BuildConfig cfg) { - return "'$(Configuration)|$(Platform)'=='"+cfg.get("Name")+"'"; - } - - void tagV(Vector<String> v) { - Iterator<String> i = v.iterator(); - while(i.hasNext()) { - String name = i.next(); - String data = i.next(); - tagData(name, data); - } - } - - void tagData(BuildConfig cfg, String name, String data) { - tagData(name, data, "Condition", buildCond(cfg)); - } - - void tag(BuildConfig cfg, String name, String... attrs) { - String[] ss = new String[attrs.length + 2]; - ss[0] = "Condition"; - ss[1] = buildCond(cfg); - System.arraycopy(attrs, 0, ss, 2, attrs.length); - - tag(name, ss); - } - - void startTag(BuildConfig cfg, String name, String... attrs) { - String[] ss = new String[attrs.length + 2]; - ss[0] = "Condition"; - ss[1] = buildCond(cfg); - System.arraycopy(attrs, 0, ss, 2, attrs.length); - - startTag(name, ss); - } - -} - -class CompilerInterfaceVC10 extends CompilerInterface { - - @Override - Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) { - Vector rv = new Vector(); - - addAttr(rv, "AdditionalIncludeDirectories", Util.join(";", includes)); - addAttr(rv, "PreprocessorDefinitions", - Util.join(";", defines).replace("\\\"", "\"")); - addAttr(rv, "PrecompiledHeaderFile", "precompiled.hpp"); - addAttr(rv, "PrecompiledHeaderOutputFile", outDir+Util.sep+"vm.pch"); - addAttr(rv, "AssemblerListingLocation", outDir); - addAttr(rv, "ObjectFileName", outDir+Util.sep); - addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb"); - // Set /nologo option - addAttr(rv, "SuppressStartupBanner", "true"); - // Surpass the default /Tc or /Tp. - addAttr(rv, "CompileAs", "Default"); - // Set /W3 option. - addAttr(rv, "WarningLevel", "Level3"); - // Set /WX option, - addAttr(rv, "TreatWarningAsError", "true"); - // Set /GS option - addAttr(rv, "BufferSecurityCheck", "false"); - // Set /Zi option. - addAttr(rv, "DebugInformationFormat", "ProgramDatabase"); - // Set /Yu option. - addAttr(rv, "PrecompiledHeader", "Use"); - // Set /EHsc- option - addAttr(rv, "ExceptionHandling", ""); - - addAttr(rv, "MultiProcessorCompilation", "true"); - - return rv; - } - - @Override - Vector getDebugCompilerFlags(String opt, String platformName) { - Vector rv = new Vector(); - - // Set /On option - addAttr(rv, "Optimization", opt); - // Set /MD option. - addAttr(rv, "RuntimeLibrary", "MultiThreadedDLL"); - // Set /Oy- option - addAttr(rv, "OmitFramePointers", "false"); - // Set /homeparams for x64 debug builds - if(platformName.equals("x64")) { - addAttr(rv, "AdditionalOptions", "/homeparams"); - } - - return rv; - } - - @Override - Vector getProductCompilerFlags() { - Vector rv = new Vector(); - - // Set /O2 option. - addAttr(rv, "Optimization", "MaxSpeed"); - // Set /Oy- option - addAttr(rv, "OmitFramePointers", "false"); - // Set /Ob option. 1 is expandOnlyInline - addAttr(rv, "InlineFunctionExpansion", "OnlyExplicitInline"); - // Set /GF option. - addAttr(rv, "StringPooling", "true"); - // Set /MD option. 2 is rtMultiThreadedDLL - addAttr(rv, "RuntimeLibrary", "MultiThreadedDLL"); - // Set /Gy option - addAttr(rv, "FunctionLevelLinking", "true"); - - return rv; - } - - @Override - Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) { - Vector rv = new Vector(); - - if(platformName.equals("Win32")) { - addAttr(rv, "AdditionalOptions", - "/export:JNI_GetDefaultJavaVMInitArgs " + - "/export:JNI_CreateJavaVM " + - "/export:JVM_FindClassFromBootLoader "+ - "/export:JNI_GetCreatedJavaVMs "+ - "/export:jio_snprintf /export:jio_printf "+ - "/export:jio_fprintf /export:jio_vfprintf "+ - "/export:jio_vsnprintf "+ - "/export:JVM_GetVersionInfo "+ - "/export:JVM_InitAgentProperties"); - } - addAttr(rv, "AdditionalDependencies", "kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;Wsock32.lib;winmm.lib;psapi.lib;version.lib"); - addAttr(rv, "OutputFile", outDll); - addAttr(rv, "SuppressStartupBanner", "true"); - addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def"); - addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb"); - addAttr(rv, "SubSystem", "Windows"); - addAttr(rv, "BaseAddress", "0x8000000"); - addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib"); - - if(platformName.equals("Win32")) { - addAttr(rv, "TargetMachine", "MachineX86"); - } else { - addAttr(rv, "TargetMachine", "MachineX64"); - } - - // We always want the /DEBUG option to get full symbol information in the pdb files - addAttr(rv, "GenerateDebugInformation", "true"); - - return rv; - } - - @Override - Vector getDebugLinkerFlags() { - Vector rv = new Vector(); - - // Empty now that /DEBUG option is used by all configs - - return rv; - } - - @Override - Vector getProductLinkerFlags() { - Vector rv = new Vector(); - - // Set /OPT:REF option. - addAttr(rv, "OptimizeReferences", "true"); - // Set /OPT:ICF option. - addAttr(rv, "EnableCOMDATFolding", "true"); - - return rv; - } - - @Override - void getAdditionalNonKernelLinkerFlags(Vector rv) { - extAttr(rv, "AdditionalOptions", " /export:AsyncGetCallTrace"); - } - - @Override - String getOptFlag() { - return "MaxSpeed"; - } - - @Override - String getNoOptFlag() { - return "Disabled"; - } - - @Override - String makeCfgName(String flavourBuild, String platform) { - return flavourBuild + "|" + platform; - } - -}