Search in sources :

Example 1 with Flag

use of com.ibm.j9tools.om.Flag in project openj9 by eclipse.

the class FeatureParser method startElement.

/**
 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
 */
@Override
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, Attributes attributes) {
    /* We are starting to parse a new element, reset the parsed value */
    // $NON-NLS-1$
    _parsedValue = "";
    if (qName.equalsIgnoreCase("feature")) {
        // $NON-NLS-1$
        /* Reset the flags list */
        _flags = new Vector<Flag>();
        /* Set the build spec id */
        // $NON-NLS-1$
        _feature.setId(attributes.getValue("id"));
        _feature.setLocation(_documentLocatorFile, _documentLocator);
    } else if (qName.equalsIgnoreCase("properties")) {
        // $NON-NLS-1$
        _properties = new Vector<Property>();
    } else if (qName.equalsIgnoreCase("requiredProperty") && _properties != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        Property property = new Property(attributes.getValue("name"), null);
        property.setLocation(_documentLocatorFile, _documentLocator);
        _properties.add(property);
    } else /* Parse sources of the feature */
    if (qName.equalsIgnoreCase("source")) {
        // $NON-NLS-1$
        _sources = new Vector<Source>();
    } else if (qName.equalsIgnoreCase("project") && _sources != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        Source source = new Source(attributes.getValue("id"));
        source.setLocation(_documentLocatorFile, _documentLocator);
        _sources.add(source);
    } else /* Parse flags of the feature */
    if (qName.equalsIgnoreCase("flags")) {
        // $NON-NLS-1$
        /* Reset the flags list */
        _flags = new Vector<Flag>();
    } else if (qName.equalsIgnoreCase("flag") && _flags != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        String flagName = attributes.getValue("id");
        // $NON-NLS-1$
        Boolean flagState = Boolean.valueOf(attributes.getValue("value"));
        FlagDefinition flagDefinition = flagDefinitions.getFlagDefinition(flagName);
        Flag flag = new Flag(flagName, flagState);
        flag.setLocation(_documentLocatorFile, _documentLocator);
        if (flagDefinition != null) {
            flag.setDefinition(flagDefinition);
        }
        _flags.add(flag);
    }
}
Also used : FlagDefinition(com.ibm.j9tools.om.FlagDefinition) Flag(com.ibm.j9tools.om.Flag) Vector(java.util.Vector) Property(com.ibm.j9tools.om.Property) InputSource(org.xml.sax.InputSource) Source(com.ibm.j9tools.om.Source)

Example 2 with Flag

use of com.ibm.j9tools.om.Flag in project openj9 by eclipse.

the class BuildSpecParser method startElement.

/**
 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
 */
@Override
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, Attributes attributes) {
    /* We are starting to parse a new element, reset the parsed value */
    // $NON-NLS-1$
    _parsedValue = "";
    if (qName.equalsIgnoreCase("spec")) {
        // $NON-NLS-1$
        /* Reset all lists */
        _owners = new Vector<Owner>();
        _features = new Vector<Feature>();
        _flags = new Vector<Flag>();
        _sources = new Vector<Source>();
        _properties = new Vector<Property>();
        /* Set the build spec id */
        // $NON-NLS-1$
        _buildSpec.setId(attributes.getValue("id"));
        /* Remember where this build spec was defined */
        _buildSpec.setLocation(_documentLocatorFile, _documentLocator);
    } else /* Parse owners of the build spec */
    if (qName.equalsIgnoreCase("owners")) {
        // $NON-NLS-1$
        _owners = new Vector<Owner>();
    } else /* Parse flags of the build spec */
    if (qName.equalsIgnoreCase("flags")) {
        // $NON-NLS-1$
        _flags = new Vector<Flag>();
    } else if (qName.equalsIgnoreCase("flag") && _flags != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        String flagName = attributes.getValue("id");
        // $NON-NLS-1$
        Boolean flagState = Boolean.valueOf(attributes.getValue("value"));
        FlagDefinition flagDefinition = flagDefinitions.getFlagDefinition(flagName);
        Flag flag = new Flag(flagName, flagState);
        flag.setLocation(_documentLocatorFile, _documentLocator);
        if (flagDefinition != null) {
            flag.setDefinition(flagDefinition);
        }
        _flags.add(flag);
    } else /* Parse features of the build spec */
    if (qName.equalsIgnoreCase("features")) {
        // $NON-NLS-1$
        _features = new Vector<Feature>();
    } else if (qName.equalsIgnoreCase("feature") && _features != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        String featureId = attributes.getValue("id");
        FeatureDefinition featureDefinition = featureDefinitions.get(featureId);
        Feature feature = new Feature(featureId);
        feature.setLocation(_documentLocatorFile, _documentLocator);
        if (featureDefinition != null) {
            feature.setDefinition(featureDefinition);
        }
        _features.add(feature);
    } else /* Parse sources of the build spec */
    if (qName.equalsIgnoreCase("source")) {
        // $NON-NLS-1$
        _sources = new Vector<Source>();
    } else if (qName.equalsIgnoreCase("project") && _sources != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        Source source = new Source(attributes.getValue("id"));
        source.setLocation(_documentLocatorFile, _documentLocator);
        _sources.add(source);
    } else /* Parse properties of the build spec */
    if (qName.equalsIgnoreCase("properties")) {
        // $NON-NLS-1$
        _properties = new Vector<Property>();
    } else if (qName.equalsIgnoreCase("property") && _properties != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$ //$NON-NLS-2$
        Property property = new Property(attributes.getValue("name"), attributes.getValue("value"));
        property.setLocation(_documentLocatorFile, _documentLocator);
        _properties.add(property);
    }
}
Also used : Owner(com.ibm.j9tools.om.Owner) FlagDefinition(com.ibm.j9tools.om.FlagDefinition) Feature(com.ibm.j9tools.om.Feature) Flag(com.ibm.j9tools.om.Flag) Source(com.ibm.j9tools.om.Source) InputSource(org.xml.sax.InputSource) FeatureDefinition(com.ibm.j9tools.om.FeatureDefinition) Property(com.ibm.j9tools.om.Property) Vector(java.util.Vector)

