use of com.ibm.uma.om.Flag in project openj9 by eclipse.
the class FlaglistsParser method parse.
public static Vector<Flags> parse(Node node, String containingFile) throws UMAException {
Vector<Flags> flags = new Vector<Flags>();
NodeList nodeList = node.getChildNodes();
for (int j = 0; j < nodeList.getLength(); j++) {
Node item = nodeList.item(j);
Flags flagsContainer = new Flags(containingFile);
if (item.getNodeName().equalsIgnoreCase("flags")) {
NodeList flagsNodeList = item.getChildNodes();
for (int k = 0; j < flagsNodeList.getLength(); k++) {
Node fItem = flagsNodeList.item(k);
Flag f = FlagParser.parse(fItem, containingFile);
flagsContainer.addFlag(f);
}
}
flags.add(flagsContainer);
}
return flags;
}
use of com.ibm.uma.om.Flag in project openj9 by eclipse.
the class PlatformImplementation method writeMakefileFlagsLine.
public final StringBuffer writeMakefileFlagsLine(Artifact artifact) throws UMAException {
StringBuffer buffer = new StringBuffer();
Vector<Flag> flags = artifact.getFlags();
for (Flag flag : flags) {
if (flag.evaluate()) {
String flagString = "";
if (flag.isDefinition()) {
if (flag.getValue() != null) {
flagString += "-D" + flag.getName() + "=" + flag.getValue();
} else {
flagString += "-D" + flag.getName();
}
} else {
flagString += flag.getName();
}
if (flag.isCflag()) {
buffer.append(UMA.UMA_ARTIFACT_CFLAGS_LABEL + "+=" + flagString + "\n");
if (replaceMacro("uma_use_cflags_on_asflag_line") != null) {
buffer.append(UMA.UMA_ARTIFACT_ASFLAGS_LABEL + "+=" + getFlagStringForAS(flag) + "\n");
}
}
if (flag.isCxxflag()) {
buffer.append(UMA.UMA_ARTIFACT_CXXFLAGS_LABEL + "+=" + flagString + "\n");
}
if (flag.isCppflag()) {
buffer.append(UMA.UMA_ARTIFACT_CPPFLAGS_LABEL + "+=" + flagString + "\n");
}
if (flag.isAsmflag()) {
buffer.append(UMA.UMA_ARTIFACT_ASFLAGS_LABEL + "+=" + getFlagStringForAS(flag) + "\n");
}
}
}
return buffer;
}
use of com.ibm.uma.om.Flag in project openj9 by eclipse.
the class ArtifactParser method parse.
public static Artifact parse(Node artifactNode, Module module) throws UMAException {
Artifact artifact = new Artifact(module);
NodeList nodeList = artifactNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
String nodeName = node.getLocalName();
if (nodeName == null)
continue;
if (nodeName.equalsIgnoreCase("description")) {
NodeList descChildren = node.getChildNodes();
Node descChild = descChildren.item(0);
artifact.setDescription(descChild.getNodeValue());
} else if (nodeName.equalsIgnoreCase("options")) {
NodeList optionsNodeList = node.getChildNodes();
for (int j = 0; j < optionsNodeList.getLength(); j++) {
Node optionItem = optionsNodeList.item(j);
NamedNodeMap attributes = optionItem.getAttributes();
if (attributes == null)
continue;
Option option = OptionParser.parse(optionItem, artifact.getContainingFile());
artifact.addOption(option);
}
} else if (nodeName.equalsIgnoreCase("phase")) {
NodeList phaseChildren = node.getChildNodes();
for (int j = 0; j < phaseChildren.getLength(); j++) {
Node phasesNode = phaseChildren.item(j);
String phaselist = phasesNode.getNodeValue();
String[] phases = phaselist.split("\\s");
for (int k = 0; k < phases.length; k++) {
try {
artifact.setPhase(UMA.getUma().getConfiguration().phaseFromString(phases[k]), true);
} catch (UMABadPhaseNameException e) {
throw new UMAException("in file: " + artifact.getContainingFile(), e);
}
}
}
} else if (nodeName.equalsIgnoreCase("includes")) {
NodeList includesNodeList = node.getChildNodes();
for (int j = 0; j < includesNodeList.getLength(); j++) {
Node includeItem = includesNodeList.item(j);
NamedNodeMap attributes = includeItem.getAttributes();
if (attributes == null)
continue;
Include include = new Include(artifact.getContainingFile());
include.setPath(attributes.getNamedItem("path").getNodeValue());
include.setType(attributes.getNamedItem("type").getNodeValue());
artifact.addInclude(include);
Parser.populatePredicateList(includeItem.getChildNodes(), include);
}
} else if (nodeName.equalsIgnoreCase("commands")) {
NodeList commandsNodeList = node.getChildNodes();
for (int j = 0; j < commandsNodeList.getLength(); j++) {
Node commandItem = commandsNodeList.item(j);
NamedNodeMap attributes = commandItem.getAttributes();
if (attributes == null)
continue;
Command command = new Command(artifact.getContainingFile());
command.setCommand(attributes.getNamedItem("line").getNodeValue());
command.setType(attributes.getNamedItem("type").getNodeValue());
artifact.addCommand(command);
Parser.populatePredicateList(commandItem.getChildNodes(), command);
}
} else if (nodeName.equalsIgnoreCase("dependencies")) {
NodeList dependenciesNodeList = node.getChildNodes();
for (int j = 0; j < dependenciesNodeList.getLength(); j++) {
Node dependencyItem = dependenciesNodeList.item(j);
NamedNodeMap attributes = dependencyItem.getAttributes();
if (attributes == null)
continue;
Dependency dependency = new Dependency(artifact.getContainingFile());
dependency.setDependency(attributes.getNamedItem("name").getNodeValue());
artifact.addDependency(dependency);
Parser.populatePredicateList(dependencyItem.getChildNodes(), dependency);
}
} else if (nodeName.equalsIgnoreCase("libraries")) {
NodeList linkNodeList = node.getChildNodes();
for (int j = 0; j < linkNodeList.getLength(); j++) {
Node linkItem = linkNodeList.item(j);
if (linkItem.getNodeName().equalsIgnoreCase("library")) {
Library library = LibraryParser.parse(linkItem, artifact.getContainingFile());
artifact.addLibrary(library);
}
}
} else if (nodeName.equalsIgnoreCase("static-link-libraries")) {
NodeList linkNodeList = node.getChildNodes();
for (int j = 0; j < linkNodeList.getLength(); j++) {
Node linkItem = linkNodeList.item(j);
if (linkItem.getNodeName().equalsIgnoreCase("library")) {
Library library = LibraryParser.parse(linkItem, artifact.getContainingFile());
artifact.addStaticLinkLibrary(library);
}
}
} else if (nodeName.equalsIgnoreCase("objects")) {
NodeList linkNodeList = node.getChildNodes();
for (int j = 0; j < linkNodeList.getLength(); j++) {
Node linkItem = linkNodeList.item(j);
if (linkItem.getNodeName().equalsIgnoreCase("group") || linkItem.getNodeName().equalsIgnoreCase("object")) {
Object object = ObjectParser.parse(linkNodeList.item(j), artifact.getContainingFile());
artifact.addObject(object);
}
}
} else if (nodeName.equalsIgnoreCase("vpaths")) {
NodeList vpathsNodeList = node.getChildNodes();
for (int j = 0; j < vpathsNodeList.getLength(); j++) {
Node vpathItem = vpathsNodeList.item(j);
if (vpathItem.getNodeName().equalsIgnoreCase("vpath")) {
VPath vpath = VPathParser.parse(vpathItem, artifact.getContainingFile());
artifact.addVPath(vpath);
}
}
} else if (nodeName.equalsIgnoreCase("makefilestubs")) {
NodeList mfsNodeList = node.getChildNodes();
for (int j = 0; j < mfsNodeList.getLength(); j++) {
Node mfsItem = mfsNodeList.item(j);
if (mfsItem.getNodeName().equalsIgnoreCase("makefilestub")) {
NamedNodeMap attributes = mfsItem.getAttributes();
Node dataNode = attributes.getNamedItem("data");
MakefileStub makefileStub = new MakefileStub(dataNode.getNodeValue(), artifact.getContainingFile());
artifact.addMakefileStub(makefileStub);
Parser.populatePredicateList(mfsItem.getChildNodes(), makefileStub);
}
}
} else if (nodeName.equalsIgnoreCase("exports")) {
NodeList exportsNodeList = node.getChildNodes();
for (int j = 0; j < exportsNodeList.getLength(); j++) {
Node exportNode = exportsNodeList.item(j);
if (exportNode.getNodeName().equalsIgnoreCase("group")) {
Export group = ExportParser.parse(exportNode, artifact.getContainingFile());
artifact.addExport(group);
group.setType(Export.TYPE_GROUP);
} else if (exportNode.getNodeName().equalsIgnoreCase("export")) {
Export group = ExportParser.parse(exportNode, artifact.getContainingFile());
artifact.addExport(group);
group.setType(Export.TYPE_FUNCTION);
}
}
} else if (nodeName.equalsIgnoreCase("flags")) {
NodeList flagsNodeList = node.getChildNodes();
for (int j = 0; j < flagsNodeList.getLength(); j++) {
Node item = flagsNodeList.item(j);
Flag f = FlagParser.parse(item, artifact.getContainingFile());
if (f != null) {
artifact.addFlag(f);
}
}
}
}
NamedNodeMap attributes = artifactNode.getAttributes();
Node nameNode = attributes.getNamedItem("name");
artifact.setName(nameNode.getNodeValue());
Node typeNode = attributes.getNamedItem("type");
artifact.setType(typeNode.getNodeValue());
Node bundleNode = attributes.getNamedItem("bundle");
if (bundleNode != null) {
artifact.setBundle(bundleNode.getNodeValue());
}
Node scopeNode = attributes.getNamedItem("scope");
if (scopeNode != null) {
artifact.setScope(scopeNode.getNodeValue());
}
Node includeInAllTargetNode = attributes.getNamedItem("all");
if (includeInAllTargetNode.getNodeValue().equalsIgnoreCase("true")) {
artifact.setIncludeInAllTarget(true);
} else {
artifact.setIncludeInAllTarget(false);
}
Node loadgroupNode = attributes.getNamedItem("loadgroup");
if (loadgroupNode != null) {
artifact.setLoadgroup(loadgroupNode.getNodeValue());
}
Node buildLocal = attributes.getNamedItem("buildlocal");
if (buildLocal.getNodeValue().equalsIgnoreCase("true")) {
artifact.setBuildLocal(true);
}
Node appendReleaseNode = attributes.getNamedItem("appendrelease");
if (appendReleaseNode.getNodeValue().equalsIgnoreCase("true")) {
artifact.setAppendRelease(true);
}
Node consoleNode = attributes.getNamedItem("console");
if (consoleNode.getNodeValue().equalsIgnoreCase("false")) {
artifact.setConsoleApplication(false);
} else {
artifact.setConsoleApplication(true);
}
Parser.populatePredicateList(nodeList, artifact);
return artifact;
}
use of com.ibm.uma.om.Flag in project openj9 by eclipse.
the class ModuleParser method parse.
public static Module parse(Document moduleXml, String modulePath) throws UMAException {
Module module = new Module(modulePath);
// Initialize the Module based on the XML document
Element elem = moduleXml.getDocumentElement();
NodeList nodeList = elem.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
String nodeName = node.getLocalName();
if (nodeName == null)
continue;
if (nodeName.equalsIgnoreCase("artifact")) {
Artifact artifact = ArtifactParser.parse(node, module);
module.addArtifact(artifact);
UMA.getUma().addArtifact(artifact);
} else if (nodeName.equalsIgnoreCase("exports")) {
Exports exps = ExportsParser.parse(node, module.getContainingFile());
module.addExports(exps.getGroup(), exps);
} else if (nodeName.equalsIgnoreCase("objects")) {
Objects objs = ObjectsParser.parse(node, module.getContainingFile());
module.addObjects(objs.getGroup(), objs);
} else if (nodeName.equalsIgnoreCase("exportlists")) {
Vector<Exports> exports = ExportlistsParser.parse(node, module.getContainingFile());
for (Exports exps : exports) {
module.addExports(exps.getGroup(), exps);
}
} else if (nodeName.equalsIgnoreCase("objectlists")) {
Vector<Objects> objects = ObjectlistsParser.parse(node, module.getContainingFile());
for (Objects objs : objects) {
module.addObjects(objs.getGroup(), objs);
}
} else if (nodeName.equalsIgnoreCase("flaglists")) {
Vector<Flags> flags = FlaglistsParser.parse(node, module.getContainingFile());
for (Flags f : flags) {
// System.out.println("Flag: " + (f == null ? "null" : f.getGroup()));
module.addFlags(f.getGroup(), f);
}
} else if (nodeName.equalsIgnoreCase("flags")) {
Flags flags = FlagsParser.parse(node, module.getContainingFile());
// System.out.println("GROUP: " + flags.getGroup());
for (Flag f : flags.getFlags()) {
/*
if (f != null) {
System.out.println("FLAG: "+ f.getName());
} else {
System.out.println("NULL FLAG");
}
*/
}
module.addFlags(flags.getGroup(), flags);
}
}
Parser.populatePredicateList(nodeList, module);
return module;
}
use of com.ibm.uma.om.Flag in project openj9 by eclipse.
the class FlagsParser method parse.
public static Flags parse(Node node, String containingFile) throws UMAException {
Flags flags = new Flags(containingFile);
NamedNodeMap attributes = node.getAttributes();
flags.setGroup(attributes.getNamedItem("group").getNodeValue());
NodeList nodeList = node.getChildNodes();
for (int j = 0; j < nodeList.getLength(); j++) {
Node item = nodeList.item(j);
if (item.getNodeName().equalsIgnoreCase("flag")) {
Flag f = FlagParser.parse(item, containingFile);
flags.addFlag(f);
} else if (item.getNodeName().equalsIgnoreCase("group")) {
NamedNodeMap attr = item.getAttributes();
String objectGroupName = attr.getNamedItem("name").getNodeValue();
Flag f = new Flag(objectGroupName, containingFile);
flags.addFlag(f);
}
}
Parser.populatePredicateList(nodeList, flags);
return flags;
}
Aggregations