Search in sources :

Example 1 with Library

use of com.ibm.uma.om.Library 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 "";
}
Also used : Library(com.ibm.uma.om.Library) SubdirArtifact(com.ibm.uma.om.SubdirArtifact) Artifact(com.ibm.uma.om.Artifact)

Example 2 with Library

use of com.ibm.uma.om.Library 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);
            }
        }
    }
}
Also used : Library(com.ibm.uma.om.Library) Dependency(com.ibm.uma.om.Dependency) SubdirArtifact(com.ibm.uma.om.SubdirArtifact) Artifact(com.ibm.uma.om.Artifact)

Example 3 with Library

use of com.ibm.uma.om.Library 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;
    }
}
Also used : Library(com.ibm.uma.om.Library) SubdirArtifact(com.ibm.uma.om.SubdirArtifact) Artifact(com.ibm.uma.om.Artifact)

Example 4 with Library

use of com.ibm.uma.om.Library in project openj9 by eclipse.

the class PlatformImplementation method writePlatformSpecificFiles.

/* (non-Javadoc)
	 * @see com.ibm.uma.platform.IPlatform#writePlatformSpecificFiles(com.ibm.uma.Artifact)
	 */
public void writePlatformSpecificFiles(Artifact artifact) throws UMAException {
    writeExportFile(artifact);
    if (!artifact.flagSet("requiresPrimitiveTable") && !artifact.flagSet("dumpMasterPrimitiveTable")) {
        return;
    }
    String filename = UMA.getUma().getRootDirectory() + artifact.getContainingModule().getFullName() + "/" + artifact.getTargetName() + "exp.c";
    Vector<Export> exports = artifact.getExportedFunctions();
    FileAssistant fa = new FileAssistant(filename);
    StringBuffer buffer = fa.getStringBuffer();
    buffer.append(configuration.getcCopyrightNotice());
    buffer.append("#include \"j9comp.h\"\n#include \"j9static.h\"\n\n");
    buffer.append("#if !defined(J9VM_SHARED_LIBRARIES_SUPPORTED) || defined(J9VM_OPT_BUNDLE_CORE_MODULES)\n");
    if (artifact.flagSet("requiresPrimitiveTable")) {
        if (artifact.flagSet("dumpGenericProtosForPrimTable")) {
            for (Export export : exports) {
                buffer.append("extern void VMCALL " + export.getExport() + "(void);\n");
            }
        } else {
            // "We ask the the module to give us a header file name to include with the public prototypes"
            String[] prototypeHeaderFileNames = artifact.getData("prototypeHeaderFileNames");
            if (prototypeHeaderFileNames != null) {
                for (String fnm : prototypeHeaderFileNames) {
                    buffer.append("#include \"" + fnm + "\"\n");
                }
            }
            if (artifact.flagSet("extraPrototypesForExportFile")) {
                String[] extraProtos = artifact.getData("extraPrototypesForExportFile");
                for (String proto : extraProtos) {
                    buffer.append("extern void VMCALL " + proto + "(void);\n");
                }
            }
        }
        buffer.append("\nEsDefinePrimitiveTable(" + artifact.getTargetName().toUpperCase() + "PrimitiveTable)\n");
        for (Export export : exports) {
            String strippedExportName = stripExportName(export.getExport());
            buffer.append("\tEsPrimitiveTableEntry(\"" + strippedExportName + "\"," + strippedExportName + ")\n");
        }
        buffer.append("EsEndPrimitiveTable\n");
    }
    if (artifact.flagSet("dumpMasterPrimitiveTable")) {
        buffer.append("\n");
        Vector<Library> libs = artifact.getStaticLinkLibraries();
        if (artifact.getType() == Artifact.TYPE_BUNDLE) {
            libs.addAll(artifact.getLibraries());
        }
        Vector<Artifact> artifacts = new Vector<Artifact>();
        for (Library lib : libs) {
            switch(lib.getType()) {
                case Library.TYPE_BUILD:
                    Artifact artifact2 = UMA.getUma().getArtifact(lib.getName());
                    if (artifact2 != null && artifact2.evaluate()) {
                        artifacts.add(artifact2);
                    }
                    break;
            }
        }
        for (Artifact oa : artifacts) {
            if (oa.evaluate() && oa.flagSet("requiresPrimitiveTable")) {
                buffer.append("extern EsPrimitiveTable " + oa.getTargetName().toUpperCase() + "PrimitiveTable;\n");
            }
        }
        buffer.append("\nEsDefinePrimitiveTable(J9LinkedNatives)\n");
        for (Artifact oa : artifacts) {
            if (oa.evaluate() && oa.flagSet("requiresPrimitiveTable")) {
                String startComment = "";
                String endComment = "";
                if (!oa.flagSet("isRequired") && !oa.flagSet("isRequiredFor" + artifact.getTargetNameWithScope())) {
                    startComment = "/* ";
                    endComment = " */";
                }
                buffer.append("\t" + startComment + "EsPrimitiveTableEntry(\"" + getTargetNameWithRelease(oa) + "\", " + oa.getTargetName().toUpperCase() + "PrimitiveTable)" + endComment + "\n");
            }
        }
        buffer.append("EsEndPrimitiveTable\n");
    }
    buffer.append("\n#endif\n");
    fa.writeToDisk();
}
Also used : FileAssistant(com.ibm.uma.util.FileAssistant) Export(com.ibm.uma.om.Export) Library(com.ibm.uma.om.Library) Vector(java.util.Vector) Artifact(com.ibm.uma.om.Artifact)

Example 5 with Library

use of com.ibm.uma.om.Library in project openj9 by eclipse.

the class PlatformWindows method addArtifactSpecificMakefileInformation.

@Override
public void addArtifactSpecificMakefileInformation(Artifact artifact, StringBuffer buffer) throws UMAException {
    super.addArtifactSpecificMakefileInformation(artifact, buffer);
    // add-in delay load information
    Vector<Library> delayLoadLibraries = new Vector<Library>();
    for (Library library : artifact.getLibraries()) {
        if (!library.evaluate() || !library.getDelayLoad())
            continue;
        delayLoadLibraries.add(library);
    }
    if (delayLoadLibraries.size() > 0) {
        buffer.append("UMA_DELAYLOAD_LIBS=");
        for (Library library : delayLoadLibraries) {
            buffer.append(" " + library.getName().replaceFirst(".lib", ".dll"));
        }
        buffer.append("\n");
    }
}
Also used : Library(com.ibm.uma.om.Library) Vector(java.util.Vector)

Aggregations

Library (com.ibm.uma.om.Library)7 Artifact (com.ibm.uma.om.Artifact)5 SubdirArtifact (com.ibm.uma.om.SubdirArtifact)3 Dependency (com.ibm.uma.om.Dependency)2 Export (com.ibm.uma.om.Export)2 Vector (java.util.Vector)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 NodeList (org.w3c.dom.NodeList)2 UMABadPhaseNameException (com.ibm.uma.UMABadPhaseNameException)1 UMAException (com.ibm.uma.UMAException)1 Command (com.ibm.uma.om.Command)1 Flag (com.ibm.uma.om.Flag)1 Include (com.ibm.uma.om.Include)1 MakefileStub (com.ibm.uma.om.MakefileStub)1 Object (com.ibm.uma.om.Object)1 Option (com.ibm.uma.om.Option)1 VPath (com.ibm.uma.om.VPath)1 FileAssistant (com.ibm.uma.util.FileAssistant)1 Node (org.w3c.dom.Node)1