src/share/tools/ProjectCreator/BuildConfig.java
Print this page
rev 3265 : 0000000: Updated projectcreator
Summary: Refactoring
Reviewed-by:
Contributed-by: nils.eliasson@oracle.com
*** 20,38 ****
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
- import java.io.File;
import java.util.Enumeration;
import java.util.Hashtable;
- import java.util.Iterator;
import java.util.Vector;
class BuildConfig {
Hashtable vars;
! Vector basicNames, basicPaths;
String[] context;
static CompilerInterface ci;
static CompilerInterface getCI() {
if (ci == null) {
--- 20,37 ----
* 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) {
*** 45,54 ****
--- 44,54 ----
}
}
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");
*** 61,90 ****
put("PlatformName", platformName);
// ones mentioned above were needed to expand format
String buildBase = expandFormat(getFieldString(null, "BuildBase"));
String sourceBase = getFieldString(null, "SourceBase");
String outDir = buildBase;
put("Id", flavourBuild);
put("OutputDir", outDir);
put("SourceBase", sourceBase);
put("BuildBase", buildBase);
put("OutputDll", outDir + Util.sep + outDll);
context = new String [] {flavourBuild, flavour, build, null};
}
! protected void init(Vector includes, Vector defines) {
initDefaultDefines(defines);
initDefaultCompilerFlags(includes);
initDefaultLinkerFlags();
! handleDB();
}
! protected void initDefaultCompilerFlags(Vector includes) {
Vector compilerFlags = new Vector();
compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"),
includes,
get("OutputDir")));
--- 61,92 ----
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;
put("Id", flavourBuild);
put("OutputDir", outDir);
put("SourceBase", sourceBase);
put("BuildBase", buildBase);
+ put("BuildSpace", buildSpace);
put("OutputDll", outDir + Util.sep + outDll);
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")));
*** 98,244 ****
linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll"), get("PlatformName")));
put("LinkerFlags", linkerFlags);
}
! DirectoryTree getSourceTree(String sourceBase, String startAt) {
! DirectoryTree tree = new DirectoryTree();
!
! tree.addSubdirToIgnore("Codemgr_wsdata");
! tree.addSubdirToIgnore("deleted_files");
! tree.addSubdirToIgnore("SCCS");
! tree.setVerbose(true);
! if (startAt != null) {
! tree.readDirectory(sourceBase + File.separator + startAt);
! } else {
! tree.readDirectory(sourceBase);
}
-
- return tree;
}
!
!
! Vector getPreferredPaths() {
! Vector preferredPaths = new Vector();
!
! // In the case of multiple files with the same name in
! // different subdirectories, prefer these versions
! preferredPaths.add("windows");
! preferredPaths.add("x86");
! preferredPaths.add("closed");
!
! // Also prefer "opto" over "adlc" for adlcVMDeps.hpp
! preferredPaths.add("opto");
!
! return preferredPaths;
! }
!
!
! void handleDB() {
! WinGammaPlatform platform = (WinGammaPlatform)getField(null, "PlatformObject");
!
! putSpecificField("AllFilesHash", computeAllFiles(platform));
}
!
! private boolean matchesIgnoredPath(String prefixedName) {
! Vector rv = new Vector();
! collectRelevantVectors(rv, "IgnorePath");
! for (Iterator i = rv.iterator(); i.hasNext(); ) {
! String pathPart = (String) i.next();
! if (prefixedName.contains(Util.normalize(pathPart))) {
return true;
}
}
return false;
}
! void addAll(Iterator i, Hashtable hash,
! WinGammaPlatform platform, DirectoryTree tree,
! Vector preferredPaths, Vector filesNotFound, Vector filesDuplicate) {
! for (; i.hasNext(); ) {
! String fileName = (String) i.next();
! if (lookupHashFieldInContext("IgnoreFile", fileName) == null) {
! String prefixedName = platform.envVarPrefixedFileName(fileName,
! 0, /* ignored */
! tree,
! preferredPaths,
! filesNotFound,
! filesDuplicate);
! if (prefixedName != null) {
! prefixedName = Util.normalize(prefixedName);
! if (!matchesIgnoredPath(prefixedName)) {
! addTo(hash, prefixedName, fileName);
! }
}
}
}
}
void addTo(Hashtable ht, String key, String value) {
ht.put(expandFormat(key), expandFormat(value));
}
- Hashtable computeAllFiles(WinGammaPlatform platform) {
- Hashtable rv = new Hashtable();
- DirectoryTree tree = getSourceTree(get("SourceBase"), getFieldString(null, "StartAt"));
- Vector preferredPaths = getPreferredPaths();
-
- // Hold errors until end
- Vector filesNotFound = new Vector();
- Vector filesDuplicate = new Vector();
-
- Vector includedFiles = new Vector();
-
- // find all files
- Vector dirs = getSourceIncludes();
- for (Iterator i = dirs.iterator(); i.hasNext(); ) {
- String dir = (String)i.next();
- DirectoryTree subtree = getSourceTree(dir, null);
- for (Iterator fi = subtree.getFileIterator(); fi.hasNext(); ) {
- String name = ((File)fi.next()).getName();
- includedFiles.add(name);
- }
- }
- addAll(includedFiles.iterator(), rv,
- platform, tree,
- preferredPaths, filesNotFound, filesDuplicate);
-
- Vector addFiles = new Vector();
- collectRelevantVectors(addFiles, "AdditionalFile");
- addAll(addFiles.iterator(), rv,
- platform, tree,
- preferredPaths, filesNotFound, filesDuplicate);
-
- collectRelevantHashes(rv, "AdditionalGeneratedFile");
-
- if ((filesNotFound.size() != 0) ||
- (filesDuplicate.size() != 0)) {
- System.err.println("Error: some files were not found or " +
- "appeared in multiple subdirectories of " +
- "directory " + get("SourceBase") + " and could not " +
- "be resolved with os_family and arch.");
- if (filesNotFound.size() != 0) {
- System.err.println("Files not found:");
- for (Iterator iter = filesNotFound.iterator();
- iter.hasNext(); ) {
- System.err.println(" " + (String) iter.next());
- }
- }
- if (filesDuplicate.size() != 0) {
- System.err.println("Duplicate files:");
- for (Iterator iter = filesDuplicate.iterator();
- iter.hasNext(); ) {
- System.err.println(" " + (String) iter.next());
- }
- }
- throw new RuntimeException();
- }
-
- return rv;
- }
-
void initDefaultDefines(Vector defines) {
Vector sysDefines = new Vector();
sysDefines.add("WIN32");
sysDefines.add("_WINDOWS");
sysDefines.add("HOTSPOT_BUILD_USER=\\\""+System.getProperty("user.name")+"\\\"");
--- 100,151 ----
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;
}
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")+"\\\"");
*** 322,345 ****
void putSpecificField(String field, Object value) {
putField(get("Id"), field, value);
}
void collectRelevantVectors(Vector rv, String field) {
! for (int i = 0; i < context.length; i++) {
! Vector v = getFieldVector(context[i], field);
if (v != null) {
! for (Iterator j=v.iterator(); j.hasNext(); ) {
! String val = (String)j.next();
! rv.add(expandFormat(val));
}
}
}
}
void collectRelevantHashes(Hashtable rv, String field) {
! for (int i = 0; i < context.length; i++) {
! Hashtable v = (Hashtable)getField(context[i], 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);
--- 229,251 ----
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);
*** 355,379 ****
return rv;
}
Vector getIncludes() {
Vector rv = new Vector();
-
collectRelevantVectors(rv, "AbsoluteInclude");
-
rv.addAll(getSourceIncludes());
-
return rv;
}
private Vector getSourceIncludes() {
! Vector rv = new Vector();
! Vector ri = new Vector();
String sourceBase = getFieldString(null, "SourceBase");
collectRelevantVectors(ri, "RelativeInclude");
! for (Iterator i = ri.iterator(); i.hasNext(); ) {
! String f = (String)i.next();
rv.add(sourceBase + Util.sep + f);
}
return rv;
}
--- 261,281 ----
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>();
! Vector<String> ri = new Vector<String>();
String sourceBase = getFieldString(null, "SourceBase");
collectRelevantVectors(ri, "RelativeInclude");
! for (String f : ri) {
rv.add(sourceBase + Util.sep + f);
}
return rv;
}
*** 602,612 ****
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");
--- 504,513 ----
*** 636,646 ****
initNames("tiered", "product", "jvm.dll");
init(getIncludes(), getDefines());
}
}
!
class CoreDebugConfig extends GenericDebugNonKernelConfig {
String getOptFlag() {
return getCI().getNoOptFlag();
}
--- 537,547 ----
initNames("tiered", "product", "jvm.dll");
init(getIncludes(), getDefines());
}
}
! /*
class CoreDebugConfig extends GenericDebugNonKernelConfig {
String getOptFlag() {
return getCI().getNoOptFlag();
}
*** 648,658 ****
initNames("core", "debug", "jvm.dll");
init(getIncludes(), getDefines());
}
}
-
class CoreFastDebugConfig extends GenericDebugNonKernelConfig {
String getOptFlag() {
return getCI().getOptFlag();
}
--- 549,558 ----
*** 660,676 ****
initNames("core", "fastdebug", "jvm.dll");
init(getIncludes(), getDefines());
}
}
-
class CoreProductConfig extends ProductConfig {
CoreProductConfig() {
initNames("core", "product", "jvm.dll");
init(getIncludes(), getDefines());
}
! }
class KernelDebugConfig extends GenericDebugConfig {
String getOptFlag() {
return getCI().getNoOptFlag();
}
--- 560,575 ----
initNames("core", "fastdebug", "jvm.dll");
init(getIncludes(), getDefines());
}
}
class CoreProductConfig extends ProductConfig {
CoreProductConfig() {
initNames("core", "product", "jvm.dll");
init(getIncludes(), getDefines());
}
! }*/
class KernelDebugConfig extends GenericDebugConfig {
String getOptFlag() {
return getCI().getNoOptFlag();
}
*** 698,707 ****
--- 597,607 ----
KernelProductConfig() {
initNames("kernel", "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);
abstract Vector getDebugLinkerFlags();