src/main/java/de/unixwork/uwproj/Feature.java

Sat, 03 Aug 2019 13:46:43 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 03 Aug 2019 13:46:43 +0200
changeset 7
686991ae6e2f
parent 0
38775db5fdf5
child 40
b42bfc9e9983
permissions
-rw-r--r--

add configureable make variables

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package de.unixwork.uwproj;

import java.util.LinkedList;
import java.util.List;
import org.w3c.dom.Element;

/**
 *
 * @author olaf
 */
public class Feature {
    private String name;
    private String arg;
    private boolean def;
    
    private TargetData targetData;
    
    public static Feature parse(Project project, Element e) throws Exception {
        Feature feature = new Feature();
        String name = e.getAttribute("name");
        String arg = e.getAttribute("arg");
        String def = e.getAttribute("default");
        
        if(name.length() == 0) {
            throw new Exception("feature element requires name attribute");
        }
        
        String ld = def.toLowerCase();
        boolean on = ld.equals("on") || ld.equals("true");
        feature.setName(name);
        feature.setDefault(on);
        if(arg.length() == 0) {
            feature.setArg(name);
        } else {
            feature.setArg(arg);
        }
        
        feature.setTargetData(TargetData.parse(e));
        project.addFeature(feature);
        return feature;
    }
    
    public String getVarName() {
        return "FEATURE_"+name.toUpperCase();
    }
    
    public List<String> getDependencies() {
        return getTargetData().getDependencies();
    }

    public List<Define> getDefines() {
        return getTargetData().getDefines();
    }
    
    public String getMake() {
        return targetData.getMake();
    }
    
    public boolean hasMake() {
        return targetData.getMake().trim().length() > 0;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getArg() {
        return arg;
    }

    public void setArg(String arg) {
        this.arg = arg;
    }

    public boolean isDefault() {
        return def;
    }

    public void setDefault(boolean def) {
        this.def = def;
    }

    public TargetData getTargetData() {
        return targetData;
    }

    public void setTargetData(TargetData targetData) {
        this.targetData = targetData;
    }   
}

mercurial