Example 3 with Flag

use of com.ibm.j9tools.om.Flag in project openj9 by eclipse.

the class Main method main.

public static void main(String[] args) {
    if (!parseOptions(args)) {
        System.out.print(applicationNameShort + " ");
        for (String arg : args) {
            System.out.print(" " + arg);
        }
        System.out.println();
        dumpHelp();
        System.exit(-1);
    }
    logger = Logger.initLogger(verbose ? Logger.InformationL2Log : Logger.InformationL1Log);
    dumpSplash();
    if (jitVersionFile.equals("")) {
        File tempJitVersionFile = new File(rootDir + "/compiler/trj9/build/version.h");
        if (tempJitVersionFile.exists() && !tempJitVersionFile.isDirectory()) {
            jitVersionFile = rootDir + "/compiler/trj9/build/version.h";
            System.out.print("Using version.h as the jitVersionFile\n");
        } else {
            tempJitVersionFile = new File(rootDir + "/jit.version");
            if (tempJitVersionFile.exists() && !tempJitVersionFile.isDirectory()) {
                jitVersionFile = rootDir + "/jit.version";
                System.out.print("Using jit.version as the jitVersionFile\n");
            }
        }
    }
    try {
        ConfigurationImpl configuration = new ConfigurationImpl(configDirectory, buildSpecId, buildId, buildDate, buildTag, jitVersionFile, excludeArtifacts);
        for (String flagString : overrideFlags.keySet()) {
            if (!configuration.isFlagValid(flagString)) {
                throw new UMAException("Invalid flag override: " + flagString);
            }
            Flag flag = configuration.getBuildSpec().getFlag(flagString);
            flag.setState(overrideFlags.get(flagString));
        }
        // Since we may have changed some flags, we need to re-verify them
        configuration.verify();
        new UMA(configuration, configuration, rootDir).generate();
    } catch (NullPointerException e) {
        logger.println(Logger.ErrorLog, "Internal error: null pointer exception");
        e.printStackTrace();
        System.exit(-1);
    } catch (UMAException e) {
        logger.println(Logger.ErrorLog, e.getMessage());
        System.exit(-1);
    }
}
Also used : UMA(com.ibm.uma.UMA) UMAException(com.ibm.uma.UMAException) File(java.io.File) ConfigurationImpl(com.ibm.j9.uma.configuration.ConfigurationImpl) Flag(com.ibm.j9tools.om.Flag)

Example 4 with Flag

use of com.ibm.j9tools.om.Flag in project openj9 by eclipse.

the class BuildSpecParser method endElement.

/**
 * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
 */
