Wed, 06 Sep 2023 22:55:42 +0200
first minor code improvements
--- a/src/main/java/de/unixwork/uwproj/ConfigVar.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/ConfigVar.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,58 +1,44 @@ -/* - * 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 org.w3c.dom.Element; -/** - * - * @author olaf - */ public class ConfigVar { - String name; - String value; + private String varName; + private String value; private boolean exec = false; - + public static ConfigVar parse(Element e) { + return parse(e, false); + } + + public static ConfigVar parse(Element e, boolean varNameIsElemName) { ConfigVar var = new ConfigVar(); - - String name = e.getAttribute("name"); - if(name == null || name.length() == 0) { - System.err.println("<var>-element: name attribute required"); - return null; + + if (varNameIsElemName) { + var.varName = e.getNodeName().toUpperCase(); + } else { + String name = e.getAttribute("name"); + if (name.isBlank()) { + System.err.println("<var>-element: name attribute required"); + return null; + } + var.varName = name; } - var.name = name; - - String value = Xml.getContent(e); - var.value = value == null ? "" : value; - - String type = e.getAttribute("type"); - if(type != null && type.equals("exec")) { - var.exec = true; - } - + + var.value = Util.getContent(e); + var.exec = e.getAttribute("type").equals("exec"); + return var; } - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; + public String getVarName() { + return varName; } public String getValue() { return value; } - public void setValue(String value) { - this.value = value; - } - public boolean isExec() { return exec; }
--- a/src/main/java/de/unixwork/uwproj/Define.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/Define.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,15 +1,5 @@ package de.unixwork.uwproj; -/* - * 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. - */ - -/** - * - * @author olaf - */ public class Define { private String name; private String value;
--- a/src/main/java/de/unixwork/uwproj/Dependency.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/Dependency.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,79 +1,71 @@ -/* - * 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 org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.util.LinkedList; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; -/** - * - * @author olaf - */ +import static de.unixwork.uwproj.Util.isNullOrBlank; + public class Dependency { private String name; private String platform; private String not; - - private List<Flags> flags = new LinkedList<>(); - private List<PkgConfigPackage> pkgconfig = new LinkedList<>(); - private List<String> tests = new LinkedList<>(); - private StringBuilder make = new StringBuilder(); - - private List<String> lang = new LinkedList<>(); - + + private final List<ConfigVar> flags = new LinkedList<>(); + private final List<PkgConfigPackage> pkgconfig = new LinkedList<>(); + private final List<String> tests = new LinkedList<>(); + private final StringBuilder make = new StringBuilder(); + + private final List<String> lang = new LinkedList<>(); + private boolean abortOnError = false; - + private int num = 0; - + public static Dependency parse(Element element) throws Exception { Dependency d = new Dependency(); - + String name = element.getAttribute("name"); String platform = element.getAttribute("platform"); String not = element.getAttribute("not"); - if(name.length() > 0) { + if (!name.isEmpty()) { d.setName(name); } - if(platform.length() > 0) { + if (!platform.isEmpty()) { d.setPlatform(platform); } - if(not.length() > 0) { + if (!not.isEmpty()) { d.setNotString(not); } - + NodeList nodes = element.getChildNodes(); - for(int i=0;i<nodes.getLength();i++) { + for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { - Element elm = (Element)node; + Element elm = (Element) node; String n = elm.getNodeName(); - if(n.equals("cflags") || n.equals("ldflags")) { - Flags f = Flags.parse(elm); - d.addFlags(f); - } else if(n.equals("pkgconfig")) { + if (n.equals("cflags") || n.equals("ldflags")) { + Optional.ofNullable(ConfigVar.parse(elm, true)).ifPresent(d::addFlags); + } else if (n.equals("pkgconfig")) { PkgConfigPackage pcp = PkgConfigPackage.parse(elm); d.addPkgconfig(pcp); - } else if(n.equals("test")) { - d.tests.add(Xml.getContent(elm)); - } else if(n.equals("make")) { - String m = Xml.getContent(elm); + } else if (n.equals("test")) { + d.tests.add(Util.getContent(elm)); + } else if (n.equals("make")) { + String m = Util.getContent(elm); d.addMake(m); - } else if(n.equals("lang")) { + } else if (n.equals("lang")) { d.lang.add(n.trim().toLowerCase()); } } } - + return d; } - + public String getName() { return name; } @@ -85,40 +77,35 @@ public String getPlatform() { return platform; } - + public String getFullName() { - if(platform == null || platform.length() == 0) { + if (isNullOrBlank(platform)) { return name; } else { - return name+" platform=\""+platform+'"'; + return name + " platform=\"" + platform + '"'; } } - + public void setNotString(String not) { this.not = not; } - + public List<String> getNotList() { - List<String> notPlatforms = new LinkedList<>(); - if(not != null) { - String[] n = not.split(","); - for(String s : n) { - notPlatforms.add(s); - } - } - return notPlatforms; + return isNullOrBlank(not) ? + Collections.emptyList() : + Arrays.stream(not.split(",")).map(String::trim).collect(Collectors.toList()); } public void setPlatform(String platform) { this.platform = platform; } - public List<Flags> getFlags() { + public List<ConfigVar> getFlags() { return flags; } - public void addFlags(Flags flags) { - this.flags.add(flags); + public void addFlags(ConfigVar var) { + this.flags.add(var); } public List<PkgConfigPackage> getPkgconfig() { @@ -136,28 +123,28 @@ public void setAbortOnError(boolean abortOnError) { this.abortOnError = abortOnError; } - + public int getNum() { return num; } - + public void setNum(int num) { this.num = num; } - + public List<String> getTests() { return tests; } - + public void addMake(String m) { make.append(m.trim()); make.append('\n'); } - + public String getMake() { return make.toString(); } - + public List<String> getLang() { return lang; }
--- a/src/main/java/de/unixwork/uwproj/Feature.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/Feature.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,18 +1,9 @@ -/* - * 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 - */ +import java.util.List; + public class Feature { private String name; private String arg; @@ -26,7 +17,7 @@ String arg = e.getAttribute("arg"); String def = e.getAttribute("default"); - if(name.length() == 0) { + if(name.isEmpty()) { throw new Exception("feature element requires name attribute"); } @@ -34,7 +25,7 @@ boolean on = ld.equals("on") || ld.equals("true"); feature.setName(name); feature.setDefault(on); - if(arg.length() == 0) { + if(arg.isEmpty()) { feature.setArg(name); } else { feature.setArg(arg); @@ -62,7 +53,7 @@ } public boolean hasMake() { - return targetData.getMake().trim().length() > 0; + return !targetData.getMake().trim().isEmpty(); } public String getName() {
--- a/src/main/java/de/unixwork/uwproj/Flags.java Wed Sep 06 21:08:04 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * 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 org.w3c.dom.Element; - -/** - * - * @author olaf - */ -public class Flags { - private String varName; - private String value; - private boolean exec = false; - - public static Flags parse(Element e) { - Flags f = new Flags(); - f.varName = e.getNodeName().toUpperCase(); - String value = Xml.getContent(e); - f.value = value == null ? "" : value; - - String type = e.getAttribute("type"); - if(type != null && type.equals("exec")) { - f.exec = true; - } - - return f; - } - - public String getVarName() { - return varName; - } - - public void setVarName(String varName) { - this.varName = varName; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public boolean isExec() { - return exec; - } - - public void setExec(boolean exec) { - this.exec = exec; - } -}
--- a/src/main/java/de/unixwork/uwproj/NamedDependency.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/NamedDependency.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,16 +1,7 @@ -/* - * 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.List; -/** - * - * @author olaf - */ public class NamedDependency { private String name; private List<Dependency> subdependencies;
--- a/src/main/java/de/unixwork/uwproj/Option.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/Option.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,20 +1,12 @@ -/* - * 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; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -/** - * - * @author olaf - */ +import java.util.LinkedList; +import java.util.List; + public class Option { private String arg; @@ -24,7 +16,7 @@ public static Option parse(Project project, Element element) throws Exception { Option opt = new Option(); String arg = element.getAttribute("arg"); - if(arg.length() == 0) { + if(arg.isEmpty()) { throw new Exception("Option has no argument string"); } opt.setArgument(arg); @@ -45,7 +37,7 @@ String defPlatform = elm.getAttribute(("platform")); OptionDefault def = new OptionDefault(opt); def.setValueName(defValue); - if(defPlatform.length() > 0) { + if(!defPlatform.isEmpty()) { def.setPlatform(defPlatform); } opt.defaults.add(def); @@ -85,7 +77,7 @@ } public String getValuesString() { - if(values.size() == 0) { + if(values.isEmpty()) { return "()"; } else if(values.size() == 1) { return values.get(0).getValue();
--- a/src/main/java/de/unixwork/uwproj/OptionDefault.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/OptionDefault.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,23 +1,14 @@ -/* - * 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; -/** - * - * @author olaf - */ public class OptionDefault { - private Option option; + private final Option option; private String value; private String platform; public OptionDefault(Option opt) { option = opt; } - + public String getValueName() { return value; } @@ -33,14 +24,14 @@ public void setPlatform(String platform) { this.platform = platform; } - + public String getFunc() { return option.getValueFunc(value); } - + public OptionValue getValue() { - for(OptionValue val : option.getValues()) { - if(val.getValue().equals(value)) { + for (OptionValue val : option.getValues()) { + if (val.getValue().equals(value)) { return val; } }
--- a/src/main/java/de/unixwork/uwproj/OptionValue.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/OptionValue.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,17 +1,7 @@ -/* - * 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.List; -import java.util.LinkedList; -/** - * - * @author olaf - */ public class OptionValue { Option option; @@ -52,6 +42,6 @@ } public boolean hasMake() { - return targetData.getMake().trim().length() > 0; + return !targetData.getMake().trim().isEmpty(); } }
--- a/src/main/java/de/unixwork/uwproj/PkgConfigPackage.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/PkgConfigPackage.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,16 +1,7 @@ -/* - * 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 org.w3c.dom.Element; -/** - * - * @author olaf - */ public class PkgConfigPackage { private String name; private String atleast; @@ -18,7 +9,7 @@ public static PkgConfigPackage parse(Element e) throws Exception { PkgConfigPackage p = new PkgConfigPackage(); - String name = Xml.getContent(e); + String name = Util.getContent(e); if(name != null) { p.setName(name); } else {
--- a/src/main/java/de/unixwork/uwproj/Project.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/Project.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,115 +1,93 @@ -/* - * 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 org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; import java.util.*; -/** - * - * @author olaf - */ public class Project { - private String path; - private Properties properties = new Properties(); - - private HashMap<String,List<Dependency>> namedDependencies = new HashMap<>(); - private List<Dependency> dependencies = new LinkedList<>(); - private List<Target> targets = new LinkedList<>(); - private List<Option> options = new LinkedList<>(); - private List<Feature> features = new LinkedList<>(); - - private HashMap<String,ConfigVar> configVars = new HashMap<>(); - private List<ConfigVar> configVarsList = new LinkedList<>(); - + private final Properties properties = new Properties(); + + private final HashMap<String, List<Dependency>> namedDependencies = new HashMap<>(); + private final List<Dependency> dependencies = new LinkedList<>(); + private final List<Target> targets = new LinkedList<>(); + private final List<Option> options = new LinkedList<>(); + private final List<Feature> features = new LinkedList<>(); + + private final HashMap<String, ConfigVar> configVars = new HashMap<>(); + private final List<ConfigVar> configVarsList = new LinkedList<>(); + public Project(File file) throws Exception { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.parse(file); - - Element root = doc.getDocumentElement(); + var root = DocumentBuilderFactory. + newDefaultNSInstance(). + newDocumentBuilder(). + parse(file). + getDocumentElement(); NodeList dependency_nodes = root.getElementsByTagName("dependency"); NodeList target_nodes = root.getElementsByTagName("target"); NodeList property_nodes = root.getElementsByTagName("property"); - NodeList config_nodes = root.getElementsByTagName("config"); - for(int i=0;i<config_nodes.getLength();i++) { - Element p = (Element)config_nodes.item(i); + + for (int i = 0; i < config_nodes.getLength(); i++) { + Element p = (Element) config_nodes.item(i); NodeList cfgs = p.getChildNodes(); - for(int c=0;c<cfgs.getLength();c++) { + for (int c = 0; c < cfgs.getLength(); c++) { Node node = cfgs.item(c); if (node.getNodeType() == Node.ELEMENT_NODE) { - if(node.getNodeName().equals("var")) { - ConfigVar var = ConfigVar.parse((Element)node); - if(var != null) { - configVarsList.add(var); - configVars.put(var.getName(), var); - } + if (node.getNodeName().equals("var")) { + Optional.ofNullable(ConfigVar.parse((Element) node)).ifPresent(v -> { + configVars.put(v.getVarName(), v); + configVarsList.add(v); + }); } } } } - - for(int i=0;i<dependency_nodes.getLength();i++) { - addDependency(Dependency.parse((Element)dependency_nodes.item(i))); + + for (int i = 0; i < dependency_nodes.getLength(); i++) { + addDependency(Dependency.parse((Element) dependency_nodes.item(i))); } - for(int i=0;i<target_nodes.getLength();i++) { - targets.add(Target.parse(this, (Element)target_nodes.item(i))); + for (int i = 0; i < target_nodes.getLength(); i++) { + targets.add(Target.parse(this, (Element) target_nodes.item(i))); } - for(int i=0;i<property_nodes.getLength();i++) { - Element p = (Element)property_nodes.item(i); + for (int i = 0; i < property_nodes.getLength(); i++) { + var p = (Element) property_nodes.item(i); String name = p.getAttribute("name"); String value = p.getAttribute("value"); - if(name != null && value != null) { + if (!name.isBlank() && !value.isBlank()) { properties.setProperty(name, value); } else { throw new Exception("Missing property name or value"); } } - - if(targets.size() == 0) { + + if (targets.isEmpty()) { createDefaultTarget(); } } - + private void createDefaultTarget() { - Target t = new Target(); + var t = new Target(); t.setAllDependencies(true); t.setName("default"); addTarget(t); } - - public String getPath() { - return path; - } - public void setPath(String path) { - this.path = path; - } - public List<NamedDependency> getNamedDependencies() { - List<NamedDependency> ret = new LinkedList<>(); - - for(Map.Entry<String,List<Dependency>> entry : namedDependencies.entrySet()) { - NamedDependency d = new NamedDependency(); + var ret = new LinkedList<NamedDependency>(); + + for (var entry : namedDependencies.entrySet()) { + var d = new NamedDependency(); d.setName(entry.getKey()); d.setSubdependencies(entry.getValue()); ret.add(d); } return ret; } - + public List<Dependency> getDependencies() { return dependencies; } @@ -117,45 +95,41 @@ public List<Target> getTargets() { return targets; } - + public void addDependency(Dependency dependency) { if(dependency.getName() != null) { - List<Dependency> l = namedDependencies.get(dependency.getName()); - if(l == null) { - l = new LinkedList<>(); - namedDependencies.put(dependency.getName(), l); - } + List<Dependency> l = namedDependencies.computeIfAbsent(dependency.getName(), k -> new LinkedList<>()); dependency.setNum(l.size()); l.add(dependency); } else { dependencies.add(dependency); } } - + public void addTarget(Target target) { targets.add(target); } - + public void addOption(Option o) { options.add(o); } - + public List<Option> getOptions() { return options; } - + public void addFeature(Feature feature) { features.add(feature); } - + public List<Feature> getFeatures() { return features; } - + public List<ConfigVar> getVars() { return configVarsList; } - + public boolean hasVar(String varName) { return configVars.containsKey(varName); }
--- a/src/main/java/de/unixwork/uwproj/Target.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/Target.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,29 +1,21 @@ -/* - * 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; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -/** - * - * @author olaf - */ +import java.util.LinkedList; +import java.util.List; + public class Target { private String name; private String prefix; - private List<String> dependencies = new LinkedList<>(); - private List<String> optionalDependencies = new LinkedList<>(); - private List<Define> defines = new LinkedList<>(); - private List<Feature> features = new LinkedList<>(); - private List<Option> options = new LinkedList<>(); + private final List<String> dependencies = new LinkedList<>(); + private final List<String> optionalDependencies = new LinkedList<>(); + private final List<Define> defines = new LinkedList<>(); + private final List<Feature> features = new LinkedList<>(); + private final List<Option> options = new LinkedList<>(); private boolean allDependencies = false; @@ -31,7 +23,7 @@ Target target = new Target(); String name = element.getAttribute("name"); - if(name.length() > 0) { + if(!name.isEmpty()) { target.setName(name); } @@ -47,12 +39,12 @@ } else if(n.equals("define")) { String def = elm.getAttribute("name"); String defval = elm.getAttribute("value"); - if(def == null) { + if (def.isBlank()) { throw new Exception("define element requires name attribute"); } target.addDefine(def, defval); } else if(n.equals("dependencies")) { - String deps = Xml.getContent(elm); + String deps = Util.getContent(elm); String[] dependencies = deps.split(","); for(String dependency : dependencies) { dependency = dependency.trim();
--- a/src/main/java/de/unixwork/uwproj/TargetData.java Wed Sep 06 21:08:04 2023 +0200 +++ b/src/main/java/de/unixwork/uwproj/TargetData.java Wed Sep 06 22:55:42 2023 +0200 @@ -1,24 +1,16 @@ -/* - * 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; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -/** - * - * @author olaf - */ +import java.util.LinkedList; +import java.util.List; + public class TargetData { - private List<Define> defines = new LinkedList<>(); - private List<String> dependencies = new LinkedList<>(); - private StringBuilder make = new StringBuilder(); + private final List<Define> defines = new LinkedList<>(); + private final List<String> dependencies = new LinkedList<>(); + private final StringBuilder make = new StringBuilder(); public static TargetData parse(Element element) throws Exception { TargetData data = new TargetData(); @@ -32,19 +24,19 @@ if(n.equals("define")) { String def = elm.getAttribute("name"); String defval = elm.getAttribute("value"); - if(def == null) { + if (def.isBlank()) { throw new Exception("define element requires name attribute"); } data.addDefine(new Define(def, defval)); } else if(n.equals("dependencies")) { - String deps = Xml.getContent(elm); + String deps = Util.getContent(elm); String[] dependencies = deps.split(","); for(String dependency : dependencies) { dependency = dependency.trim(); data.addDependency(dependency); } } else if(n.equals("make")) { - String m = Xml.getContent(elm); + String m = Util.getContent(elm); data.addMake(m); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/unixwork/uwproj/Util.java Wed Sep 06 22:55:42 2023 +0200 @@ -0,0 +1,32 @@ +package de.unixwork.uwproj; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class Util { + /** + * Returns the text content of the given element. + * + * @param elm the element + * @return the contents or empty string if there are no contents + */ + public static String getContent(Element elm) { + NodeList nodes = elm.getChildNodes(); + for (int i = 0; i < nodes.getLength(); i++) { + var node = nodes.item(i); + if (node.getNodeType() == Node.TEXT_NODE) { + return node.getTextContent(); + } + } + return ""; + } + + public static boolean isNullOrBlank(String s) { + return s == null || s.isBlank(); + } + + public static boolean isNotNullOrBlank(String s) { + return s != null && !s.isBlank(); + } +}
--- a/src/main/java/de/unixwork/uwproj/Xml.java Wed Sep 06 21:08:04 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* - * 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 org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * - * @author olaf - */ -public class Xml { - public static String getContent(Element elm) { - NodeList nodes = elm.getChildNodes(); - for(int i=0;i<nodes.getLength();i++) { - Node node = nodes.item(i); - if (node.getNodeType() == Node.TEXT_NODE) { - return node.getTextContent(); - } - } - return null; - } -}
--- a/src/test/resources/golden-sample/configure2 Wed Sep 06 21:08:04 2023 +0200 +++ b/src/test/resources/golden-sample/configure2 Wed Sep 06 22:55:42 2023 +0200 @@ -312,27 +312,21 @@ echo no return 1 } -dependency_test() +dependency_gtk2() { - printf "checking for test... " - # dependency test platform="bsd" + printf "checking for gtk2... " + # dependency gtk2 while true do - if isnotplatform "bsd"; then + if [ -z "$PKG_CONFIG" ]; then break fi - if isplatform "macos"; then + $PKG_CONFIG gtk+-2.0 + if [ $? -ne 0 ] ; then break fi - TEMP_CFLAGS="$TEMP_CFLAGS -DBSD" - echo yes - return 0 - done - - # dependency test - while true - do - TEMP_CFLAGS="$TEMP_CFLAGS -DTEST" + TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`" echo yes return 0 done @@ -362,21 +356,27 @@ echo no return 1 } -dependency_gtk2() +dependency_test() { - printf "checking for gtk2... " - # dependency gtk2 + printf "checking for test... " + # dependency test platform="bsd" while true do - if [ -z "$PKG_CONFIG" ]; then + if isnotplatform "bsd"; then + break + fi + if isplatform "macos"; then break fi - $PKG_CONFIG gtk+-2.0 - if [ $? -ne 0 ] ; then - break - fi - TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`" - TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`" + TEMP_CFLAGS="$TEMP_CFLAGS -DBSD" + echo yes + return 0 + done + + # dependency test + while true + do + TEMP_CFLAGS="$TEMP_CFLAGS -DTEST" echo yes return 0 done
--- a/test/make/configure.vm Wed Sep 06 21:08:04 2023 +0200 +++ b/test/make/configure.vm Wed Sep 06 22:55:42 2023 +0200 @@ -2,9 +2,9 @@ #foreach( $var in $vars ) #if( $var.exec ) -${var.name}=`${var.value}` +${var.varName}=`${var.value}` #else -${var.name}=${var.value} +${var.varName}=${var.value} #end #end @@ -247,7 +247,7 @@ # general vars #foreach( $var in $vars ) -${var.name}=$${var.name} +${var.varName}=$${var.varName} #end #if ( ! $project.hasVar("PREFIX") )