use of com.ibm.uma.om.Artifact in project openj9 by eclipse.
the class PlatformWindows method writeRebaseTargets.
void writeRebaseTargets(StringBuffer buffer) throws IOException, UMAException {
// determine the total number of loadgroups and which ones have duplicates
Hashtable<String, Vector<Artifact>> loadtable = new Hashtable<String, Vector<Artifact>>();
for (Artifact artifact : UMA.getUma().getArtifacts().values()) {
if ((artifact.getType() == Artifact.TYPE_BUNDLE || artifact.getType() == Artifact.TYPE_SHARED) && artifact.getLoadGroup() != null) {
Vector<Artifact> artifacts = loadtable.get(artifact.getLoadGroup());
if (artifacts == null) {
artifacts = new Vector<Artifact>();
loadtable.put(artifact.getLoadGroup(), artifacts);
}
artifacts.add(artifact);
}
}
Vector<String> groupNames = new Vector<String>();
Vector<String> singles = new Vector<String>();
boolean topGroupExists = false;
for (String group : loadtable.keySet()) {
Vector<Artifact> artifacts = loadtable.get(group);
if (group.equalsIgnoreCase("top")) {
topGroupExists = true;
groupNames.add(group);
} else {
if (artifacts.size() > 1) {
groupNames.add(group);
} else {
singles.add(group);
}
}
}
buffer.append("rebase: rebase.txt");
for (String group : groupNames) {
buffer.append(" rebase_" + group + ".txt");
}
String rebase_base = configuration.replaceMacro("uma_rebase_base");
if (rebase_base == null || rebase_base.equalsIgnoreCase("")) {
rebase_base = "0x7FFB0000";
}
buffer.append("\n" + " -rm -f rebase.log\n" + " rebase -q -b " + rebase_base + " -d -R . -l rebase.log");
if (topGroupExists) {
buffer.append(" -G rebase_top.txt");
}
buffer.append(" -G rebase.txt");
/*
* In jvm.26 JIT makefiles are used directly, to allow the use the same UMA tool in jvm.24 and beyond
* uma needs to detect whether JIT makefiles are in use. The absence of "j9jit" in the groups list means
* that JIT makefiles are being used.
*
* See CMVC 187776 for what happens when JIT makefiles are used and -O rebase_jit.txt is not present.
* (preview there will be problems instantiating the heap)
*
* When JIT makefiles are not used and -O rebase_jit.txt is present, compile will fail due to not being able to open
* the rebase_jit.txt file.
*/
boolean jitGroupDetected = false;
for (String group : groupNames) {
if (group.equalsIgnoreCase("top"))
continue;
buffer.append(" -O rebase_" + group + ".txt");
if (group.equalsIgnoreCase("j9jit")) {
jitGroupDetected = true;
}
}
if (!jitGroupDetected) {
// this file is created as rebase_jit.txt.ftl in the VM windows code base.
buffer.append(" -O rebase_jit.txt");
}
buffer.append("\n\n");
for (String group : groupNames) {
buffer.append("rebase_" + group + ".txt: makefile\n" + " -rm -f rebase_" + group + ".txt\n");
Vector<Artifact> artifacts = loadtable.get(group);
for (Artifact artifact : artifacts) {
buffer.append(" echo $(" + artifact.getTargetNameWithScope() + "_ondisk) >> rebase_" + group + ".txt\n");
}
buffer.append("\n");
}
buffer.append("rebase.txt: makefile\n" + " -rm -f rebase.txt\n");
for (String group : singles) {
Vector<Artifact> artifacts = loadtable.get(group);
for (Artifact artifact : artifacts) {
buffer.append(" echo $(" + artifact.getTargetNameWithScope() + "_ondisk) >> rebase.txt\n");
}
}
buffer.append("\n" + ".PHONY: rebase\n" + "\n");
}
use of com.ibm.uma.om.Artifact in project openj9 by eclipse.
the class UMA method getLibraryDependenciesOfType.
/**
* @param artifact artifact being built
* @param type The type of library to find.
* @param forStatic Whether these libraries are for an UMA_STATIC_BUILD
* @param libArtifact artifact being linked in
* @throws UMAException
*/
private String getLibraryDependenciesOfType(Artifact artifact, int type, boolean forStatic, Artifact libArtifact) throws UMAException {
String libName = libArtifact.getTargetNameWithScope();
if (type == Library.TYPE_BUILD) {
/* static versions use the library name without any tweaks */
if (forStatic) {
return libName + " ";
}
/* unbundled artifacts don't require special treatment */
if (!libArtifact.isInBundle()) {
return libName + " ";
}
}
StringBuilder stringBuilder = new StringBuilder();
/* executables/external DLL's should link in the *actual* code, not the bundle */
if (!artifact.isInBundle() && (artifact.getType() == Artifact.TYPE_EXECUTABLE)) {
if (type == Library.TYPE_BUILD) {
stringBuilder.append(libName + " ");
}
for (Library inheritedLib : libArtifact.getLibraries()) {
if (!inheritedLib.evaluate()) {
continue;
}
Artifact inheritedLibArtifact = getArtifact(inheritedLib.getName());
if (inheritedLib.getType() == Library.TYPE_BUILD) {
/* Do not include the library if its artifact is not included */
if (null == inheritedLibArtifact || !inheritedLibArtifact.evaluate()) {
continue;
}
}
if (inheritedLib.getType() == type) {
/* macro libraries will have their name mangled */
if (type == Library.TYPE_MACRO) {
if (null != inheritedLibArtifact && !inheritedLibArtifact.evaluate()) {
continue;
}
String libs = platform.replaceMacro(inheritedLib.getName());
if (libs != null) {
stringBuilder.append(libs + " ");
}
} else {
stringBuilder.append(inheritedLib.getName() + " ");
}
}
}
return stringBuilder.toString();
}
if (type == Library.TYPE_BUILD) {
/* if we are building the bundle then used unmodified names */
Artifact bundle = getBundleArtifact(libArtifact.getBundle());
if (bundle == artifact) {
return stringBuilder.toString();
}
/* otherwise the library is in a bundle and we should substitute the bundle name (ugh) */
stringBuilder.append(bundle.getArtifactKey() + " ");
return stringBuilder.toString();
}
return "";
}
use of com.ibm.uma.om.Artifact in project openj9 by eclipse.
the class UMA method addArtifact.
public void addArtifact(Artifact artifact) throws UMAException {
String artifactKey = artifact.getArtifactKey();
Artifact artifactInMap = artifactMap.get(artifactKey);
if (artifactInMap != null) {
throw new DuplicateArtifactKeyException("Duplicate artifact key found [" + artifactKey + "] in file " + artifact.getContainingFile() + " already found in file " + artifactInMap.getContainingFile());
}
artifactMap.put(artifactKey, artifact);
}
use of com.ibm.uma.om.Artifact in project openj9 by eclipse.
the class UMA method addDependencies.
void addDependencies(Vector<Library> libraries, Hashtable<String, LinkedHashSet<String>> buildDependencies, Artifact artifact) throws UMAException {
String target = artifact.getMakefileName();
LinkedHashSet<String> deps = buildDependencies.get(target);
if (deps == null) {
deps = new LinkedHashSet<String>();
buildDependencies.put(target, deps);
}
for (Library library : libraries) {
if (library.evaluate()) {
if (library.getType() != Library.TYPE_BUILD)
continue;
Artifact libArtifact = getArtifact(library.getName());
if (libArtifact == null)
continue;
String libName = libArtifact.getMakefileName();
if (libArtifact.isInBundle()) {
Artifact bundle = getBundleArtifact(libArtifact.getBundle());
if (artifact != bundle) {
/* If we are not dealing with the bundle itself, then substitute the
* bundle name for the library. */
libName = bundle.getMakefileName();
}
}
if (!deps.contains(libName) && !libName.equalsIgnoreCase(target)) {
deps.add(libName);
}
}
}
for (Dependency artifactDependency : artifact.getDependendies()) {
if (artifactDependency.evaluate()) {
String dependency = artifactDependency.getDependency();
if (!deps.contains(dependency) && !dependency.equalsIgnoreCase(target)) {
deps.add(dependency);
}
}
}
}
use of com.ibm.uma.om.Artifact in project openj9 by eclipse.
the class UMA method expandLibraryDependencies.
void expandLibraryDependencies(Artifact artifact, StringBuffer libLocations) throws UMAException {
switch(artifact.getType()) {
// FALL-THRU
case Artifact.TYPE_BUNDLE:
// FALL-THRU
case Artifact.TYPE_STATIC:
case Artifact.TYPE_SHARED:
libLocations.append(artifact.getTargetNameWithScope() + "_deps=" + artifact.getTargetName());
Hashtable<String, Library> libs = artifact.getAllLibrariesThisArtifactDependsOn();
for (Library lib : libs.values()) {
if (lib.evaluate()) {
switch(lib.getType()) {
case Library.TYPE_MACRO:
String mlibs = platform.replaceMacro(lib.getName());
if (mlibs != null) {
libLocations.append(" " + mlibs);
}
continue;
}
libLocations.append(" " + lib.getName());
}
}
/* for bundles emit a dependency on element in the bundle */
if (artifact.getType() == Artifact.TYPE_BUNDLE) {
String bundleName = artifact.getTargetName();
for (Artifact artifactCursor : artifactMap.values()) {
if (!artifactCursor.evaluate()) {
continue;
}
if (!artifactCursor.isInBundle()) {
continue;
}
if (!artifactCursor.getBundle().equalsIgnoreCase(bundleName)) {
continue;
}
libLocations.append(" " + artifactCursor.getArtifactKey());
}
}
libLocations.append("\n\n");
break;
}
}
Aggregations