@Override
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) {
    if (qName.equalsIgnoreCase("name")) {
        // $NON-NLS-1$
        _buildSpec.setName(_parsedValue);
    } else if (qName.equalsIgnoreCase("asmBuilderName")) {
        // $NON-NLS-1$
        AsmBuilder asmBuilder = new AsmBuilder(_parsedValue);
        asmBuilder.setLocation(_documentLocatorFile, _documentLocator);
        _buildSpec.setAsmBuilder(asmBuilder);
    } else if (qName.equalsIgnoreCase("cpuArchitecture")) {
        // $NON-NLS-1$
        _buildSpec.setCpuArchitecture(_parsedValue);
    } else if (qName.equalsIgnoreCase("os")) {
        // $NON-NLS-1$
        _buildSpec.setOs(_parsedValue);
    } else if (qName.equalsIgnoreCase("defaultJCL")) {
        // $NON-NLS-1$
        JclConfiguration jclConfiguration = new JclConfiguration(_parsedValue);
        jclConfiguration.setLocation(_documentLocatorFile, _documentLocator);
        _buildSpec.setDefaultJCL(jclConfiguration);
    } else if (qName.equalsIgnoreCase("defaultSizes")) {
        // $NON-NLS-1$
        DefaultSizes defaultSizes = new DefaultSizes(_parsedValue);
        defaultSizes.setLocation(_documentLocatorFile, _documentLocator);
        _buildSpec.setDefaultSizes(defaultSizes);
    } else if (qName.equalsIgnoreCase("priority")) {
        // $NON-NLS-1$
        try {
            _buildSpec.setPriority(Integer.parseInt(_parsedValue));
        } catch (NumberFormatException e) {
            // $NON-NLS-1$
            error(new SAXParseException("Invalid priority value, not a valid integer.", _documentLocator));
        }
    } else if (qName.equalsIgnoreCase("owner")) {
        // $NON-NLS-1$
        /* Parsed a single owner, add it to the list of Owners */
        Owner owner = new Owner(_parsedValue);
        owner.setLocation(_documentLocatorFile, _documentLocator);
        _buildSpec.addOwner(owner);
    } else if (qName.equalsIgnoreCase("owners")) {
        // $NON-NLS-1$
        /* Parsed all owners, add it to the BuildSpec */
        _owners.add(new Owner(_parsedValue));
    } else /* The <flags> element is being closed. Add all parsed flags to the buildSpec */
    if (qName.equalsIgnoreCase("flags")) {
        // $NON-NLS-1$
        for (Flag f : _flags) {
            _buildSpec.addFlag(f);
        }
        // flags set to a default value of FALSE
        for (FlagDefinition flagDefinition : flagDefinitions.getFlagDefinitions().values()) {
            if (!_buildSpec.hasFlag(flagDefinition.getId())) {
                _buildSpec.addFlag(new Flag(flagDefinition));
            }
        }
    } else /* The <features> element is being closed. Add all parsed features to the buildSpec */
    if (qName.equalsIgnoreCase("features")) {
        // $NON-NLS-1$
        for (Feature f : _features) {
            /* Save the feature id, it is not our responsibility to load the actual feature here */
            _buildSpec.addFeature(f);
        }
    } else /* The <sources> element is being closed. Add all parsed sources to the buildSpec */
    if (qName.equalsIgnoreCase("source")) {
        // $NON-NLS-1$
        for (Source s : _sources) {
            _buildSpec.addSource(s);
        }
    } else /* The <properties> element is being closed. Add all parsed properties to the buildSpec */
    if (qName.equalsIgnoreCase("properties")) {
        // $NON-NLS-1$
        for (Property p : _properties) {
            _buildSpec.addProperty(p);
        }
    }
}
Also used : AsmBuilder(com.ibm.j9tools.om.AsmBuilder) Owner(com.ibm.j9tools.om.Owner) JclConfiguration(com.ibm.j9tools.om.JclConfiguration) FlagDefinition(com.ibm.j9tools.om.FlagDefinition) SAXParseException(org.xml.sax.SAXParseException) DefaultSizes(com.ibm.j9tools.om.DefaultSizes) Flag(com.ibm.j9tools.om.Flag) Feature(com.ibm.j9tools.om.Feature) Property(com.ibm.j9tools.om.Property) Source(com.ibm.j9tools.om.Source) InputSource(org.xml.sax.InputSource)

Aggregations

Flag (com.ibm.j9tools.om.Flag)4 FlagDefinition (com.ibm.j9tools.om.FlagDefinition)3 Property (com.ibm.j9tools.om.Property)3 Source (com.ibm.j9tools.om.Source)3 InputSource (org.xml.sax.InputSource)3 Feature (com.ibm.j9tools.om.Feature)2 Owner (com.ibm.j9tools.om.Owner)2 Vector (java.util.Vector)2 ConfigurationImpl (com.ibm.j9.uma.configuration.ConfigurationImpl)1 AsmBuilder (com.ibm.j9tools.om.AsmBuilder)1 DefaultSizes (com.ibm.j9tools.om.DefaultSizes)1 FeatureDefinition (com.ibm.j9tools.om.FeatureDefinition)1 JclConfiguration (com.ibm.j9tools.om.JclConfiguration)1 UMA (com.ibm.uma.UMA)1 UMAException (com.ibm.uma.UMAException)1 File (java.io.File)1 SAXParseException (org.xml.sax.SAXParseException)1